+ Reply to Thread
Results 1 to 10 of 10

Thread: Choose Value?

  1. #1
    Wire Noob Wurmy1029's Avatar
    Join Date
    Aug 2007
    Location
    Somewhere
    Posts
    3

    Default

    Ok well hello thar. I just got a question for you wire gods ;3

    Basically what I have is 2 values (lets say 2 and 3)
    What I want is for both of those values to go into some chip or something.
    The output of the chip would be constantly changing from 2 to 3, at a certain rate.

    So is there a way to do this? Hope you understand what I want << Also the two variables that go in will be constantly changing..

    So anybody know? Is this possible? :/
    Any help is appreciated :D

  2. #2
    Wire Sofaking Shandolum's Avatar
    Join Date
    Apr 2007
    Location
    Europe -> Denmark
    Posts
    887

    Default

    You could use an expression chip.
    Code:
    I@Value1 Value2
    O@NewValue
    interval(1000)
    Change=(Change?0:1)
    NewValue=(Change?Value1:Value2)
    You can modify the interval as you please. 1000 is equal to 1 second, 250 is equal 0.25 seconds, get the drift.
    This is the time between it runs the expression.
    Everything can be improved upon. Nothing is Perfect.
    The only way to move forward, is to surpass what has already been done.
    Creator of many things.

  3. #3
    Wire Noob Wurmy1029's Avatar
    Join Date
    Aug 2007
    Location
    Somewhere
    Posts
    3

    Default

    Ooh Thank you very much :D

    EDIT:
    I got it to work... but I can&#39;t get it to work with 3 or more values.. could you explain how to do that?

  4. #4
    Wirererer uoykcuf's Avatar
    Join Date
    Jul 2007
    Posts
    279

    Default

    Ooh Thank you very much

    EDIT:
    I got it to work... but I can&#39;t get it to work with 3 or more values.. could you explain how to do that?[/b]
    You could do that like this, but since i dont know how to use the internal timer youll have to add a external timer

    Code:
    N@Value Changer
    I@Value1 Value2 Value3 Timer
    O@Value Reset
    Reset = Timer >= 3
    TimerInt = ceil(timer)
    TimerInt == 1 -> Value = Value1;
    TimerInt == 2 -> Value = Value2;
    TimerInt == 3 -> Value = Value3;

    Damnnn... i love e-gate
    Creator of this Ram controller



    Click here if u experience wiremod error Problems

    92% of teens have moved onto rap. If you are part of the 8% that still listen to real music, copy and paste this into your signature.

    98% of teens smoke, or have smoked before in their life. If you are part of the 2% that hasn&#39;t/doesn&#39;t, copy this into your sig.

    It ain&#39;t broken, it just lacks ducktape

  5. #5
    Wire Sofaking Shandolum's Avatar
    Join Date
    Apr 2007
    Location
    Europe -> Denmark
    Posts
    887

    Default

    You could do that like this, but since i dont know how to use the internal timer youll have to add a external timer

    Code:
    N@Value Changer
    I@Value1 Value2 Value3 Timer
    O@Value Reset
    Reset = Timer >= 3
    TimerInt = ceil(timer)
    TimerInt == 1 -> Value = Value1;
    TimerInt == 2 -> Value = Value2;
    TimerInt == 3 -> Value = Value3;
    Damnnn... i love e-gate [/b]
    But you need a seperate timer chip for that thing
    here is another way to do it
    Code:
    I@Value1 Value2 Value3 ..........
    O@NewValue
    interval(1000)
    Number+=1
    Number>2 ->Number=0** # 2 is the number of values you have minus 1. "3-1=2"
    NewValue=sel(Number,Value1,Value2,Value3,.........)
    Replace ......... with Value 4,5,6,7 or whatever.
    Each time the code is triggered, the Number will be 1 bigger, if it is higher than a certain number, it will be reverted to 0, the code then selects the desired value based on the number. Interval can still be changed.
    Everything can be improved upon. Nothing is Perfect.
    The only way to move forward, is to surpass what has already been done.
    Creator of many things.

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

    Default

    You could do that like this, but since i dont know how to use the internal timer youll have to add a external timer

    Code:
    N@Value Changer
    I@Value1 Value2 Value3 Timer
    O@Value Reset
    Reset = Timer >= 3
    TimerInt = ceil(timer)
    TimerInt == 1 -> Value = Value1;
    TimerInt == 2 -> Value = Value2;
    TimerInt == 3 -> Value = Value3;
    Damnnn... i love e-gate [/b]
    Code:
    N@Value Changer
    I@Value1 Value2 Value3
    O@Value Reset
    interval(1000)
    clk() -> TimerInt = (TimerInt + 1) % 3;
    TimerInt == 0 -> Value = Value1;
    TimerInt == 1 -> Value = Value2;
    TimerInt == 2 -> Value = Value3;
    That&#39;s how you do it using the internal timer (changed code slightly to make it simpler)

  7. #7
    Wire Sofaking Shandolum's Avatar
    Join Date
    Apr 2007
    Location
    Europe -> Denmark
    Posts
    887

    Default

    Code:
    N@Value Changer
    I@Value1 Value2 Value3
    O@Value Reset
    interval(1000)
    clk() -> TimerInt = (TimerInt + 1) % 3;
    TimerInt == 0 -> Value = Value1;
    TimerInt == 1 -> Value = Value2;
    TimerInt == 2 -> Value = Value3;
    That&#39;s how you do it using the internal timer (changed code slightly to make it simpler)[/b]
    What exactly is the "% 3" doing? or did i miss something while going through the documentation.
    Everything can be improved upon. Nothing is Perfect.
    The only way to move forward, is to surpass what has already been done.
    Creator of many things.

  8. #8
    Wire Amateur Psawhn's Avatar
    Join Date
    Aug 2007
    Posts
    34

    Default

    Nah, it&#39;s just the modulus operator.

    Actually, looking at that - that&#39;s a really nifty way of automatically resetting the timer. I would have just let the timer go up to infinity and used the mod for the states. Of course, cleaner code wins.
    x* x+ 17 = 0
    When keeping it real goes wrong.

  9. #9
    Wire Noob Wurmy1029's Avatar
    Join Date
    Aug 2007
    Location
    Somewhere
    Posts
    3

    Default

    OOh thank you very much xD
    I&#39;m kinda new to expression chips

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

    Default

    What exactly is the "% 3" doing? or did i miss something while going through the documentation.[/b]
    Just like the above said, the modulo operator. Also known as "remainder after division".
    In practice it basically means that when X >= 3 then substract 3 until the value is less than 3 again, hence the value will loop 0-1-2-0-1-...

    Nah, it&#39;s just the modulus operator.

    Actually, looking at that - that&#39;s a really nifty way of automatically resetting the timer. I would have just let the timer go up to infinity and used the mod for the states. Of course, cleaner code wins. [/b]
    Not that it really matters, but you have to remember that precision is lost when values are too high, if you simply connect it to a timer it doesn&#39;t really matter, but if you have something that increase really really fast, if you do not reset it it will eventually start to loose precision and either it will stop counting up or give irregular values. But you&#39;ll only see it happen in very rare cases.

+ Reply to Thread

Similar Threads

  1. Making a gamemode, how to choose teams?
    By Asphid in forum Wiremod Addons & Coding
    Replies: 7
    Last Post: 01-28-2009, 11:46 PM
  2. Abilty To Choose Numpad I/O Models
    By Jack in forum Ideas & Suggestions
    Replies: 7
    Last Post: 03-26-2008, 08:52 AM
  3. Ability To Choose How Many Outputs
    By Jack in forum Ideas & Suggestions
    Replies: 2
    Last Post: 03-24-2008, 06:41 PM

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