IrrAdventure - Part 4 - Use of the variables

Back to the index

Creation of variables

Now you surely want to make more complicated mechanisms. For that, you must create variables. Add between the "variables" markers :

<variable camembert="5" />
<variable emmental="5" />

Now, add between the markers of the mechanism created in the previous part:

<consequenceSetVar variable="camembert" newValue="10" />
<consequenceIncrVar variable="emmental" incrementation="-1" />

Test

Launch the game. Press on A key. You must see appear (several times) something like :

###### Beginning of mechanisms
(-0.948778 -0.218659 -0.228055 0.050000)->(camembert=10.000000)(camembert+=1.000000)
###### End of mechanisms
######Beginning of settings contents :
windowSizeX 640.000000
windowSizeY 480.000000
isFullscreen 0.000000
displayBits 32.000000
driverType 2.000000
isRelease 0.000000
camembert 5.000000
emmental 5.000000
######End of Settings contents

Now click on the mechanism.

--click on mechanism 0(camembert=10.000000)(emmental=4.000000)(sound=0) and goto node 45--

Press again on A key : as expected, the camembert value passed to 10, that of emmental was incremented of -1. The mechanism modified the the variables values.

Note: the variables can be float variables.

Go to part 5