Continuous Move by Key Bind
11 posts • Page 1 of 1
Continuous Move by Key Bind
Will it work ?
How can I improve it?
Is there an easer way?
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
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.
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
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.
I would be more helpful, but I'm on holiday with only my iPod until tomorrow.
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: Continuous Move by Key Bind
- 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...
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.
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.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Continuous Move by Key Bind
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?
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: Continuous Move by Key Bind
Overcomplication is right.
I guess we will have to wait.
I guess we will have to wait.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
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.
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.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Continuous Move by Key Bind
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
-

Chronos - [Most Active Member 2010]
- Posts: 4457
- Joined: Mon Aug 31, 2009 6:00 pm
- Location: Californania
Re: Continuous Move by Key Bind
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.
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
You want scene.my.velx to increase by 1 every second?
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: Continuous Move by Key Bind
That's easy.
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:
However, I think this code is what you want (correct me if my key bind syntax is wrong)
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
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...
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.
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.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
11 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests




