Using ent_animate ... but how ?

Posted By: BBN

Using ent_animate ... but how ? - 07/27/14 21:09

What's wrong with this code:
Code:
action ent001()
{
my.skill1 = 0;
while(my.skill1 < 100)
{
ent_frame("death", my.skill1);
my.skill1 += 1;
}
wait(1);
}
}


Gets the error message:

> UNDECLARED IDENTIFIER <

?



Posted By: Superku

Re: Error message ... - 07/27/14 21:18

Doesn't the error message say which function the UNDECLARED IDENTIFIER is? It should and I bet it says "ent_frame". Replace it with ent_animate (and pay attention to the different function arguments).
Posted By: BBN

Re: Error message ... - 07/27/14 21:37

Change the code to:
Code:
var animation;

action ent001
{
animation = 0;
while(animation < 100) {ent_animate("death",animation); animation+=1; wait(1) ; }
}


It is now another error message:

Error in line 16 ...

That is > animation = 0; <

?
Posted By: Ch40zzC0d3r

Re: Error message ... - 07/27/14 22:24

action ent001()
You forgot the brackets.
Also why not declare animation locally?
Posted By: DLively

Re: Error message ... - 07/28/14 03:02

Code:
ent_animate("death",animation);



You are missing a couple parameters wink

Code:
ent_animate(me,"death",animation, ANM_CYCLE);



Also, as Ch40zzC0d3r said: You can make your var local, by which he means placing it inside the action. Then several entities can use this action, and will not follow the same var amount.
Posted By: rayp

Re: Error message ... - 11/03/14 21:59

Quote:
ent_frame
Mhhh ... old ( and dead ) "C - Script" i guess.
Instead of asking such questions, a look into the manual, would help alot and is done in a few seconds.

Besides the already mentioned missing parameters, you scripted an oneshot animation ( plays animation only one time, after that it does nothing more ).
Also u missed "speed correction" via time_step. This means, animation plays slowly on old ( slow ) computers but fast on new ( fast ) machines. Using "+1" here instead of "+time_step*X" is ( in almost all cases ) a deadly ( and extremly ugly ) mistake.

This code here combines both, oneshot- and cycle- animationstyles, time corrected with time_step:
Code:
//flag1 OneShotAnm 0
action ENTanm_WED(){ // FLAG1 = checked in WED-prop-window: marked as oneshot animation
   while (my){
      my.skill1 += time_step;    // framerate independent 
      my.skill1 %= 100;          // skill1 range 0..100 [if(my.skill1>=100)my.skill1=0;]
      if (!is (my, FLAG1)) ent_animate (me, "idle", my.skill1, ANM_CYCLE);
      else{                      // oneshot: plays animation only one time
         ent_animate (me, "idle", my.skill1, NULL);
         if (my.skill1 >= 100) break;
      }
      wait (1);
   }
   wait (1);                     // btw always(!!!) wait single frame be4u remove ent's  
   ptr_remove (me);              // btw#2 dont(!!!) use in ent / particle - event's
}


Peace
© 2024 lite-C Forums