How to initialize a variable

#1
need help on variable

Hello,

Is it possible to initialize a variable but only one time (at the beginning) ?
I'am making an animated train which follow a path and i would like it to move backward (along the path) when it reach the end. So a made 2 animations (forward animation and backward animation) and i used an user variable to change the train move, using this code :

SETWRD 0312h,1

;0=A->B / 1=B->A
IFIN1 lbl_BtoA, 0312h, 0, 0
BGL_JUMP_32 lbl_AtoB

lbl_BtoA label word
BGL_ANIMATE VAR_BASE_GLOBAL,usrvr2,VAR_BASE_LOCAL,(offset SD_train_trans_back - offset SD_train_pvan_1),0.0,0.0,0.0
BGL_ANIMATE VAR_BASE_GLOBAL,usrvr2,VAR_BASE_LOCAL,(offset SD_train_quat_back - offset SD_train_pvan_1),0.000000,0.000000,0.000000
SETWRD 0312h,0
BGL_JUMP_32 lbl_fin

lbl_AtoB label word
BGL_ANIMATE VAR_BASE_GLOBAL,usrvr2,VAR_BASE_LOCAL,(offset SD_train_trans_1 - offset SD_train_pvan_1),0.0,0.0,0.0
BGL_ANIMATE VAR_BASE_GLOBAL,usrvr2,VAR_BASE_LOCAL,(offset SD_train_quat_1 - offset SD_train_pvan_1),0.000000,0.000000,0.000000
SETWRD 0312h,1
BGL_JUMP_32 lbl_fin

lbl_fin label word

but the train always do the same animation because the SETWRD 0312h,1 command (at the beginning) is repeating each time. So is there a way to do this command only one time, just to set the first train animation ?

Thanks
 
Last edited:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#2
Hi,

Sorry for the late reply, I did miss your post before now.

Did you read my tutorial about making frequency controlled animations? I think you should be able to use a similar trigger.

For this example code, have you tried it without the first SETWRD command? Without that command the value is 0 initially. Once a certain animation has been run it can be set to another value like you already do now. So I think without that line your animation should also work.
 
Top