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

openBVE plugin blinking lights problem

2 posters

Go down

openBVE plugin blinking lights problem Empty openBVE plugin blinking lights problem

Post by LXQt Fri Jul 19, 2019 6:00 am

So recently I am trying to create a blinking light with plugins(which once you press a button,it will start blinking) but I have an problem, since the blinking light is blinking quite fast,if a user pressed the button when the lights are on,it will stay on. But I want no matter if the blinking lights state is on or off, it will still go off when user pressed the button,is there anyways to do so?(I've tried using currentState,but it end up crashing object viewers and openBVE)
Btw here's my code:

[Object]
States = DirectionLightoff.csv, DirectionLighton.csv
Position = -2.75,0,0.1
Statefunction = Mod[value + pluginstate[105], 2] 
RefreshRate = 0.55

The code I tried but crashed:

[Object]
States = DirectionLightoff.csv, DirectionLighton.csv
Position = -2.75,0,0.1
Statefunction = if[currentState==1 & pluginstate[105],0,1]
RefreshRate = 0.55
LXQt
LXQt

Posts : 114
Join date : 2019-02-18
Location : Hong Kong

https://lx862.com

Back to top Go down

openBVE plugin blinking lights problem Empty Re: openBVE plugin blinking lights problem

Post by leezer3 Fri Jul 19, 2019 4:49 pm

Interesting, you seem to have hit a somewhat long-standing problem- CurrentObjectState was a little broken (Dates back to Michelle!).

This function should now work as intended.

However, your second set of code isn't the way to go- It'll never actually get as far as changing state.

Probably easiest to do the following:
Code:
[Object]
States = DirectionLightoff.csv, DirectionLighton.csv
Position = -2.75,0,0.1
Statefunction = if[pluginstate[105] == 1, Mod[value + pluginstate[105], 2] ,0]
RefreshRate = 0.55

Note the added conditional, so that if pluginState[105] is not 1, it will always return 0 Smile

leezer3

Posts : 1978
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Back to top

- Similar topics

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