Interval is pretty much a "tick".
It just re-reads the code after XX milliseconds. (For instance; "interval(1000)" is just like saying, "Re-read the code every 1 second [1000 milliseconds = 1 second])
Hi,
First of all, know that English is not my mother tongue, so I do my best 4 you xD.
I play with wiremod since a long time ago. At the beginning, I thought "ouch... it's difficult this mod", but now, I use expression 2 easy.
But I've never understand how to use (and when to use it) the interval(XXX) command...
I'll take an example of the expression of Masogir, which is (I don't know for what this expression is, but for the exemple, it's good) :
what will this intervall do ?Code:@name Maso's Turret @inputs A:entity Range @outputs Pitch Yaw Roll Fire NextTarg @persist Elev Bear R interval(10) Target = A:pos()+vec(0,0,A:height()/2) Elev = entity():elevation(Target) Bear = entity():bearing(Target) R = entity():angles():roll() Pitch = Elev*2 + $Elev*10 Yaw = Bear*2 + $Bear*10 Roll = R*2 + $R*10 Fire = (A&Range) NextTarg = !NextTarg*(A:health() <= 0)
If i've well understand, the program will read the code from the top to the bottom, and when it's finish, it'll start again but wait 10 miliseconds ?
please, I want to understand how to use that..... Thanks for your help, and sorry for my bad English xD
Last edited by Azrael; 12-28-2008 at 10:21 AM.
Interval is pretty much a "tick".
It just re-reads the code after XX milliseconds. (For instance; "interval(1000)" is just like saying, "Re-read the code every 1 second [1000 milliseconds = 1 second])
I just want to add to IEF015, interval(X) indeed reads (executes) the code once, after X milliseconds. But, remember that changes in inputs still cause the code to execute, so interval(1000), doesn't mean that the code executes once every second. It means that it executes once every second + the number of the changed inputs.
To for instance avoid inputs screwing things up, you can use "clk()", if you do if(clk()) { ... }, "..." will only be executed once every second, regardless of inputs.
Interval and timer are the same thing, the only difference being that interval() is to make things simpler, so it would be the same as timer("mytimer", X), clk("mytimer").
(Note: interval() only causes ONE execution, in order for it to cause further executions, e.g. at a specific interval, it needs to be executed every time the gate is run (or when the clk()-function returns 1).
EDIT: Feel free to ask if it's still unclear, we know this is quite problematic functionality for some.
ok, I think I've understant, I'll try this later to see if I'm ok with interval xD, thanks for your help, if I've any problem, I'll ask you here.....
I've a problem :
I want to make that a red light blink while a hydraulic is mauving.... simple thing no ?
so that's my code :
PHP Code:@name Alarm Light
@inputs Trigger
@outputs Red
@persist C
if(Trigger > 10 & Trigger < 100)
{
interval(500)
C = C+1
if(C == 1 & clk()) { Red = 255}
if(C== 2 & clk()) { Red = 0, C = 0}
}
if(Trigger == 10 | Trigger == 100) {Red = 0}
so I link the button (on = 100, off = 10) to a timer (smooter) with a rate of 50. I link input trigger to the smoother, the input red of the light to the output red of the expression, ant it doesn't work. BUT, if I link the input trigger to a constant value (>10 value <100), so for example 50, it works fine... so what I made wrong ?
EDIT : thanks to try to understand me, and to try to help me....
Last edited by anthraxyhe; 12-28-2008 at 04:34 AM.
so someone has an idea to help me ?
EDIT : oh sorry, I forgot the time difference between our 2 countries
Last edited by anthraxyhe; 12-28-2008 at 05:39 AM.
For my blinking lights I use
This will make the light toggle on or off every .5 seconds.Code:interval(500) if (On) {Red = -Red +255} else {Red=0}
I want to understand why my Egate don't work.... don't want to know how I could do...
I'm not sure what your script is doing exactly.
But, one thing I can note in your expression is that, it will ONLY be executed more times, if (Trigger > 10 & Trigger < 100), otherwise it won't.
(Do note that, neither 10 or 100 (but value of the button), is 100 > x > 10 ... you have to use >= in order for that.)
This is another way of doing what you are doing btw:
Code:@name Alarm Light @inputs Trigger @outputs Red @persist C if(Trigger > 10 & Trigger < 100) { interval(500) C = !C if(clk() & C) { Red = 255 } if(clk() & !C) { Red = 0 } } else { Red = 0 }
Bookmarks