Turn Script - Help

Hello there,
I'm new here and I'm having a bit of trouble understanding what a turn script is. Could someone give me some sort of definition? Maybe an example of what you can do with a turn script?
Also, if there are French speaking users, do you have any idea how you would translate it in French?
Thank you very much.


The 'Elements' are the main "physical" things of quest:

http://docs.textadventures.co.uk/quest/elements/

The 'Turnscript' Element:

http://docs.textadventures.co.uk/quest/elements/turnscript.html

a 'Turnscript' runs/executes/does/activates its scripting every internal turn (any mouse click or entered command/text/input into the command bar at the bottom)

you can have it start the game enabled (true) or not (false), via its 'enabled' Boolean Attribute

if you create/add a 'turnscript' to a Room Object, then it is specific (local) to that Room Object: unless you're in its Room Object, it won't run/execute/activate/do its scripting

otherwise, it's a global turnscript, and its scripting will be run/executed/activated where-ever you are within the game (that is, if its 'enabled' Boolean Attribute's value is set to 'true')

here's an example:

<game name="example_game">

  <attr name="turn" type="int">0</attr>

</game>

<turnscript name="example_global_turnscript">

  <attr name="enabled" type="boolean">true</attr>

  <script>

    msg ("Global Turnscript, Game Turn: " + game.turn)
    game.turn = game.turn + 1
    msg ("Global Turnscript, Game Turn: " + game.turn)

  </script>

</turnscript>

<object name="example_room">

  <inherit name="editor_room" />

  <attr name="turn" type="int">0</attr>

  <turnscript name="example_local_turnscript">

    <attr name="enabled" type="boolean">false</attr>

    <script>

      msg ("Local Turnscript, Room Turn: " + example_room.turn)
      example_room.turn = example_room.turn + 1
      msg ("Local Turnscript, Room Turn: " + example_room.turn)

    </script>

  </turnscript>

</object>

Basically...

Turn-Scripts can run in the background.

Let's say if you are playing your game and the player eats a poisonous flower. Sure, they'd get a "you are poisoned message" in the beginning. But how are you going to tick down their health?

Enter Turn-Script.

So you could set something up like...

if (player.poison=True) {
player.health = player.health - 1
}

And every turn the player takes will reduce their health points by 1 automatically.

Or you could make it more complicated.

Let's say you wanted their health to tick down when they are poisoned but you don't want them to DIE from this. You could do...

if (player.poison=True) {
if (player.health>=1) {
 player.health = player.health - 1 
}
else {
player.poison=False
}
}

Does that make sense?


Thank you very much for your answers and the examples. It does make sense now, indeed!
Many thanks again!


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

Support

Forums