Example #1
0
JSBool js_model_bone_get_brightness_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	char			pose_name[name_str_len],bone_name[name_str_len];
	float			bright;
	model_draw		*draw;
	
		// get proper draw setup
		
	draw=script_bone_function_setup();
	if (draw==NULL) return(JS_FALSE);
	
		// get bone light

	script_value_to_string(argv[0],pose_name,name_str_len);
	script_value_to_string(argv[1],bone_name,name_str_len);
	
	if (!model_get_bone_brightness(draw,pose_name,bone_name,&bright)) {
		JS_ReportError(js.cx,"Named pose or bone does not exist: %s,%s",pose_name,bone_name);
		return(JS_FALSE);
	}
	
	*rval=script_float_to_value(bright);
	
	return(JS_TRUE);
}
Example #2
0
JSValueRef js_map_object_spawn_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	int				uid;
	char			name[name_str_len],err_str[256],
					script[name_str_len],params[256];
	d3pnt			pnt;
	d3ang			ang;

	if (!script_check_param_count(cx,func,argc,5,exception)) return(script_null_to_value(cx));

		// spawn values

	script_value_to_string(cx,argv[0],name,name_str_len);
	script_value_to_string(cx,argv[1],script,name_str_len);
	script_value_to_string(cx,argv[2],params,256);
	script_value_to_point(cx,argv[3],&pnt);
	script_value_to_angle(cx,argv[4],&ang);

		// spawn

	uid=object_script_spawn(name,script,params,&pnt,&ang,FALSE,err_str);
	if (uid==-1) {
		*exception=script_create_exception(cx,err_str);
		return(script_null_to_value(cx));
	}

		// return UID

	return(script_int_to_value(cx,uid));
}
Example #3
0
JSBool js_model_bone_find_position_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	char				pose_name[name_str_len],bone_name[name_str_len];
	int					x,y,z;
	model_draw			*draw;
	
		// get proper draw setup
		
	draw=script_bone_function_setup();
	if (draw==NULL) return(JS_FALSE);
	
		// get bone position
	
	script_value_to_string(argv[0],pose_name,name_str_len);
	script_value_to_string(argv[1],bone_name,name_str_len);
	
	if (!model_find_bone_position(draw,pose_name,bone_name,&x,&y,&z)) {
		JS_ReportError(js.cx,"Named pose or bone does not exist: %s,%s",pose_name,bone_name);
		return(JS_FALSE);
	}
	
	*rval=script_point_to_value(x,y,z);
	
	return(JS_TRUE);
}
Example #4
0
JSValueRef js_event_call_game_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	int				n,arg_count;
	char			func_name[64],err_str[256];
	JSValueRef		rval,args[20];

	if (!script_check_param_at_least_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	if (!script_check_fail_in_construct(cx,func,j_obj,exception)) return(script_null_to_value(cx));
	
		// get arguments

	script_value_to_string(cx,argv[0],func_name,64);

	arg_count=argc-1;
	if (arg_count<0) arg_count=0;
	if (arg_count>20) arg_count=20;

	for (n=0;n!=arg_count;n++) {
		args[n]=argv[n+1];
	}

		// call function

	rval=scripts_direct_call(script_get_index(j_obj),js.game_script_idx,-1,func_name,arg_count,args,err_str);
	if (rval==NULL) {
		*exception=script_create_exception(cx,err_str);
		return(script_null_to_value(cx));
	}
	
	return(rval);
}
Example #5
0
JSBool js_event_call_object_by_id_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	int				n,arg_count;
	char			func_name[64];
	jsval			args[20];
	obj_type		*obj;

		// get arguments

	obj=object_find_uid(JSVAL_TO_INT(argv[0]));
	if (obj==NULL) {
		*rval=JSVAL_FALSE;
		return(JS_TRUE);
	}

	script_value_to_string(argv[1],func_name,64);

	arg_count=argc-2;
	if (arg_count<0) arg_count=0;
	if (arg_count>20) arg_count=20;

	for (n=0;n!=arg_count;n++) {
		args[n]=argv[n+2];
	}

		// call function

	if (!scripts_direct_call(&obj->attach,func_name,arg_count,args,rval)) return(JS_FALSE);

	return(JS_TRUE);
}
Example #6
0
JSValueRef js_map_object_nearest_skip_object_id_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	int					type,min_dist,max_dist;
	char				*name_ptr,name[name_str_len];
	float				ang,ang_sweep;
	d3pnt				pnt;
	obj_type			*obj;

	name_ptr=NULL;
	type=-1;
	ang=-1;
	ang_sweep=360;
	
	if (!script_check_param_count(cx,func,argc,8,exception)) return(script_null_to_value(cx));

	script_value_to_point(cx,argv[0],&pnt);
	if (!script_is_value_null(cx,argv[1])) {
		script_value_to_string(cx,argv[1],name,name_str_len);
		name_ptr=name;
	}
	if (!script_is_value_null(cx,argv[2])) type=script_value_to_int(cx,argv[2])-sd_object_type_player;
	if (!script_is_value_null(cx,argv[3])) ang=script_value_to_float(cx,argv[3]);
	if (!script_is_value_null(cx,argv[4])) ang_sweep=script_value_to_float(cx,argv[4]);
	min_dist=script_value_to_int(cx,argv[5]);
	max_dist=script_value_to_int(cx,argv[6]);
	
		// find object

	obj=object_find_nearest(&pnt,name_ptr,type,-1,ang,ang_sweep,min_dist,max_dist,FALSE,script_value_to_int(cx,argv[7]));
	if (obj==NULL) return(script_int_to_value(cx,-1));
	
	return(script_int_to_value(cx,obj->idx));
}
Example #7
0
JSValueRef js_obj_position_place_random_node_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	int				idx;
	char			name[name_str_len];
	obj_type		*obj;
	node_type		*node;
	
	if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	
	obj=object_get_attach(j_obj);
	
		// find random node
		
	script_value_to_string(cx,argv[0],name,name_str_len);
	idx=map_find_random_node(&map,name,-1);
	if (idx==-1) return(script_null_to_value(cx));

		// move player
		
	node=&map.nodes[idx];
	
	object_set_position(obj,node->pnt.x,node->pnt.y,node->pnt.z,0.0f,0);
 	object_telefrag_players(obj,FALSE);

	return(script_null_to_value(cx));
}
Example #8
0
JSValueRef js_event_call_spawn_weapon_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	int				n,arg_count,script_idx;
	char			func_name[64],err_str[256];
	JSValueRef		rval,args[20];
	obj_type		*obj;
	weapon_type		*weap;
	proj_type		*proj;
	script_type		*script;

	if (!script_check_param_at_least_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	if (!script_check_fail_in_construct(cx,func,j_obj,exception)) return(script_null_to_value(cx));

		// find weapon that fired
		// this projectile

	script_idx=(int)JSObjectGetPrivate(j_obj);
	script=js.script_list.scripts[script_idx];
	
	if (script->attach.thing_type!=thing_type_projectile) {
		*exception=script_create_exception(cx,"Not an projectile script");
		return(script_null_to_value(cx));
	}

	proj=server.proj_list.projs[script->attach.proj_idx];
	if (!proj->on) {
		*exception=script_create_exception(cx,"Could not find projectile");
		return(script_null_to_value(cx));
	}

	obj=server.obj_list.objs[script->attach.obj_idx];
	weap=obj->weap_list.weaps[script->attach.weap_idx];
	if (weap==NULL) {
		*exception=script_create_exception(cx,"Could not find weapon");
		return(script_null_to_value(cx));
	}

		// get arguments

	script_value_to_string(cx,argv[0],func_name,64);

	arg_count=argc-1;
	if (arg_count<0) arg_count=0;
	if (arg_count>20) arg_count=20;

	for (n=0;n!=arg_count;n++) {
		args[n]=argv[n+1];
	}

		// call function

	rval=scripts_direct_call(script_get_index(j_obj),weap->script_idx,-1,func_name,arg_count,args,err_str);
	if (rval==NULL) {
		*exception=script_create_exception(cx,err_str);
		return(script_null_to_value(cx));
	}

	return(rval);
}
Example #9
0
JSBool js_interface_console_write_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	char			txt[256];
	
	script_value_to_string(argv[0],txt,256);
	console_add(txt);
	
	return(JS_TRUE);
}
Example #10
0
bool js_weap_projectile_set_objectFirePoseName(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef vp,JSValueRef *exception)
{
	weapon_type		*weap;
	
	weap=weapon_get_attach(j_obj);
	script_value_to_string(cx,vp,weap->proj.object_fire_pose_name,name_str_len);

	return(TRUE);
}
Example #11
0
JSValueRef js_data_get_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
    char			name[name_str_len];

    if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));

    script_value_to_string(cx,argv[0],name,name_str_len);
    return(script_get_global(cx,name));
}
Example #12
0
JSBool js_weap_zoom_set_maskName(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp)
{
	weapon_type		*weap;
	
	weap=weapon_find_uid(js.attach.thing_uid);
	script_value_to_string(*vp,weap->zoom.mask_name,name_str_len);
	weapon_attach_zoom_mask(weap);
	
	return(JS_TRUE);
}
Example #13
0
JSBool js_proj_melee_set_strikePoseName(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp)
{
    proj_setup_type		*proj_setup;

    proj_setup=proj_setup_get_attach();
    if (proj_setup==NULL) return(JS_TRUE);

    script_value_to_string(*vp,proj_setup->melee.strike_pose_name,name_str_len);

    return(JS_TRUE);
}
Example #14
0
JSValueRef js_obj_set_debug_string_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	obj_type		*obj;
	
	if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	
	obj=object_get_attach(j_obj);
	script_value_to_string(cx,argv[0],obj->debug.str,256);

	return(script_null_to_value(cx));
}
Example #15
0
JSBool js_proj_melee_set_strikeBoneTag(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp)
{
    char				str[32];
    proj_setup_type		*proj_setup;

    proj_setup=proj_setup_get_attach();
    if (proj_setup==NULL) return(JS_TRUE);

    script_value_to_string(*vp,str,32);
    proj_setup->melee.strike_bone_tag=text_to_model_tag(str);

    return(JS_TRUE);
}
Example #16
0
JSValueRef js_obj_motion_vector_walk_to_node_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
    char			start_name[name_str_len],end_name[name_str_len],err_str[256];
    obj_type		*obj;

    if (!script_check_param_count(cx,func,argc,3,exception)) return(script_null_to_value(cx));

    obj=object_get_attach(j_obj);

    // get node names

    script_value_to_string(cx,argv[0],start_name,name_str_len);
    script_value_to_string(cx,argv[1],end_name,name_str_len);

    // start walk

    if (!object_auto_walk_node_name_setup(obj,start_name,end_name,script_value_to_int(cx,argv[2]),err_str)) {
        *exception=script_create_exception(cx,err_str);
    }

    return(script_null_to_value(cx));
}
Example #17
0
JSValueRef js_event_call_held_weapon_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	int				n,arg_count,script_idx;
	char			func_name[64],err_str[256];
	JSValueRef		rval,args[20];
	obj_type		*obj;
	weapon_type		*weap;
	script_type		*script;

	if (!script_check_param_at_least_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	if (!script_check_fail_in_construct(cx,func,j_obj,exception)) return(script_null_to_value(cx));

		// find held weapon

	script_idx=(int)JSObjectGetPrivate(j_obj);
	script=js.script_list.scripts[script_idx];
	
	if (script->attach.thing_type!=thing_type_object) {
		*exception=script_create_exception(cx,"Not an object script");
		return(script_null_to_value(cx));
	}

	obj=object_get_attach(j_obj);
	weap=weapon_find_current(obj);
	if (weap==NULL) {
		*exception=script_create_exception(cx,"No held weapon");
		return(script_null_to_value(cx));
	}

		// get arguments

	script_value_to_string(cx,argv[0],func_name,64);

	arg_count=argc-1;
	if (arg_count<0) arg_count=0;
	if (arg_count>20) arg_count=20;

	for (n=0;n!=arg_count;n++) {
		args[n]=argv[n+1];
	}

		// call function

	rval=scripts_direct_call(script_get_index(j_obj),weap->script_idx,-1,func_name,arg_count,args,err_str);
	if (rval==NULL) {
		*exception=script_create_exception(cx,err_str);
		return(script_null_to_value(cx));
	}

	return(rval);
}
Example #18
0
JSValueRef js_obj_set_ambient_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	char			name[name_str_len];
	obj_type		*obj;
	
	if (!script_check_param_count(cx,func,argc,2,exception)) return(script_null_to_value(cx));
	
	obj=object_get_attach(j_obj);
	
	script_value_to_string(cx,argv[0],name,name_str_len);
	object_set_ambient(obj,name,script_value_to_float(cx,argv[1]));

	return(script_null_to_value(cx));
}
Example #19
0
JSBool js_model_halo_set_name(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp)
{
	char				name[name_str_len];
	model_draw			*draw;
	model_draw_halo		*halo;

	draw=js_find_model_draw(j_obj,TRUE);
	halo=&draw->halos[draw->script_halo_idx];

	script_value_to_string(*vp,name,name_str_len);
	halo->idx=halo_find(name);

	return(JS_TRUE);
}
Example #20
0
bool js_model_set_name(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef vp,JSValueRef *exception)
{
	model_draw		*draw;
	
	if (!script_in_construct(j_obj)) {
		*exception=script_create_exception(cx,"Can only set model name in the construct event");
		return(TRUE);
	}

	draw=script_find_model_draw(j_obj);
	script_value_to_string(cx,vp,draw->name,name_str_len);
	
	return(TRUE);
}
Example #21
0
JSValueRef js_map_object_find_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	char				name[name_str_len];
	obj_type			*obj;
	
	if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	
	script_value_to_string(cx,argv[0],name,name_str_len);
	
	obj=object_find_name(name);
	if (obj==NULL) return(script_int_to_value(cx,-1));

	return(script_int_to_value(cx,obj->idx));
}
Example #22
0
JSBool js_event_chain_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	char			chain_func_name[64];
	
	script_value_to_string(argv[1],chain_func_name,64);
	
	if (!timers_add(&js.attach,JSVAL_TO_INT(argv[0]),0,chain_func_name,timer_mode_chain)) {
		*rval=JSVAL_FALSE;
	}
    else {
		*rval=JSVAL_TRUE;
	}

    return(JS_TRUE);
}
Example #23
0
JSValueRef js_obj_chat_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	char			msg[max_view_chat_str_len];
	d3col			col;
	obj_type		*obj;
	
	if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	
	obj=object_get_attach(j_obj);
	script_value_to_string(cx,argv[0],msg,max_view_chat_str_len);
	
	if ((net_setup.mode!=net_mode_none) && (object_networkable(obj))) net_client_send_chat(obj,msg);
	object_get_tint(obj,&col);
	chat_add_message(obj,msg,&col);

	return(script_null_to_value(cx));
}
Example #24
0
JSBool js_event_send_message_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	int				msg_to,id;
	char			name[name_str_len];
	obj_type		*obj;

	msg_to=JSVAL_TO_INT(argv[0]);
	id=JSVAL_TO_INT(argv[2]);
	
	*rval=JSVAL_TRUE;
	
	switch (msg_to) {
	
		case sd_message_to_player:
			obj=object_find_uid(server.player_obj_uid);
			memmove(obj->attach.get_msg_data,js.attach.set_msg_data,(sizeof(attach_msg_type)*max_msg_data));
			scripts_post_event_console(&obj->attach,sd_event_message,sd_event_message_from_script,id);
			break;
	
		case sd_message_to_object:
			script_value_to_string(argv[1],name,name_str_len);
			obj=object_find_name(name);
			if (obj==NULL) {
				*rval=JSVAL_FALSE;
				break;
			}

			memmove(obj->attach.get_msg_data,js.attach.set_msg_data,(sizeof(attach_msg_type)*max_msg_data));
			scripts_post_event_console(&obj->attach,sd_event_message,sd_event_message_from_script,id);
			break;
			
		case sd_message_to_course:
			memmove(js.course_attach.get_msg_data,js.attach.set_msg_data,(sizeof(attach_msg_type)*max_msg_data));
			scripts_post_event_console(&js.course_attach,sd_event_message,sd_event_message_from_script,id);
			break;
		
		case sd_message_to_game:
			memmove(js.game_attach.get_msg_data,js.attach.set_msg_data,(sizeof(attach_msg_type)*max_msg_data));
			scripts_post_event_console(&js.game_attach,sd_event_message,sd_event_message_from_script,id);
			break;
	
	}

	return(JS_TRUE);
}
Example #25
0
JSValueRef js_event_chain_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	int				script_idx;
	char			chain_func_name[64],err_str[256];
	
	if (!script_check_param_count(cx,func,argc,2,exception)) return(script_null_to_value(cx));
	if (!script_check_fail_in_construct(cx,func,j_obj,exception)) return(script_null_to_value(cx));
	
	script_idx=(int)JSObjectGetPrivate(j_obj);
	script_value_to_string(cx,argv[1],chain_func_name,64);
	
	if (!timers_add(script_idx,script_value_to_int(cx,argv[0]),0,chain_func_name,timer_mode_chain,err_str)) {
		*exception=script_create_exception(cx,err_str);
		return(script_bool_to_value(cx,FALSE));
	}

	return(script_bool_to_value(cx,TRUE));
}
Example #26
0
JSValueRef js_weap_projectile_spawn_from_center_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	char					proj_name[name_str_len],err_str[256];
    obj_type				*obj;
	weapon_type				*weap;

	if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	
	obj=object_get_attach(j_obj);
	weap=weapon_get_attach(j_obj);

	script_value_to_string(cx,argv[0],proj_name,name_str_len);

	if (!weapon_script_projectile_spawn_center(obj,weap,proj_name,1,0.0f,NULL,err_str)) {
		*exception=script_create_exception(cx,err_str);
	}

	return(script_null_to_value(cx));
}
Example #27
0
JSBool js_event_send_message_to_object_by_name_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	char			name[name_str_len];
	obj_type		*obj;

	script_value_to_string(argv[0],name,name_str_len);
	obj=object_find_name(name);
	if (obj==NULL) {
		*rval=JSVAL_FALSE;
		return(JS_TRUE);
	}

	memmove(obj->attach.get_msg_data,js.attach.set_msg_data,(sizeof(attach_msg_type)*max_msg_data));
			
	scripts_post_event_console(&obj->attach,sd_event_message,sd_event_message_from_script,JSVAL_TO_INT(argv[1]));

	*rval=JSVAL_TRUE;

	return(JS_TRUE);
}
Example #28
0
JSBool js_event_set_message_data_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	int			idx;

		// get index

	idx=JSVAL_TO_INT(argv[0]);
	if ((idx<0) || (idx>=max_msg_data)) {
		JS_ReportError(js.cx,"Message data index out of bounds");
		return(JS_FALSE);
	}

		// set data

	if (JSVAL_IS_INT(argv[1])) {
		js.attach.set_msg_data[idx].type=d3_jsval_type_int;
		js.attach.set_msg_data[idx].data.d3_int=JSVAL_TO_INT(argv[1]);
		return(JS_TRUE);
	}
	
	if (JSVAL_IS_DOUBLE(argv[1])) {
		js.attach.set_msg_data[idx].type=d3_jsval_type_float;
		js.attach.set_msg_data[idx].data.d3_float=script_value_to_float(argv[1]);
		return(JS_TRUE);
	}
	
	if (JSVAL_IS_BOOLEAN(argv[1])) {
		js.attach.set_msg_data[idx].type=d3_jsval_type_boolean;
		js.attach.set_msg_data[idx].data.d3_boolean=JSVAL_TO_BOOLEAN(argv[1]);
		return(JS_TRUE);
	}
	
	js.attach.set_msg_data[idx].type=d3_jsval_type_string;
	script_value_to_string(argv[1],js.attach.set_msg_data[idx].data.d3_string,max_d3_jsval_str_len);	
    return(JS_TRUE);
}
Example #29
0
JSValueRef js_map_object_set_model_mesh_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	int					idx;
	char				name[name_str_len];
	obj_type			*obj;
	
	if (!script_check_param_count(cx,func,argc,3,exception)) return(script_null_to_value(cx));
	
	obj=script_find_obj_from_uid_arg(cx,argv[0],exception);
	if (obj==NULL) return(script_null_to_value(cx));
	
	script_value_to_string(cx,argv[1],name,name_str_len);
	idx=model_find_mesh_from_draw(&obj->draw,name);
	if (idx==-1) return(script_null_to_value(cx));

	if (script_value_to_bool(cx,argv[2])) {
		obj->draw.mesh_mask|=(0x1<<idx);
	}
	else {
		obj->draw.mesh_mask&=((0x1<<idx)^0xFF);
	}

	return(script_null_to_value(cx));
}
Example #30
0
JSBool js_event_call_game_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval)
{
	int				n,arg_count;
	char			func_name[64];
	jsval			args[20];

		// get arguments

	script_value_to_string(argv[0],func_name,64);

	arg_count=argc-1;
	if (arg_count<0) arg_count=0;
	if (arg_count>20) arg_count=20;

	for (n=0;n!=arg_count;n++) {
		args[n]=argv[n+1];
	}

		// call function

	if (!scripts_direct_call(&js.game_attach,func_name,arg_count,args,rval)) return(JS_FALSE);

	return(JS_TRUE);
}