Continuous Move by Key Bind

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

Continuous Move by Key Bind

Postby salies1807 » Wed Jun 01, 2011 10:18 pm

Will it work ?

How can I improve it?

Is there an easer way?




Code: Select all
keys.bind=("d",{true ? {sim.frequecy = ({scene.my.movx2(scene.my.passo/scene.my.segundo)};100)} : sim.frequecy=100}

scene.my.movx2=[{scene.my.passo=scene.my.passo + 1};{scene.my.passo=0;scene.my.velx1=scene.my.velx1 + 1 }]

scene.my.passo=0
scene.my.segundo=20
scene.my.velx1=0
salies1807
 
Posts: 4
Joined: Sun May 15, 2011 1:18 am

Re: Continuous Move by Key Bind

Postby salies1807 » Thu Jun 02, 2011 2:26 am

I've made some changes but it still don't work... :(
The "scene.my.velx1" should get bigger, but he doesn't and I just don't know why.



Code: Select all
keys.bind("d",{sim.frequency = scene.my.movx2(scene.my.passo/scene.my.segundo)() ; 100})

scene.my.movx2=[{scene.my.passo=scene.my.passo + 1},{scene.my.passo=0;scene.my.velx1=scene.my.velx1 + 1 }]

scene.my.passo=0
scene.my.segundo=20
scene.my.velx1=0
salies1807
 
Posts: 4
Joined: Sun May 15, 2011 1:18 am

Re: Continuous Move by Key Bind

Postby bozbez » Sat Jun 04, 2011 6:21 pm

There are other reasons why it won't work, but the main is that you need too stop messing with sim.frequency and find another method or doing what you need.

I would be more helpful, but I'm on holiday with only my iPod until tomorrow. :)
Image

Go here. Now. That's Now. Not in 5 minutes. Now.
User avatar
bozbez
 
Posts: 149
Joined: Tue Apr 12, 2011 7:01 pm

Re: Continuous Move by Key Bind

Postby Someone Else » Sun Jun 05, 2011 6:54 am

Code: Select all
scene.my.movx2= (a, b, c)=>{a = a + 1;
a = 0;
c = c + 1};

keys.bind("d",{scene.my.unknown = scene.my.movx2(scene.my.passo, scene.my.segundo, scene.my.velx1)});

scene.my.passo=0;
scene.my.segundo=20;
scene.my.velx1=0;


I've no clue what you're trying to do, and I also have no clue how key binds work, but this is my best guess.

Note how I substituted scene.my.unknown for sim.frequency.

bozbez, do you have any idea?
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Continuous Move by Key Bind

Postby bozbez » Sun Jun 05, 2011 4:45 pm

I think things are being overcomplicated. From what i gather from the original code, all that needs to be done is the increasing of scene.my.velx1 when 'd' is pressed?
Image

Go here. Now. That's Now. Not in 5 minutes. Now.
User avatar
bozbez
 
Posts: 149
Joined: Tue Apr 12, 2011 7:01 pm

Re: Continuous Move by Key Bind

Postby Someone Else » Mon Jun 06, 2011 2:31 am

Overcomplication is right.

I guess we will have to wait.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Continuous Move by Key Bind

Postby Chronos » Mon Jun 06, 2011 3:17 am

You know, you could always bind D to a hinge and have it trigger an onCollide, which increases the variable every time the object with the hinge hits another object. :|
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: Continuous Move by Key Bind

Postby salies1807 » Wed Jun 08, 2011 3:39 am

Sorry for all this, but I'm just starting to program, I was just trying to increasethe velx1 as we press 'd' but the action (movx2) was supposed to happen every second with no need to press repeatedly the key.

Also, I was trying to do it only programming and with no scene.my things. :?
salies1807
 
Posts: 4
Joined: Sun May 15, 2011 1:18 am

Re: Continuous Move by Key Bind

Postby bozbez » Wed Jun 08, 2011 2:27 pm

You want scene.my.velx to increase by 1 every second?
Image

Go here. Now. That's Now. Not in 5 minutes. Now.
User avatar
bozbez
 
Posts: 149
Joined: Tue Apr 12, 2011 7:01 pm

Re: Continuous Move by Key Bind

Postby salies1807 » Thu Jun 09, 2011 1:34 am

yeap
salies1807
 
Posts: 4
Joined: Sun May 15, 2011 1:18 am

Re: Continuous Move by Key Bind

Postby Someone Else » Thu Jun 09, 2011 6:49 am

That's easy.

Code: Select all
scene.my.velx = {math.toInt(sim.time)}

This constantly increases scene.my.velx by one unit every second. Using a key bind is much more complicated.

I would do it mechanically, use a hinge to make a box hit another box every second. One of the boxes gets this code:
Code: Select all
scene.my.velx = scene.my.velx + 1


However, I think this code is what you want (correct me if my key bind syntax is wrong)
Code: Select all
keys.bind("d", {{scene.my.ltime >= sim.time + 1} ? {
    scene.my.velx = scene.my.velx + 1;
    scene.my.ltime = sim.time
} : {}})


I know if you call this up on a laser, it should work, but I don't know if a key bind is called upon every frame or just when the button is initially pressed. I shall test it.

Shows what a tired brain can do. This code works:
Code: Select all
keys.bind("d", {
        {scene.my.ltime <= sim.time - 1} ? {
            scene.my.velx = scene.my.velx + 1;
            scene.my.ltime = sim.time
        } : {}
    })
}
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron