Wait for keypress - problems

Grids
I find it hard using 'wait' (for keypress).

When I insert a big line of if statements and then add some 'waits' to break up the text it does weird things to my game.
Often when I use a few waits in one script it puts a 'continue' sitting weirdly after the command bar.

Also it is impossible to continue working on that script in GUI mode...it jams so I need to work in code mode.

I can do a little bit in code mode (mainly cutting pasting and modifying) but when it comes to 'wait' scripts I get completely confused with all the nesting. When I try to rearrange where the 'wait' is...it always completely stuffs the code.

Is there any tips with multiple 'waits' or another way around it that is simpler.


Here is a sample of a problematic section from the 80s sci-fi game I'm working on.


<use type="script"><![CDATA[
if (GetBoolean(Magnetic Memory Machine, "mmm")) {
if (Got(Amethyst)) {
msg ("I see you are carrying the grand Amethyst. This crystal was used by the Ancient Egyptian to harness cybernetic energy from the sun.")
wait {
msg ("Dr Fortress holds the precious amethyst and gently places it upon a large hexagonal pad. Foam starts spilling out from the machine's tubes.")
MoveObject (You, Travelling through time)
}
}
else {
msg ("You need to find a large Amethyst Crystal to harness cybernetic energy to utilise this machine's future memory power.")
wait {
msg ("Although you could possibly travel in time with someone else as the combined inter-ionisation energy would be sufficient to travel through time.<br/>Give me the name of someone you could travel with?")
get input {
if (IsRegexMatch ("(tina)", LCase (result))) {
msg ("Dr Fortress hands you a strange metallic box that he calls a 'mobile phone'. <br/>'Call her', he says.")
msg ("You type in...")
TextFX_Typewriter ("777 123 777 ", 100)
msg ("After the phone call Tina arrives into the Laboratory in about half an hour. Her blonde perm bounces as she walks. Before you have a chance to smile at each other, Dr Fortress pushes you beside the Magnetic Memory Machine.")
wait {
msg ("He pushes a large red button and the room begins to fog up like the inside of a car on a cold day.")
MoveObject (You, Swirling through Time)
}
}
else {
msg ("It needs to be someone you have acually met.")
}
}
}
}
}
else {
msg ("You should probably ask Dr Fortress about the weird machine before you start poking around.")
}
]]></use>


<object name="Swirling through Time">
<inherit name="editor_room" />
<descprefix>You are </descprefix>
<enter type="script">
MakeObjectVisible (Tina2)
</enter>
<description type="script">
msg ("A helix of colours blurs around you. You can feel Tina's hand gripping yours. The air starts spinning like a broken washing machine. You feel Tina's grip loosen and she is flung away into the void. \"I'll find you,\" you cry out.")
MakeObjectVisible (Tina2)
MoveObject (You, Travelling Wasteland)
</description>
</object>
<turnscript />
<object name="Travelling Wasteland">
<inherit name="editor_room" />
<description>You are standing on a boardwalk but it is covered with debris and burnt palm leaves. In the distance, you see remnants of what appears to be skycrapers crumpled into piles of rubble. A smashed, neon sign lies on the other side of the road, flickering sporadically. To your left, the beach appears grey, layered with dust, floppy disks and broken hard drives. The scent of burning plastic invades your senses.</description>

XanMag
I know this doesn't sound like a legit fix, but this same thing happened to me a couple times.

I copied everything. Deleted it and replanted new scripts piece by piece. Not sure why, but it worked. If that doesn't work, hopefully someone else can give you a more usable fix.

HegemonKhan
Note:

I'm still really confused by scripting 'order of operations' and all the 'rules' of scripting, so take this as a grain of salt, as probably a lot of it is incorrect and~or incorrectly explained by me.

and XanMag may be right... there might be some weird bug in quest, which his solution fixes.

--------------------

you can't have multiple 'get input', 'show menu', 'wait', and etc activating~executing~running at the same time for obvious reasons.

thus, this makes scripting very difficult, especially as you make it more complex (try to keep your scripting as non-complex as you can, if you're a code noob like me, lol).

the 'wait' explained:

it stops the scripting (so, if you got any other scripts trying to activate~run~execute, this will likely cause an error), displays the 'continue' hyperlink, and upon pressing any keyboard key or (left) mouse click, causes whatever scripts you got nested inside of the 'wait' to execute~run~activate.

wait { // this stops the scripting and the 'continue' hyperlink is displayed
// upon keyboard key press and~or (left) mouse click, these nested script~s here, run~execute~activate (and the scripting as a whole, obviously is no longer stopped as well):
// script~s // these scripts run~execute~activate upon a keyboard key press or (left) mouse click
}


because you can only have one 'wait' running~executing~activated, let's look at the 'order of operations' of scripting:

script1
|...\
|....\
|.....script2
|
script3

if script1 and script3 are 'waits' (at the same 'nested'~indenting~column~horizontal layer~level~placement), then you got an error, as the script1 'wait' is considered 'finished' running~activating~executing upon its displayment of 'continue' by script3, even though the script1 'wait' is not fully finished as it is awaiting for that keyboard key press or left mouse click (ie in 'suspended-waiting for input' mode), thus script3 'wait' begins too, and thus the error.

also, if you got any other script (non-input script) for script 1, and your script2 and script3 are 'waits', then they're activating~executing~running at the same time, and thus an error.

and it gets even more messy~convoluted~complicated~complex as it becomes bigger (more same branching as fractal sub-branching):

script1
|...\
|....\
|.....script2
|.......|...\
|.......|....script3
|.......|
|.......script4
|
script5
|...\
|....\
|.....script6
|.......|...\
|.......|....script7
|.......|
|.......script8
|
script9

and further messy with looping and~or jumping around, and~or multple functions~scripts calls (especially functions that return values) ....

-----------

the simplest structure of scripting is this:

script1
-> script2
->-> script3
->->-> script4
->->->-> script5

as it is a straight line of consecutive and non-interfering operations:

\
.\
..\
...\
....\
.....\

as each operation (script~scripting), is at its own 'nesting' (indenting) level~layer

and thus you'll have no errors with using multiple 'waits~get inputs~show menus~etc', as can be seen:

(the 'msgs' are at the same nesting~indenting layers, but its the 'waits~get inputs~show menus' which matter in terms of having them at the different nesting~indenting layers~levels, as it is they that can't be running the same time as another 'wait~get input~show menu', but msgs and other non-input scripts can do so with mostly no problems)

msg ("0")
wait {
msg ("1")
wait {
msg ("2")
wait {
msg ("3")
wait {
msg ("4")
}
}
}
}


or get input:

msg ("0")
get input {
x1 = result
msg ("1")
get input {
x2 = result
msg ("2")
get input {
x3 = result
msg ("3")
get input {
x4 = result
msg ("4")
}
}
}
}


or 'show menus' :

msg ("0")
show menu (xxx) {
x1 = result
msg ("1")
show menu (xxx) {
x2 = result
msg ("2")
show menu (xxx) {
x3 = result
msg ("3")
show menu (xxx) {
x4 = result
msg ("4")
}
}
}
}


----------------------

if any good coders want to try to explain the rules and order of operations with scripting, I'd be so appreciative! I think Jay tried to do so for me in the past, but obviously I haven't been able to understand very well (and~or forgotten) about all the rules and order of operations with scripting, sighs.

Grids
Thanks for that. What about if you have 'if' and 'else' statements - isn't it impossible to keep it linear with your 'waits'?

HegemonKhan
using 'if~if else~else' scripts should work fine, as it's the entire scripting block sequence that is the difficulty in getting it to work correctly without error:

no errors (it works fine):

if (x=1) {
wait {
msg ("1")
wait {
msg ("11")
}
}
} else if (x=2) {
wait {
msg ("2")
wait {
msg ("22")
}
}
} else if (x=3) {
wait {
msg ("3")
wait {
msg ("33")
}
}
} else {
wait {
msg ("4")
wait {
msg ("44")
}
}
}


think of an 'if~else if~else' as its own road, which splits~forks into multiple roads~paths, independent from each other:

.....................|......................................................|
.....................|......................................................|
.....................|.......................................................\
...(if)............../..(x=1)../|..(x=2)..|..|..(x=3)..|..\...(else)....\
..................../............/....|..........|..|..........|....\.............\
.................../............/.....|..........|..|..........|.....\.............\
................./............/.......|..........|..|..........|.......\.............\

by having an 'if~if else~else' block:

if 'if x=1' runs, then (x=2, x=3, and else) does NOT run.
if 'if else x=2' runs, then x=1, x=3, and else) does NOT run.
if 'if else x=3' runs, then (x=1, x=2, and else) does NOT run.
if 'else' runs, then (x=1, x=2, and x=3) does NOT run.

-----------------

the same is true with an 'if~if else' block and an 'if~else' block (see picture above, but it only forks into 2 paths)

if (x=1) {
// 'msg' + 'wait' scripts
} else if (x=2) {
// 'msg' + 'wait' scripts
}


if 'if x=1' runs, then 'if else x=2' does NOT run.
if 'if else x=2' runs, then 'if x=1' does NOT run.

~ AND ~

if (x=1) {
// 'msg' + 'wait' scripts
} else {
// 'msg' + 'wait' scripts
}


if 'if x=1' runs, then 'else' does NOT run.
if 'else' runs, then 'if x=1' does NOT run.

------------------

whereas, when you got multiple blocks, you got to be careful:

'if' blocks:

this will have errors, as the 'waits' activate~run~execute at the same time

if (x=1) {
msg ("1")
wait {
msg ("11")
}
}
if (x=2) {
msg ("2")
wait {
msg ("22")
}
}
if (x=3) {
msg ("3")
wait {
msg ("33")
}
}


'if~else' blocks:

this will have errors, as the 'waits' activate~run~execute at the same time

if (x=1) {
msg ("1")
wait {
msg ("11")
}
} else {
msg ("1A")
wait {
msg ("11A")
}
}
if (x=2) {
msg ("2")
wait {
msg ("22")
}
} else {
msg ("2A")
wait {
msg ("22A")
}
}
if (x=3) {
msg ("3")
wait {
msg ("33")
}
} else {
msg ("3A")
wait {
msg ("33A")
}
}


and hopefully you get the syntax for 'if~else if' blocks... (too lazy to write it in, lol)

Grids
Thanks for this

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums