+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Want to understand "interval" and "timer" in Expression 2

  1. #1
    Wire Noob anthraxyhe's Avatar
    Join Date
    Dec 2008
    Posts
    18

    Talking Want to understand "interval" and "timer" in Expression 2

    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) :
    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)
    what will this intervall do ?

    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.

  2. #2
    Wire Sofaking IEF015's Avatar
    Join Date
    Feb 2008
    Location
    London, ON (Canada, eh?)
    Posts
    1,640

    Default Re: Want to understand "interval" and "timer" in Expression 2

    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])
    "It's my favourite country song. And I hate it."

  3. #3
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default Re: Want to understand "interval" and "timer" in Expression 2

    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.

  4. #4
    Wire Noob anthraxyhe's Avatar
    Join Date
    Dec 2008
    Posts
    18

    Default Re: Want to understand "interval" and "timer" in Expression 2

    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.....

  5. #5
    Not a bot itsbth's Avatar
    Join Date
    Feb 2007
    Location
    Norway
    Posts
    1,173

    Default Re: Want to understand "interval" and "timer" in Expression 2

    Quote Originally Posted by anthraxyhe View Post
    First of all, know that English is not my mother tongue, so I do my best 4 you xD.
    Try harder!
    Last edited by itsbth; 12-28-2008 at 06:49 AM. Reason: Made my point even more clear.

  6. #6
    Wire Noob anthraxyhe's Avatar
    Join Date
    Dec 2008
    Posts
    18

    Default Re: Want to understand "interval" and "timer" in Expression 2

    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+1
    if(== clk()) { Red 255}
    if(
    C== clk()) { Red 00}
    }

    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.

  7. #7
    Wire Noob anthraxyhe's Avatar
    Join Date
    Dec 2008
    Posts
    18

    Default Re: Want to understand "interval" and "timer" in Expression 2

    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.

  8. #8
    Wirererer Hunter234564's Avatar
    Join Date
    Apr 2008
    Location
    Holland
    Posts
    225

    Default Re: Want to understand "interval" and "timer" in Expression 2

    For my blinking lights I use

    Code:
    interval(500)
    if (On) {Red = -Red +255} else {Red=0}
    This will make the light toggle on or off every .5 seconds.

  9. #9
    Wire Noob anthraxyhe's Avatar
    Join Date
    Dec 2008
    Posts
    18

    Default Re: Want to understand "interval" and "timer" in Expression 2

    I want to understand why my Egate don't work.... don't want to know how I could do...

  10. #10
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default Re: Want to understand "interval" and "timer" in Expression 2

    Quote Originally Posted by anthraxyhe View Post
    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+1
    if(== clk()) { Red 255}
    if(
    C== clk()) { Red 00}
    }
     
    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....
    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
    }

+ Reply to Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. Xtensity's "Spaceman Turret V6" Tutorial, "Head Shots FTW"
    By Xtensity in forum Gate Nostalgia (Old School Wiring) Discussion & Help
    Replies: 24
    Last Post: 09-20-2008, 08:46 AM
  2. expression gate "undo" bugfix (temporary)
    By Pyro-Fire in forum Wiremod General Chat
    Replies: 8
    Last Post: 08-31-2008, 10:20 PM
  3. "Smarter" Expression Gate
    By jakobolle in forum Ideas & Suggestions
    Replies: 3
    Last Post: 08-02-2007, 09:38 AM
  4. Need the pack that has the "Generator" and "Razor" models...
    By Mr. Brightside in forum Installation and Malfunctions Support
    Replies: 2
    Last Post: 06-06-2007, 11:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots