Calculation

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

Calculation

Postby jordan30001 » Thu Sep 02, 2010 10:46 pm

ok i have got 8 calculations

scene.my.counter = 0
scene.my.counter1 = 0
scene.my.counter2 = 0
scene.my.counter3 = 0
scene.my.counter4 = 0
scene.my.counter5 = 0
scene.my.counter6 = 0
scene.my.counter7 = 0
scene.my.counter8 = 0

now i got 8 "text" counters in a row but i want counter to go up to 9 then reset back to 0 and make counter1 = 1 then go up to 9 then reset to = 0 and make counter2 = 1 and you get the idea how could i solve this please?
jordan30001
 
Posts: 11
Joined: Mon Aug 16, 2010 4:03 pm

Re: Calculation

Postby Rideg » Thu Sep 02, 2010 10:52 pm

I've done this before. I can't remember now. I'm so tired right now. I'll try in the morning eh? :thumbup:
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Calculation

Postby jordan30001 » Thu Sep 02, 2010 10:54 pm

Thanks m8 i apreciate it
jordan30001
 
Posts: 11
Joined: Mon Aug 16, 2010 4:03 pm

Re: Calculation

Postby Rideg » Thu Sep 02, 2010 11:00 pm

Just so I've got it. You want to raise a value when it resets right. Like 1-9 and 10 = 0 and if counter8 = 0 then add 1 to counter7?
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Calculation

Postby jordan30001 » Thu Sep 02, 2010 11:17 pm

counter 8 always counts up there is no deduction
jordan30001
 
Posts: 11
Joined: Mon Aug 16, 2010 4:03 pm

Re: Calculation

Postby kilebantick » Fri Sep 03, 2010 2:35 am

(e)={Scene.my.counter == 9 ? {scene.my.counter = 0; scene.my.counter1 = scene.my.counter1 + 1} : {}}

Translated to English: If scene.my.counter equals nine, then scene.my.counter1 equals whatever it was before, plus one. Just keep repeating that, and add in your own code when necassary. I think that's right :)
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: Calculation

Postby jordan30001 » Fri Sep 03, 2010 1:27 pm

theres one problem if the first counter gets hit untill the second counter gets to 8 and then 9 it carries on past 9 and doesnt reset untill somthing collides with it, is there anyway past this problem?
jordan30001
 
Posts: 11
Joined: Mon Aug 16, 2010 4:03 pm

Re: Calculation

Postby kilebantick » Fri Sep 03, 2010 6:17 pm

Yeah, i had to make a revision of the code, turns out i was using = instead of ==
Just take a look at the code again, it works for me :)
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: Calculation

Postby jordan30001 » Mon Sep 06, 2010 5:09 am

Hey is there anyway to autoupdate each counter with a laser collision because if a counter does not get a collision it goes past the reset counter and does not reset at all even when it collides i could use <= but i would still have the problem of counters going past 9.

Thanks for everyone who has helped so far :thumbup:
jordan30001
 
Posts: 11
Joined: Mon Aug 16, 2010 4:03 pm

Re: Calculation

Postby kilebantick » Tue Sep 07, 2010 2:02 am

Ah, the console variables for it (The scene.my) auto-update one hundred time a second. I don't know what you're talking about. Explain more fully?
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: Calculation

Postby jordan30001 » Tue Sep 07, 2010 6:02 pm

ok i will just use 3 counters to make it easier for now

ok so scene.my.counter = 8 then it gets hit again + 1 = 9 = 0 = scene.my.counter1 = 1 so on and so on untill you get to this

scene.my.counter = 8 scene.my.counter1 = 8 scene.my.counter +1 = 9 = 0 = scene.my.counter1 +1 =9 = 0 which should make scene.my.counter2 = 1 but it doesnt make it 1 it just makes scene.my.counter1 reset without adding onto counter 2 or it just keeps counting up past 9
jordan30001
 
Posts: 11
Joined: Mon Aug 16, 2010 4:03 pm

Re: Calculation

Postby kilebantick » Wed Sep 08, 2010 1:09 am

Hmmm.

Code: Select all
(e)=>{
    Scene.my.one >= 8 ? {
        Scene.my.two = scene.my.two + 1;
        scene.my.one = 0
    } : {};
    Scene.my.two >= 8 ? {
        scene.my.three = scene.my.three + 1;
        scene.my.two = 0
    } : {};
    scene.my.three >= 8 ? {scene.my.three = 0} : {}
}

I think you know how to do the other part of it. That codes been tested, and it works :)
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest