|
Action attached to sprite in WED stopped working
#440359
04/24/14 12:39
04/24/14 12:39
|
tolu619
Unregistered
|
tolu619
Unregistered
|
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.
Last edited by rayp; 04/25/14 09:22. Reason: merged posts
|
|
|
Re: Action attached to sprite in WED stopped working
[Re: rayp]
#440412
04/25/14 10:28
04/25/14 10:28
|
tolu619
Unregistered
|
tolu619
Unregistered
|
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:
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;
}
Last edited by tolu619; 04/25/14 10:29. Reason: added code tags
|
|
|
Re: Action attached to sprite in WED stopped working
[Re: jcl]
#440447
04/25/14 16:35
04/25/14 16:35
|
tolu619
Unregistered
|
tolu619
Unregistered
|
OK, here's my entire project folder. https://www.dropbox.com/sh/6979kmt9rstkk46/4Xl2o8udfSRun 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.
|
|
|
Re: Action attached to sprite in WED stopped working
[Re: jcl]
#440593
04/28/14 14:37
04/28/14 14:37
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
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.
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;
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
|