Help with wiremod!

So I am not that advanced in wiremod but Im not not bad either. And my question is now: How do the “While Loops” Work in WireMod E2? I tried them in normal Lua and they worked fine. I tried them in E2 but it always prints me to close the parenthisis and if it doesnt do that it always prints some other errors. Please help.

[Lua]
@name Alarm
@inputs Keypad Time Gate Button
@outputs Indicator Sound Repeat
@persist
@trigger

while(Button~=1){

if(Gate==1){
    Time=1
}

if(Time>0){
    Indicator=1
    Sound=1
    Repeat=1
} 

if(Keypad==1){
    Repeat=0
    Time=0
    Indicator=0
    Sound=0
}

}
[/Lua]

Button~=1 to Button!=1, also you need an interval(number) before the while loop

Thanks let me try

[editline]26th April 2016[/editline]

Tick quota … some error.
[Lua]
@name Alarm
@inputs A B C
@outputs D
@persist
@trigger

interval(10)

while(C != 1) {
if( A < B ) {
D = 1
}
}
[/Lua]

You shouldnt use while loop in an inverval() it causes overload


@name Alarm
@inputs A B C
@outputs D
@persist 
@trigger 

interval(10)

if (C!= 1){
    if( A < B ) {
        D = 1
    }
}

Same here. Tick quoate exceeded.

[Lua]
@name Alarm
@inputs Keypad Time Gate Button
@outputs Indicator Sound Repeat
@persist
@trigger

interval(10)

while(Button!=1){

if(Gate==1){
    Time=1
}

if(Time&gt;0){
    Indicator=1
    Sound=1
    Repeat=1
} 

if(Keypad==1){
    Repeat=0
    Time=0
    Indicator=0
    Sound=0
}

}
[/Lua]

[editline]26th April 2016[/editline]

But when may I use while loops? I dont get it.

intervaal() works like a whilie loop so if you use another while loop inside a while loop it causes error.

you can use while loop with RunOnSignal() RunOnKeys() etc.

You can use


if (Button!=1){}

While loop is not needed. Also, to prevent overload you can do something like


while (Button!=1&perf()){}

And why is this false just asking? Is there a way to make it with a while loop or just use instead 2 ifs?
Error: sv: Expression 2 (Alarm): tick quota exceeded
[Lua]
@name Alarm
@inputs Keypad Time Gate Button
@outputs Indicator Sound Repeat
@persist
@trigger

while(Button!=1){

if(Gate==1){
    Time=1
}

if(Time&gt;0){
    Indicator=1
    Sound=1
    Repeat=1
} 

if(Keypad==1){
    Repeat=0
    Time=0
    Indicator=0
    Sound=0
}

}
[/Lua]

[editline]26th April 2016[/editline]

Thanks iJohnny it works but my question is now. What does the &perf mean?

[editline]26th April 2016[/editline]

[Lua]&perf())[/Lua]

You can find explanation in E2Helper. There is the button in E2Editor

RunOnTick(<integer here>) ??