Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

mini-game script (still need help!!)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
xaero
me




Joined: 30 Dec 2003
Posts: 101
Location: somewheres

PostPosted: Sat Feb 21, 2004 4:09 pm    Post subject: mini-game script (still need help!!) Reply with quote

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
View user's profile Send private message MSN Messenger
MultiColoredWizard
Come back, baby!
The Breastmaster



Joined: 01 Feb 2003
Posts: 1232

PostPosted: Sat Feb 21, 2004 5:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
xaero
me




Joined: 30 Dec 2003
Posts: 101
Location: somewheres

PostPosted: Sat Feb 21, 2004 8:36 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Sat Feb 21, 2004 8:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
MultiColoredWizard
Come back, baby!
The Breastmaster



Joined: 01 Feb 2003
Posts: 1232

PostPosted: Sat Feb 21, 2004 10:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
*Worthy*
Critical Thinker




Joined: 11 Aug 2003
Posts: 186

PostPosted: Sun Feb 22, 2004 6:19 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
xaero
me




Joined: 30 Dec 2003
Posts: 101
Location: somewheres

PostPosted: Sun Feb 22, 2004 6:39 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
*Worthy*
Critical Thinker




Joined: 11 Aug 2003
Posts: 186

PostPosted: Sun Feb 22, 2004 6:58 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
MultiColoredWizard
Come back, baby!
The Breastmaster



Joined: 01 Feb 2003
Posts: 1232

PostPosted: Sun Feb 22, 2004 7:06 pm    Post subject: Reply with quote

Make sure that the script is set to run from the NPC that starts it.
Back to top
View user's profile Send private message
xaero
me




Joined: 30 Dec 2003
Posts: 101
Location: somewheres

PostPosted: Sun Feb 22, 2004 7:43 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sun Feb 22, 2004 11:30 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
xaero
me




Joined: 30 Dec 2003
Posts: 101
Location: somewheres

PostPosted: Mon Feb 23, 2004 6:49 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
byako
Shogun




Joined: 28 Oct 2003
Posts: 48
Location: Shotgun in the 48 car...

PostPosted: Mon Feb 23, 2004 9:13 pm    Post subject: what about Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Feb 24, 2004 12:49 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Feb 24, 2004 1:17 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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