BVE WorldWide
Would you like to react to this message? Create an account in a few clicks or log in to continue.

How to set the keyboard key for turn on/off lamp in statefunction formula ?

2 posters

Go down

How to set the keyboard key for turn on/off lamp in statefunction formula ? Empty How to set the keyboard key for turn on/off lamp in statefunction formula ?

Post by ADbve Thu Mar 31, 2022 3:36 pm

Hello

I wanna know how to set the keyboard key to statefunction formula as toggle to switch between object states?

I want to make a lamp that can turn on and off by clicking those key, if i remember openbve had separate command in controls menu to turn on/off headlight and turn on/off rearlight that has been assigned to some keyboard key that i forgot what keyboard key it assigned😅.

I have write like this.

[Object]
Position = 0, 0, 10
States = headlampOFF.b3d, headlampON.b3d
Statesfunction = ........


So how to write and assigned it when that key pressed it change the object ?

ADbve

Posts : 72
Join date : 2020-05-14

Back to top Go down

How to set the keyboard key for turn on/off lamp in statefunction formula ? Empty Re: How to set the keyboard key for turn on/off lamp in statefunction formula ?

Post by SP1900 Sun Apr 24, 2022 4:13 pm

Many trains I have seen have reverser-controlled lights, meaning that they are controlled by what direction that the reverser is set. There are some trains which use pluginstates to operate the lights. 

Here is an extract of code from a train I have seen. This piece of code controls the on and off states of a set of tail lights. They are left on by default and you can press the button to turn them off and press again to turn them on again. The pluginstates used I suppose are determined by the plugin that you use. I am not an expert with animated coding so I am not 100% sure how it works but I hope it can be helpful

[Object]
States = lights\Class465_Taillights_1.csv
Position = 0, 0, -1.465
StateFunction = if[pluginstate[31] == 1, pluginstate[21] - 1, -1]
SP1900
SP1900

Posts : 302
Join date : 2017-12-08
Age : 22

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum