 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
xaero me

Joined: 30 Dec 2003 Posts: 101 Location: somewheres
|
Posted: Sat Feb 21, 2004 4:09 pm Post subject: mini-game script (still need help!!) |
|
|
On my new game you are on a boat and it crashes, then you end up in a lifeboat and have to row your way through the rocks and parts of broken boat, and i want to make a script to make rowing the boat more like the real thing, so i want it to go like this
when you press A you face left(not walk) on D face right, on S walk up and on w walk down,and the script ends when you get to x16,y65( i do have cubes pslibrary)
so what i got is
script,boat,begin
suspend player
if (key is pressed(key:a)) then (set hero direction(me,left))
if (key is pressed(key:d)) then (set hero direction(me,right))
if (key is pressed(key:w)) then (walk hero(me,down,1))
if (key is pressed(key:a)) then (walk hero (me,up,1))
*the part where the script end when hero is at x16,y65*
resume player
end
but the script doesnt wait for you to press the keys it just does the walking by it self
please help
________
Suzuki RM250
Last edited by xaero on Thu Feb 03, 2011 7:52 am; edited 2 times in total |
|
Back to top |
|
 |
MultiColoredWizard Come back, baby! The Breastmaster

Joined: 01 Feb 2003 Posts: 1232
|
Posted: Sat Feb 21, 2004 5:06 pm Post subject: |
|
|
well, for one, get rid of th esuspend and resume players. also, i reccomend using wait(1) after those commands. I'll test it out and tell you what I get when i'm done.
EDIT: okay.
For one, you used A as doing the same thing twice -- which is bad.
try using this:
script,boat,begin
while (true)
do(
if (key is pressed(key:a)) then (set hero direction(me,left))
wait
if (key is pressed(key:d)) then (set hero direction(me,right))
wait
if (key is pressed(key:w)) then (walk hero(me,down,1))
wait for hero
if (key is pressed(key:s)) then (walk hero (me,up,1))
wait for hero
)
end
remember at the top to write "include, scancode.hsi"
That should solve your troubles. |
|
Back to top |
|
 |
xaero me

Joined: 30 Dec 2003 Posts: 101 Location: somewheres
|
Posted: Sat Feb 21, 2004 8:36 pm Post subject: |
|
|
i tried that but when i compile it it says
while (true)
condition is always true (1)
________
Suzuki GS450L
Last edited by xaero on Thu Feb 03, 2011 7:53 am; edited 1 time in total |
|
Back to top |
|
 |
Cube Dimensional Traveller

Joined: 02 Feb 2003 Posts: 294
|
Posted: Sat Feb 21, 2004 8:49 pm Post subject: |
|
|
That's because it is always true, heh. Loops always do what's in the "do" section as long as the condition in "while" is true. Since you put "true" itself as the condition, the loop will NEVER end, therefore mess up your game. The compiler insists on not compiling this because James knew it would be pointless to allow silly things like that.
Instead, put in a tag, like this:
Code: |
script,boat,begin
suspend player
set tag(tag#, on)
while(check tag(tag#)==on) do (
if (key is pressed(key:a)) then (set hero direction(me,left))
if (key is pressed(key:d)) then (set hero direction(me,right))
if (key is pressed(key:w)) then (walk hero(me,down,1))
if (key is pressed(key:a)) then (walk hero (me,up,1))
#the part where the script end when hero is at x16,y65*
)
resume player
end
|
Now, in the "part where the script ends where the hero is at whatever", add:
set tag(tag#, off)
Tag# being the tag you choose to use, whichever one that may be. And you need the suspend player, resume player because you don't want the actual arrow keys to work. Don't worry, your key press commands will be fine (And the hero WILL be able to walk using "walk hero" as long as his speed isn't 0). |
|
Back to top |
|
 |
MultiColoredWizard Come back, baby! The Breastmaster

Joined: 01 Feb 2003 Posts: 1232
|
Posted: Sat Feb 21, 2004 10:21 pm Post subject: |
|
|
Cube's coding is off. He kept the typo of S in. Use this:
Code: | script,boat,begin
suspend player
set tag(tag#, on)
while(check tag(tag#)==on) do (
if (key is pressed(key:a)) then (set hero direction(me,left))
if (key is pressed(key:d)) then (set hero direction(me,right))
if (key is pressed(key:w)) then (walk hero(me,down,1))
if (key is pressed(key:s)) then (walk hero (me,up,1))
#the part where the script end when hero is at x16,y65*
)
resume player
end |
|
|
Back to top |
|
 |
*Worthy* Critical Thinker

Joined: 11 Aug 2003 Posts: 186
|
Posted: Sun Feb 22, 2004 6:19 am Post subject: |
|
|
Don't forget to put a "wait" command in somewhere in the while statement.
~Worthy _________________ You can do whatever you want...but prison is full of people who make bad decisions. |
|
Back to top |
|
 |
xaero me

Joined: 30 Dec 2003 Posts: 101 Location: somewheres
|
Posted: Sun Feb 22, 2004 6:39 pm Post subject: |
|
|
okay so now i've got
script,boat,begin
set tag(3, on)
while(check tag(3)==on) do(
if (key is pressed(key:a)) then (set hero direction(me,left)
wait(1))
if (key is pressed(key:d)) then (set hero direction(me,right)
wait (1))
if (key is pressed(key:w)) then (walk hero(me,down,1)
wait for hero(me))
if (key is pressed(key:s)) then (walk hero (me,up,1)
wait for hero(me))))
end
it compiles but doesn't work in the game, it just stops and you can't do anything
could someone please test it out and see if its going or not?
________
Lamborghini Marzal
Last edited by xaero on Thu Feb 03, 2011 7:53 am; edited 1 time in total |
|
Back to top |
|
 |
*Worthy* Critical Thinker

Joined: 11 Aug 2003 Posts: 186
|
Posted: Sun Feb 22, 2004 6:58 pm Post subject: |
|
|
Get rid of the waits when setting the hero direction. I also don't think you will want to be "waiting for hero", but I don't know what you are using this for. Put a "wait" command (just one tick) in the while statement, not under any "if" statements. It's not running because it is lacking that essential "wait" command.
Code: | script,boat,begin
set tag(3, on)
while(check tag(3)==on) do(
if (key is pressed(key:a)) then (set hero direction(me,left))
if (key is pressed(key:d)) then (set hero direction(me,right))
if (key is pressed(key:w)) then (walk hero(me,down,1)
wait for hero(me))
if (key is pressed(key:s)) then (walk hero (me,up,1)
wait for hero(me)))
wait
)
end
|
I'm not sure if all of your () add up or not, but I'm assuming the last ) represents the end of the "while" statement.
~Worthy _________________ You can do whatever you want...but prison is full of people who make bad decisions. |
|
Back to top |
|
 |
MultiColoredWizard Come back, baby! The Breastmaster

Joined: 01 Feb 2003 Posts: 1232
|
Posted: Sun Feb 22, 2004 7:06 pm Post subject: |
|
|
Make sure that the script is set to run from the NPC that starts it. |
|
Back to top |
|
 |
xaero me

Joined: 30 Dec 2003 Posts: 101 Location: somewheres
|
Posted: Sun Feb 22, 2004 7:43 pm Post subject: |
|
|
still has something wrong cant figure it out though
________
uhwh warehouse
Last edited by xaero on Thu Feb 03, 2011 7:53 am; edited 1 time in total |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sun Feb 22, 2004 11:30 pm Post subject: |
|
|
Umm... do you want the script to move the rower the direction he is facing when you press the up key? Or just up the screen? I think the script you want it this (I also added in checking for being at 16,65):
Code: | script,boat,begin
suspend player
set tag(3, on)
while(check tag(3)==on) do(
if (key is pressed(key:a)) then (set hero direction(me,left))
if (key is pressed(key:d)) then (set hero direction(me,right))
if (key is pressed(key:w)) then (walk hero(me,herodirection(me),1)
wait for hero(me))
if (key is pressed(key:s)) then (walk hero (me,((herodirection(me)+2),mod, 4) ,1)
wait for hero(me)))
if (hero x == 16, and, hero y == 65) then (set tag (3, off))
wait
)
resume player
end
|
Also, why don't you want to use the arrow keys?
Note that ((herodirection(me)+2),mod, 4) returns the opposite direction than which hero 1 is facing. Now if you wanted to make it even more realistic by making it that you row faster going backwards/forwards, you can do that too. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
xaero me

Joined: 30 Dec 2003 Posts: 101 Location: somewheres
|
Posted: Mon Feb 23, 2004 6:49 pm Post subject: |
|
|
still doesn't seem to go
but i wanted it so he walks the way he is facing when you press down and the other way when you press up, and yeah it would probably be better if the controls were changed to the directional keys but i couldn't find what to type for it to go on that
________
extreme vaporizer
Last edited by xaero on Thu Feb 03, 2011 7:53 am; edited 1 time in total |
|
Back to top |
|
 |
byako Shogun

Joined: 28 Oct 2003 Posts: 48 Location: Shotgun in the 48 car...
|
Posted: Mon Feb 23, 2004 9:13 pm Post subject: what about |
|
|
What if you put a
wait for key(anykey)
before the while/do command. _________________ This is my new signature.
---------------------
EDO -an oldie but goodie
matricx re-hacked a great little game |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Tue Feb 24, 2004 12:49 am Post subject: |
|
|
That is very easy. Why didn't you just check the plotscripting library or scancode.hsi?
Change to
key is pressed (key:up)
key is pressed (key:down)
key is pressed (key:left)
key is pressed (key:right)
Ok, how is the script not working? Its very hard for us to fix the script if we have to guess how its broken. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Tue Feb 24, 2004 1:17 am Post subject: |
|
|
Whoops, I took no heed of the 'wait for hero commands'. Does this versio work? :
Code: |
script,boat,begin
suspend player
set tag(3, on)
while(check tag(3)==on) do(
if (key is pressed(key:left)) then (set hero direction(me,left))
if (key is pressed(key:right)) then (set hero direction(me,right))
if (key is pressed(key:down)) then (walk hero(me,herodirection(me),1), wait for hero(me))
if (key is pressed(key:up)) then (walk hero (me,((herodirection(me)+2),mod, 4) ,1), wait for hero(me))
if (hero x == 16, and, hero y == 65) then (set tag (3, off))
wait
)
resume player
end
|
_________________ "It is so great it is insanely great." |
|
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
|