Making an object "blink"

About advanced scenes, and the Thyme scripting language used in Algodoo.

Making an object "blink"

Postby RpT » Tue Aug 27, 2013 6:39 pm

Hi everyone, I want to make a warning sign on a car's dashboard. I succeeded in making it disappear/appear but this happens instantly and only once. I want to make it beep 2 or as many times as I need and then stay ON until a condition from a laser shuts it DOWN.

Code: Select all
scene.my.aidwarn == 1 || scene.my.aidwarn2 == 1 || scene.my.aidwarn3 == 1 ? {
        e.geom.color = [0.96, 0.33600003, 0.33600003, 1.0]
    } : {
        e.geom.color = [0.96, 0.33600003, 0.33600003, 0.0]
    }


This is what the code looks like. (it is put under a onLaserHit textbox)
I must say that I tried something, namely, to put 2 lasers on a circle and spin that circle for as long as I need but it isn't accurate at all. I want a full thymed script please!
So if someone could help me I would very much appreciate it! :D

PS: I want to include this warning sign on a car with an automatic braking system (and other electronic aids) when it encounters something ahead (the final prototype should be really awesome I think :crazy: ).
Țăranul se uită la pământ și pământul la țăran..dacă are pământ, dacă nu, atunci nu!

:lol:
RpT
 
Posts: 11
Joined: Sun Oct 02, 2011 4:45 pm

Re: Making an object "blink"

Postby Ivan » Wed Aug 28, 2013 2:17 pm

Hi, RpT!
I am not sure if I understood what you meant but maybe something like this is what you are looking for.
Code: Select all
color =
{
    scene.my.blink ? {
        (math.toint(sim.tick / 60) % 2 == 0) ? {
            [1, 0.5, 0, 1.0]
        } : {
            [0.25, 0.125, 0, 1]
        }
    } : {
        [0.25, 0.125, 0, 1]
    }
}

The number that divides sim.tick determines the blinking frequency. There is 60 ticks per second, depending on sim.frequency.
User avatar
Ivan
 
Posts: 203
Joined: Tue Oct 06, 2009 2:01 pm
Location: Croatia

Re: Making an object "blink"

Postby RpT » Wed Aug 28, 2013 8:03 pm

Thank you Ivan, it worked :D
Țăranul se uită la pământ și pământul la țăran..dacă are pământ, dacă nu, atunci nu!

:lol:
RpT
 
Posts: 11
Joined: Sun Oct 02, 2011 4:45 pm

Re: Making an object "blink"

Postby Ivan » Thu Aug 29, 2013 12:52 pm

You're welcome!
User avatar
Ivan
 
Posts: 203
Joined: Tue Oct 06, 2009 2:01 pm
Location: Croatia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests