+ Reply to Thread
Results 1 to 9 of 9

Thread: A countdown

  1. #1
    Inactive Lieutent Slappy Moose is on a distinguished road Lieutent Slappy Moose's Avatar
    Join Date
    Jun 2008
    Location
    In a box on the moon
    Posts
    44

    Default A countdown

    I am making a trebuchet which is almost fully automated. I am using a series of winches to swing the arm, but I am using an expression and a timer to trigger everything.

    How can I make it so for "X" seconds, the winches pull at a rate of "Y?"

    Can I do this in the expression, or do I need a different set of chips?

    If there is some sort of "countdown" chip, like a reverse of the timer, can you tell me what it is (or how I can make one) because if there is I know a way to solve my problem.

    Thanks.


    Actually, I just thought of a solution. I can just subtract the timer from 60, giving me "time left" which I can manipulate into winch power.

    Still, if anybody has any other ideas please share them. I can always use different/simpler methods of doing things.
    Last edited by Lieutent Slappy Moose; 06-25-2008 at 06:34 PM. Reason: Duh, silly me.
    Where my homies at

  2. #2
    Success: An illusion
    turck3 will become famous soon enough turck3's Avatar
    Join Date
    Jun 2007
    Location
    USA
    Posts
    1,169

    Default Re: A countdown

    Code:
    @NCount Down
    @IStart Reset Max Min
    @OTime
    interval(100)
    Reset -> Time = Max;
    Start & Time & clk() > Min -> Time -= 0.1;
    Time < Min -> Time = Min;
    
    Acurate to the 10th of a second, it counts from the maximum value to the minimum value. It also has a built in system not allowing it to go underneath the minimum... which the version described above doesn't easily allow. Obviously, Min and Max could be replaced with constant values such as 60 and 0...

  3. #3
    Inactive Lieutent Slappy Moose is on a distinguished road Lieutent Slappy Moose's Avatar
    Join Date
    Jun 2008
    Location
    In a box on the moon
    Posts
    44

    Default Re: A countdown

    Thanks, I'll give your way a shot.

    I've actually found an interesting way to do a countdown, and convert the time into length and such. If it doesn't work, I'll try yours.



    Yeah, looks like I am gonna need your timer after all heheheh. The way I used mine doesn't work for certain things.

    Thanks, turns out I really really needed it.
    Last edited by Lieutent Slappy Moose; 06-26-2008 at 08:58 PM.
    Where my homies at

  4. #4
    Inactive Lieutent Slappy Moose is on a distinguished road Lieutent Slappy Moose's Avatar
    Join Date
    Jun 2008
    Location
    In a box on the moon
    Posts
    44

    Default Re: A countdown

    Hey, another question.


    Is it possible to reverse the timer? So if the input is 1, it counts from 0 to 60, but then when the input is -1, it counts from 60 to 0.
    I'm using the expression code from above, and I can't for the life of me figure out how to reverse the timer :C

    Thanks in advance for any help. I really appreciate it.
    Last edited by Lieutent Slappy Moose; 07-28-2008 at 07:19 PM.
    Where my homies at

  5. #5
    Spucatum Tauri
    Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    3,462

    Default Re: A countdown

    Code:
    N@CountDown
    I@Start Reset Max Min Dir
    O@TimeOut
    interval(100)
    Reset -> Time = Max;
    Start & Time & clk() > Min -> Time -= 0.1;
    Time < Min -> Time = Min;
    TimeOut=(Dir==1?Time:Max-Time)
    
    N@ I@ O@ were the wrong way before

    Last line checks if Dir (direction) is equal to 1
    If yes -> Timeout = time
    If no -> Timeout = max - time

    Hope this is any help to you.

  6. #6
    Inactive Lieutent Slappy Moose is on a distinguished road Lieutent Slappy Moose's Avatar
    Join Date
    Jun 2008
    Location
    In a box on the moon
    Posts
    44

    Default Re: A countdown

    I'll try that, and thanks.

    I think I get what the last line does, thanks for the explanation.


    Hmm, it didn't work.

    I may be implementing it wrong, but it either seems to instantly go to max or min, or just stay at one of those.


    I'm gonna try a different method.

    Thank you anyway, though, I appreciate any advice I can get.
    Last edited by Lieutent Slappy Moose; 07-29-2008 at 02:29 PM.
    Where my homies at

  7. #7
    Spucatum Tauri
    Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    3,462

    Default Re: A countdown

    Oh wait...
    You mean that the values of the start button are -1 and 1 ?
    I created a extra switch to turn it around. Which makes it go instantly.

    Code:
    N@CountDown
    I@Start  Max Min Reset
    O@Time
    interval(100)
    Start==1 & clk() & Time<Max -> Time += 0.1;
    Start==-1 & clk() & Time>Min -> Time -= 0.1;
    Time<Min->Time=Min;
    Time>Max->Time=Max;
    Reset->Time=Min;
    
    This code works with a toggle button (-1 Off / 1 On ) connected to start
    It should smooth go up and down. It doesn't matter at what moment you toggle Start.
    Push button -> it counts to max
    Push button again while it's still counting to max -> it counts back to min.

    I also added two extra lines to make absolute sure that Time is always between Min And Max

    Reset sets the timer back to minimum...Instant.

    Code:
    N@CountDown
    I@Start  Max Min
    O@Time
    interval(100)
    Start==1 & clk() & Time<Max -> Time += 0.1;
    Start==-1 & clk() & Time>Min -> Time -= 0.1;
    Time<Min->Time=Min;
    Time>Max->Time=Max;
    
    Same code without reset. Not sure if you need a reset function.

    Tested ingame.. works like a charm
    Last edited by Bull; 07-29-2008 at 06:10 PM. Reason: Added extra safetynet

  8. #8
    Inactive Lieutent Slappy Moose is on a distinguished road Lieutent Slappy Moose's Avatar
    Join Date
    Jun 2008
    Location
    In a box on the moon
    Posts
    44

    Default Re: A countdown

    Thank you so much!

    I had been trying to figure out how I could have two different start values, which would change whether time was added or subtracted, and you just told me how!

    I can't tell you how much this will help me.



    I tried it, and it works. This code will save me so much trouble with everything I make! I am currently using this code very a type of elevator, but this will help me with so much more, especially in factories...

    I appreciate you taking the time to help me!
    Last edited by Lieutent Slappy Moose; 07-29-2008 at 06:33 PM.
    Where my homies at

  9. #9
    Spucatum Tauri
    Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    3,462

    Default Re: A countdown

    my pleasure

+ Reply to Thread

Similar Threads

  1. countdown
    By woo482 in forum Help & Support
    Replies: 4
    Last Post: 10-20-2008, 02:57 PM
  2. Timed Countdown Detonator (Circuit Diagram)
    By evileliminator in forum Wiremod Tutorials
    Replies: 9
    Last Post: 07-12-2007, 02:27 AM
  3. Countdown Timer and Activator
    By teriaki in forum Wiremod General Chat
    Replies: 3
    Last Post: 05-28-2007, 07:40 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