Action attached to sprite in WED stopped working

Posted By: Anonymous

Action attached to sprite in WED stopped working - 04/24/14 12:39

I'm frustrated right now because an action I attached to some sprites in WED which were working perfectly before suddenly stopped working. I put a "printf" command at the beginning of the action just to test whether or not the action was running at all and I don't get any message (from the printf code) when the script starts running. Other actions in the same script (attached to models) are working perfectly. Its not about a syntax error in the code. For some reason, the code just seems unreachable to the engine, even though it was running perfectly before.

PLEASE! I've tried shortening the names of the actions and functions since I know the free edition of gamestudio places limitations on name lengths but nothing seems to work. I can attach the actions to the sprites in WED but once I start the game, the thing acts like there's no action attached to it at all.
Posted By: rayp

Re: Action attached to sprite in WED stopped working - 04/25/14 09:23

Instead making double posts, maybe u should provide the code you add to the sprite ?

Action names are limited to 18 chars, if iam right btw.
Posted By: Anonymous

Re: Action attached to sprite in WED stopped working - 04/25/14 10:28

While I have no problems with posting the code here, I'm convinced that this a bug and I think it needs to be looked into. I have 2 reasons for this conclusion. First, the code was working perfectly before then it suddenly stopped working without any adjustments being made to it. Secondly, I created another action in the same script and randomly named it "twirl". All it did was rotate the sprite attached to it. It worked. So I slowly added the code of the action that wasn't working, line by line, to the new action called Twirl. Every time I ran it, it worked. Eventually, the exact same code that didn't work in the other action worked in Twirl. Just for arguments purpose, I swapped the names of the 2 actions and now, the former code worked because it was named Twirl. Very annoying that I lost almost 2 days to this. Here's the code:

Code:
action Twirl()
{
	while(!player){wait(1);}
	my.skill50 = 1199; //I'm a jump target
	JumpTargetID++;
	my.skill51 = JumpTargetID;
	set(my, PASSABLE); 
	set(my, INVISIBLE);	
	my.emask |= (ENABLE_SCAN); //sensitive to c_scan	
	my.event = WasScanned;
	while(1)
	{
		//my.pan += 10*time_step;
		my.roll += 10*time_step;
		//my.tilt += 10*time_step;
		wait(1);
	}
}

action JumpTarget()
{
	while(!player){wait(1);}
	my.skill50 = 1199; //I'm a jump target
	JumpTargetID++;
	my.skill51 = JumpTargetID;
	while(1){my.roll+=1*time_step; wait(1);}

//	set(my, BRIGHT);
//	my.red = 255;
//	my.blue = 255;
//	my.green = 255;
//	my.lightrange = 10000;
	
	set(my, PASSABLE); 
	set(my, INVISIBLE);	
	my.emask |= (ENABLE_SCAN); //sensitive to c_scan	
	my.event = WasScanned;
}

Posted By: Superku

Re: Action attached to sprite in WED stopped working - 04/25/14 11:55

You will need to provide an example/ test project, otherwise this probably won't be reconstructable or fixable.
Posted By: jcl

Re: Action attached to sprite in WED stopped working - 04/25/14 12:04

If an action suddenly stops working, the most likely place to look for the bug is the part that you changed after it worked the last time. A wrong name length is not a likely reason unless you get an error message about it.

From your script snippet I cannot tell you where the bug is - but under "troubleshooting" in the manual there are many hints how to find and fix bugs.
Posted By: Anonymous

Re: Action attached to sprite in WED stopped working - 04/25/14 16:35

OK, here's my entire project folder. https://www.dropbox.com/sh/6979kmt9rstkk46/4Xl2o8udfS
Run the script called "Project Monkey", select the fox as your character, then select the level in the middle (dodge dash training ground) and as your level. The twirl code should run on the sprites it is attached to while the JumpTarget code won't run. At least that's what happens here.
Posted By: jcl

Re: Action attached to sprite in WED stopped working - 04/28/14 14:05

Hmm, although I'm here to help users with their projects, this folder is a little too big for my taste (and for my time). Can you do the first steps? Strip the game down, step by step, until you end up with a minimal script that only contains the very elements you have problems with. You will most likely find the bug this way. But if the action then still does not run, please post here and I'll help.
Posted By: Superku

Re: Action attached to sprite in WED stopped working - 04/28/14 14:37

It may help you to implement some sort of level protocol function. A few weeks ago I did something similar - you can see the function below - but there may be some bugs (in engine_gettaskinfo(), the protocol function or my game) because it sometimes leads to errors. You can however use it as a basis for your own project and if you remove the first while(e_res) loop there won't be errors.

Click to reveal..
Code:
void level_protocol()
{
	var p_file,e_count = 0,e_res = 1;
	STRING* str_tmp;
	char* funcname;
	ENTITY* ent;
	
	sys_marker("LP1");
	str_tmp = str_create("");
	str_cpy(str_tmp,level_name);
	str_trunc(str_tmp,4);
	if(key_l) str_cat(str_tmp,"_protocol_forced.txt");
	else str_cat(str_tmp,"_protocol.txt");
	p_file = file_open_write(str_tmp);
	if(!p_file)
	{
		error("level_protocol: could not open file!");
		return;
	}
	
	sys_marker("LP2");
	file_str_write(p_file,"Functions:");
	while(e_res)
	{
		sys_marker("L2A");
		if(!engine_gettaskinfo(e_count,&funcname,&ent)) break;
		sys_marker("L2B");
		file_str_write(p_file,"\nFunction: ");
		file_var_write(p_file,e_count);
		file_str_write(p_file,"\n-name: ");
		sys_marker("L2C");
		if(funcname) file_str_write(p_file,funcname);
		sys_marker("L2D");
		file_str_write(p_file,"\n-me entity: ");
		if(ent) file_var_write(p_file,ent->link.index);
		e_count++;
	}
	sys_marker("LP3");
	file_str_write(p_file,"\nEntities:");
	e_count = 0;
	for(you = ent_next(NULL); you; you = ent_next(you))
	{
		e_count++;
		file_str_write(p_file,"\nEntity: ");
		file_var_write(p_file,e_count);
		file_str_write(p_file,"\n-filename: ");
		str_for_entfile(str_tmp,you);
		file_str_write(p_file,str_tmp);
		file_str_write(p_file,"\n-link id: ");
		file_var_write(p_file,you->link.index);
		file_str_write(p_file,"\n-link name: ");
		if(you->link.name) file_str_write(p_file,you->link.name);
		file_str_write(p_file,str_printf(NULL,"\n-pos: (%d,%d,%d)",(int)your.x,(int)your.y,(int)your.z));
		file_str_write(p_file,str_printf(NULL,"\n-pan: (%d,%d,%d)",(int)your.pan,(int)your.tilt,(int)your.roll));
		file_str_write(p_file,str_printf(NULL,"\n-scale: (%d,%d,%d)",(int)your.scale_x,(int)your.scale_y,(int)your.scale_z));
		file_str_write(p_file,str_printf(NULL,"\n-flags: (%d,%d,%d)",(int)your.eflags,(int)your.flags2,(int)your.emask));
	}
	sys_marker("LP4");
	file_str_write(p_file,"\nEntities in total: ");
	file_var_write(p_file,e_count);
	file_str_write(p_file,"\nLoading errors: ");
	file_var_write(p_file,last_error);
	file_close(p_file);
	sys_marker(NULL);
	ptr_remove(str_tmp);
}
...
on_l = level_protocol;
on_level_load = level_protocol;

© 2024 lite-C Forums