some script question

Gurtag

Active member
hey guys, have been using some script i found around and whant to ask a few questions.

how can i turn this one in to a function?
Code:
@script
void self = getlocalvar("self");
if(frame==0)
{
  changeentityproperty(self, "lifespancountdown", 39);
}
@end_scrip

got this one from ilu´s AUBF game, is there a way to make this move script to afect the wole anim instead of having to declare it on every frame? i mean make it work like the move command so to speak

Code:
void mover(int dx, int dz,int da)
{ // Moves entity freely and ignores obstacles
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x"); //Get character's x coordinate
    int z = getentityproperty(self,"z"); //Get character's z coordinate
    int a = getentityproperty(self,"a"); //Get character's a coordinate
    int dir = getentityproperty(self,"direction"); //Get character's facing direction

     if(dir==0){ // Facing left?
      changeentityproperty(self, "position", x-dx, z+dz, a+da); //Move
     }
     else if(dir==1){ // Facing right?
      changeentityproperty(self, "position", x+dx, z+dz, a+da); //Move
     }
}
 
It's kinda funny to see that the answer of each question lies in the other question  ;D.

1st, to create function version, you need to create function and place all script lines there excluding frame check. Then decide if any of values you set can be modified with parameter.
My suggestion is this:
Code:
void Lifespan(int Value){
    void self = getlocalvar("self");

    changeentityproperty(self, "lifespancountdown", Value);
}

2nd, @script ... @end_script will run any function declared in it on every single frame on respective animation.
Therefore if you have function which should run on every single frame, you should declare it like this:
Code:
@script
 mover(dx, dz, da);
@end_script

Replace dx, dz and da with values of course.
 
thanks a lot for the help man, works like charm, btw does the move script can be override later on the animation with for example:

@script
mover(0, 0, 0);
@end_script

i tryed but no luck.
 
If you want to use it like move command, it's better to specify at which frames you want mover function to be run.
Such as:
Code:
@script
  if(frame<6){
   mover(2, 0, 0);
  }
@end_script

This will only run mover function from 1st frame to 6th frame.
 
Back
Top Bottom