Author Topic: Help with variable events  (Read 709 times)

I'm trying to make a brick that can't be clicked more than once. (It's a voting system, so it will have 2 bricks: one is yes, the other one is no).

Events:


I know that the error is on event 3 but i don't know how to get rid of it.
« Last Edit: January 16, 2012, 11:53:16 PM by Dante77 »

You made it so that every time you click it, it sets voted to 0

Try this:

Code: [Select]
onActivate > Client > VCE_ifVariable > voted == 1
onVariableTrue > Client > CenterPrint > You already voted
onVariableFalse > Client > VCE_modVariable > voted Set 1
onVariableFalse > etc.

since a variable always starts at 0 just put at the start of the events Onactivate client vceifvariable == 0 then all the onvariablefalse and true jazz then AFTER that put onactivate client vcemodvariable set 1

get rid of line 3, thats all you have to do

Line 3 causes the variable voted to rest whenever someone clicks on the brick, regardless if they have actually voted or not. So you don't need it.

Why didn't you use the Events Help topic?

Code: [Select]
OnActivate > Self > SetColor > Green
OnActivate > Client > ifVarible > voted = 1
OnVaribleTrue > Client > Centerprint > you cant vote more than once
OnVaribleFalse > namedbrick: ya1 > FireRelay
OnVaribleFalse > Client > modVarible > voted - set - 1
OnVaribleFalse > Client > CenterPrint > You have voted.