Runaway Script

clockworkdragon
A new forum post for a new problem.

I may have overlooked the solution to this (As I am sure there is a very simple solution that I am just missing) but how do you prevent a runaway script?

By runaway script (not sure if that's the technical term or not) I mean how do you prevent your script from playing out all at once.

For my starting script I have the player reading their own journal and I give them options about what to write, how their family reacted to them boarding an air ship and leaving home and why they left etc etc. Mostly stuff to flesh out the game.

Here is the problem, the game BYPASSES those 'if then' statements and runs the scripting after instead of pausing to give the player a moment to read what is written, even with a 'get input' code.

Instead, what happens is the game reaches that 'if then' statement to show the starting room description.

Is there a script that prevents this?

or should I make it so this a 'enable turn script'?

Silver
You've probably done something wrong as you can control how information is recieved and there's myriad ways to make a player wait either over time ot following an input. Could you post up your game file or recreate the problem and post that up?

OurJud
Pretty much what Silver says.

I'd say the most common are 'wait' scripts and 'key press' scripts.

HegemonKhan
@OurJud:

the 'code:wait === (GUI~Editor:key press)' Script won't work for this issue. Good guess though, you're thinking on the rihgt track, but it's not quite how the 'wait' script works.

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

the 'start' (and other scripts) are a bit 'buggy' (probably not really buggy, just that I and you, don't understand the 'order of operations' of scripts as well as we need to, obviously, as I too have this issue sometimes too).

you need to understand this with scripts (and this is the limit of my own knowledge of 'order of operations' with scripting, grr):

1
|.\
|..2A
|
2B

2A and 2B will run at the same time, as you see that 1 has dual paths, one path to 2A and the other to 2B

possible fixes:

1A. your 'if~else if~else' scripts aren't done right (in the example above: 2A), causing them to not activate, and thus you go to the below script (in the example above: 2B).

1B. you haven't 'nested' (indented, or in the GUI~Editor, you clicked on the wrong 'add a script' circle buttons) properly.

2. you can try the 'on ready' command~script~function~whatever it is~is called ( http://docs.textadventures.co.uk/quest/ ... ready.html ), ask if you can't figure out how to set it up properly, use it, and~or don't understand how it works or what it does. But, I think this will only wait upon (in the example above), 1 to finish, which doesn't help you at all, as it's not what you want, which is, not having 2B running until 2A is done.

3. try to craft~design your scripting so that it is all within a single indented script block~chain:

(start)
Z
-> Y
->-> X
->->-> W
->->->-> V
...........(finish)

4. other ways to manipulate it, using different scripting methods: 'start' script + a Timer ( http://docs.textadventures.co.uk/quest/ ... timer.html ) ~ Turnscript ( http://docs.textadventures.co.uk/quest/ ... cript.html )

5. other ways to manipulate it, using a cunning coding trick, of flags (such as a Boolean or Integer), for example (using a Boolean):

handled_1_flag = false

1
-> 2A {
->-> handled_1_flag = true
-> }
3: if (handled_1_flag = true) {
-> 2B
} else if (handled_1_flag = false) {
// loop (run this Function again)
}

the problem with this (the above), is that it might be in an endless loop forever, as we still haven't created a way for it to do 2A before 3.

6. possibly changing the order of scripts settings in the 'game' (the special game object), so that the 'room description' script is last...

7. or if really desperate... we can turn off the automatic 'room description' and call upon it ourself, so that we make sure that the 'start' (or other) Scripts can finish first in their entirety, before we run (call upon) the 'room description' script.

--------

I'd need to see your entire game code, to see if you made mistakes, or if we got to come up with a creative way to get it to work.

The Pixie
Quest has various commands that will wait for the player to do something, such as "wait" and "ShowMenu". Howewver, you have to put everything you want to happen afterwards in its own block, directly after the command. Here is an example with "wait":

  msg ("First bit")
wait {
msg ("Second bit")
}
msg ("Third bit")


Quest does the first line as expected, then gets to the "wait" line. What "wait" does is start the waiting process, it does not really wait itself. The next section, the block in the curly braces, go off with the "wait", but the Quest iummediately goes on to the next bit, and does the last line. Some time later the player presses a button, and then Quest runs that block of code that was sent with the "wait", and now prints out the second bit.

If you have multiple waits (or whatever, you have to nest them, which means putting the next block of code, inside the previous. In this example, the "Third bit" appears after the player presses a key for a second time.

  msg ("First bit")
wait {
msg ("Second bit")
wait {
msg ("Third bit")
}
}

clockworkdragon
That makes sense. I was kind of hoping for a script that would not require nesting, as that will make things very...disorganized depending on the complexity of the scene.

I take it there isn't any 'wait for script to finish' code or script? If not I shall manage :)

Silver
You say the game ignores the If script and continues on its merry way. That's because you need the rest of the text to be part of the If script, surely? This is very dificult to diagnose without seeing the code and knowing precisely what it is that you want to do.

You could set up a command called Next and place the information that has to be waitied for in there. Then it's a simple case of adding this code in your game:

{command:next}

This will create a hyperlink called next in your game which will then display that information.
You can call the command anything you want and have the text processor still show the link as 'next'.

Set up a command called fwjfhweufhb (or anything random) and then put in this code in your message:

{command:fwjfhweufhb:next}

and it will run whatever script or message you have set up in that command.

Silver
Here's an example of how it could be done.

http://textadventures.co.uk/games/view/ ... al-example

Silver
And here's the file...

jaynabonne
clockworkdragon wrote:That makes sense. I was kind of hoping for a script that would not require nesting, as that will make things very...disorganized depending on the complexity of the scene.

I take it there isn't any 'wait for script to finish' code or script? If not I shall manage :)


There is an alternate way to use the "wait" command, which I just discovered. I won't go through all the steps I went through, but here's what I ended up with. You can pass a function to "wait" instead of an inline script. (For some reason, it wants a function instead of a script. So you can't pass either a script attribute or script variable.) This allows you to "spread the pain" a bit by at least not having to nest.

The entire game is here:

<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="scriptwaittest">
<gameid>8549b59d-daa8-4686-bb38-f550a399426d</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
<start type="script">
msg ("You enter the room...")
wait part2
</start>
</game>
<function name="part2"
msg ("The monster attacks...")
wait part3
</function>
<function name="part3">
msg ("And you die...")
</function>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>

The key parts are this... The game start script:
    <start type="script">
msg ("You enter the room...")
wait part2
</start>

and two functions to handle the second and third steps:

  <function name="part2">
msg ("The monster attacks...")
wait part3
</function>
<function name="part3">
msg ("And you die...")
</function>

Not sure if that's better for you or not. :)

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

Support

Forums