 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Onlyoneinall Bug finder
Joined: 16 Jul 2005 Posts: 746
|
Posted: Sat Aug 12, 2006 9:54 pm Post subject: Problem with running script when key is pressed |
|
|
This script has a problem, but I don't know what it is. When the script is run, the character ends up getting stuck in the tile it advances to and it keeps moving (as in the animation), but the character just sits there and you can't open a menu. Is something wrong with it? How would I make a script if this one isn't correct, so that a character will run when you hold down a key?
Code: |
script,Run,begin
if (key is pressed(key:Z))
then,begin
set hero speed(0,5)
end
else,begin
set hero speed(0,4)
end
end |
_________________ http://www.castleparadox.com/gamelist-display.php?game=750 Bloodlust Demo 1.00
 |
|
Back to top |
|
 |
TwinHamster ♫ Furious souls, burn eternally! ♫

Joined: 07 Mar 2004 Posts: 1352
|
Posted: Sun Aug 13, 2006 3:31 am Post subject: |
|
|
Apparently the guys who work on the engine decided to change 'key is pressed' to 'keyval' without updating the dictionary.
Keyval is the exact same thing as key is pressed. |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Mon Aug 14, 2006 1:14 pm Post subject: |
|
|
You should not change speed while the hero is moving. That causes it to become misaligned with the tiles, and gets you stuck. Try wrapping the code in an if block that checks to make sure the hero is not currently walking before changing the speed.
Code: |
script,Run,begin
if(hero is walking(0))
else, begin
if (key is pressed(key:Z))
then,begin
set hero speed(0,5)
end
else,begin
set hero speed(0,4)
end
end
end
|
As for the key is pressed vs keyval, yes there is a change in the behaviour of key is pressed, but not one that could cause this problem
The new behavior of key is pressed is to return true or false depending on whether or not the key is being pressed. The documentation didn't change, because the old implementation of key is pressed did NOT really do exactly what the documentation said.
The old key is pressed (and the new keyval) does the following:
0 if not pressed
greater than 0 if pressed
greater than 1 on key-down and key-repeat
If you wanted to use keyval here, and take advantage of its original keypress detection, you would write:
Code: |
script,Run,begin
if(hero is walking(0))
else, begin
if (keyval(key:Z)>>1)
then,begin
set hero speed(0,5)
end
else,begin
set hero speed(0,4)
end
end
end
|
|
|
Back to top |
|
 |
Onlyoneinall Bug finder
Joined: 16 Jul 2005 Posts: 746
|
Posted: Wed Aug 16, 2006 12:42 pm Post subject: |
|
|
Awesome, now the script runs without much of an issue! Now I also understand better the "hero is walking" plotscripts command and such better as well. Thanks! _________________ http://www.castleparadox.com/gamelist-display.php?game=750 Bloodlust Demo 1.00
 |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|