• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

How to initialize a variable

Messages
5
Country
france
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:
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.
 
Thanks Arno,

but i found an other solution with GMax only and several keys to simulate the train stop then move backward.
 
Back
Top