Turns!!!

Yggdrasill Games
28 Jun 2017, 07:54

So, i am really stuck on the "making turns part of the tutorial." Can anyone please give me a better step by step guide on how to do it because the tutorial is not very good at explaining this. Thank you.


The Pixie
28 Jun 2017, 08:18

Do you mean turn scripts? What are you not getting? I am not sure what else I can add to the tutorial to make it clearer.


hegemonkhan
28 Jun 2017, 13:32

I think he/she needs help with how to do the displayment of a (increasing/'counter') 'turn' Integer Attribute. If this is already in the tutorial (too lazy to look), then maybe just re-explaining/re-walkthroughing it, in a slightly different way will help...

I'll give it a shot at trying to help him with it


Quest has 'internal turns', that increase with any action you do (typed-in and entered command in the input/command bar and/or a mouse click on a hypertext in the left big text box or on a 'button/verb' in the right side).

I don't know if these internal turns are stored in some VARIABLE and/or if accessible at the user level (aside from a Turnscript), for example: being able to use the special 'changed' Script Attribute with the internal turns if are stored into an accessible VARIABLE

Pixie can maybe address this, depending on how much of quest's internal coding he knows or don't knows yet (Pixie does know a lot of quest and at least some of its internal coding, if not more or all, I just don't know how much he knows of it).


however, as stated above, the Turnscript does indeed access these internal turns (every internal turn: a Turnscript's scripts are run/executed/activated/done/fired, of course when it is 'enabled' and/or you're in the same room as it, depending on the controls you got set up for it)

so, for example:

(usually, for the 'game turns' effect, you want/need the Turnscript to be global, so it is always counting/increasing with each internal turn, but you may not always want it to be firing as well, you might want some actions that you can do without your 'game turns' increasing, which Pixie has a library/guide on doing this, somewhere in the libraries and code samples forum board and/or on his quest github page)

<game name="example_game">
  <attr name="turn" type="int">0</attr>
  <attr name="statusattributes" type="simplestringdictionary">turn = Game Turn: !</attr>
</game>

// notice that the 'Turnscript' Element below is NOT inside of an 'Object' Element, this makes it a global turnscript, it always applies, no matter where (what room doesn't matter as any/every room you're in, doesn't matter) you're within the game

<turnscript name="example_global_turnscript">
  <enabled /> // the long form is: <attr name="enabled" type="boolean">true</attr> // if you want the turnscript to be enabled at the start of your game
  <script>
    // blah scripting // all the stuff/actions/events/etc you want to do during the turn (and thus BEFORE the next turn)
    game.turn = game.turn + 1 // indicating the next turn, with the new/increased and displayed (see the 'game.statusattributes' for the actual displayment cause/production) turn count, for example: from turn 0 to turn 1, from turn 1 to turn 2, etc etc etc
  </script>
</turnscript>

<!--
// whereas, if you got a turnscript inside of a room object, then it is a local turnscript, it only applies when you're within the same room as it (the same is true for the 'Command' Element as well, by the way, you can have global Commands as well as local Commands):

<game name="example_game">
  <attr name="room_X_turn" type="int">0</attr>
  <attr name="statusattributes" type="simplestringdictionary">room_X_turn = Room X Turn: !</attr>
</game>

<object name="room_X">
  <turnscript name="example_local_turnscript">
    <enabled /> // even though this is enabled at the beginning of the game, it's still a local turnscript, and thus you got to be in the same room as it, for it to apply (actual/effective enablement).
    <script>
      // blah scripting
      game.room_X_turn = game.room_X_turn + 1
    </script>
  </turnscript>
</object>
-->

and if you want to see both (global and local) together, working:

<game name="example_game">
  <attr name="turn" type="int">0</attr>
  <attr name="room_X_turn" type="int">0</attr>
  <attr name="statusattributes" type="simplestringdictionary">turn = Game Turn: !; room_X_turn = Room X Turn: !</attr>
</game>

<object name="room_X">
  <turnscript name="example_local_turnscript">
    <enabled />
    <script>
      // blah scripting
      game.room_X_turn = game.room_X_turn + 1
    </script>
  </turnscript>
</object>

<turnscript name="example_global_turnscript">
  <enabled />
  <script>
    // blah scripting
    game.turn = game.turn + 1
  </script>
</turnscript>

ask if you need help with anything or if you got any questions on anything


Yggdrasill Games
29 Jun 2017, 01:34

I am just confused when the tutorial explains that i need to go to the "game" and run a script there and then it suddenly says i need to create an attribute tab in the "player." It doesn't really explain how to go from "game" to "player" or even how to create this attribute tab.


hegemonkhan
29 Jun 2017, 03:42

okay, in the tutorial (hopefully this is where you're looking at):

http://docs.textadventures.co.uk/quest/tutorial/using_timers_and_turn_scripts.html

here's what you need to do:

  1. create your 'turn' Integer Attribute on the special 'game' Game Settings Object:

left side's 'tree of stuff '(Elements: Objects, Exits, Functions, Commands, Verbs, Turnscripts, Timers, Object Types / Types, etc):

Objects
-> 'game' // the special 'game' Game Settings Object // click on 'game' so it is highlighted, then look at the right side (and see below)
->-> Commands
->-> Verbs
-> 'room' Room Object
->-> 'player' Player Object
Functions
Timers
etc etc

after you clicked on 'game' so that it is highlighted, and now on the right side, it's on the 'setup' Tab, but we want to click on the 'Attributes' Tab, so it's now showing the 'Attribute' Tab's stuff

Attributes (NOT the status attributes and NOT the inherited attributes) box -> Add -> (see below)

(Object Name: game)
Attribute Name: turn // for this example, but you can name it whatever you want
Attribute Type: int // int = integer
Attribute Value: 0

in code scripting it looks like this: game.turn = 0 // when using code scripting, quest is able to determine the Attribute Type from its Value.

The special 'game' Game Settings Object contains the 'turn' Integer Attribute

  1. create the displayment of our 'turn' Integer Attribute:

for this we use the built-in 'statusattributes' Stringdictionary Attribute. However, this only works for the special 'game' Game Settings Object or Player Objects (such as the default 'player' Player Object).

so, what that means is, we either need to add a statusattribute to (contained within) either: the special 'game' Game Settings Object or a Player Object.

for a game turn, it's most logical to use the special 'game' Game Settings Object, so we'll do that (and this way we don't have to click-on/switch-over to the 'player' Player Object)

if you're not still viewing the 'Attributes' Tab of the special 'game' Game Settings Object: click on 'game' on the left side's 'tree of stuff' so it is highlighted and then on the right side, click on the 'Attributes' Tab.

now, for the 'status attributes' box (NOT the 'attributes' box and NOT the 'inherited attributes' box) -> Add -> (see below)

Name text box (this is our 'key'): turn // or whatever you named this Attribute as (see #1)
Field text box (this is our 'value'): Game Turns: ! // this will display during game play in the status pane on the right side: Game Turns: (the current 'game.turn' value)

A stringdictionary Attribute is just an input-output(string input, string output) Function: the 'turn' is the input ('key'), and it's match up with the output ('value'): Game Turns: !, like this in its coding: turn = Game Turns: !, and thus it outputs: Game Turns: (current value of the'game.turn' Integer Attribute)

also, the '!' is a special command that GETS/displays the current value of the (in this example) 'game.turn' Integer Attribute

  1. lastly, we create a global (and enabled at game start) Turnscript for handling the updating (increasing) of our 'game.turn' Integer Attribute with every internal turn (any action you do: a typed-in input or a click on a hypertext or button/verb during game play):

Unfortunately... the 'Turnscript' Element was accidentally left out it showing up in the left side's 'tree of stuff' (the Timer is there, but no Turnscript), and not sure if Pixie has fixed this up in quest version 560/570, or not.

However, you can still easily access/create one:

A. simply right click on the left side's 'tree of stuff', and the popup menu window will have the 'add turnscript' option for you.
B. at the menu bar at the top of the screen (not sure what it's under), you can find the 'add turnscript' or something like that.

the turnscript added/created will be a global turnscript, which is what we want.
(whereas, a local turnscript is a turnscript that is contained-within/added-to an Object)

Turnscript Name text box: global_turnscript // or whatever you want to name it as

'enabled' (called: enabled when game starts or something like this) checkbox: check it in (have it be checked in)

and for its scripting (add new scripts):

// blah add new scripts

// last/bottom-most script:
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable game.turn = [EXPRESSION] game.turn + 1

(I don't know the GUI/Editor's script options, so I "cheat" and use the '[EXPRESSION]' script option, so I can type in what I want)
(there's probably some kind of 'increase counter' script option that you'd normally use for doing this. A 'counter' is just an Integer Attribute, as Integer Attributes can be increased/descreased)
(change 'turn' to whatever you named it, if you named it something else: see #1)


and hopefully I didn't mess up and/or forget anything, and you were able to follow my directions, as then it should work for you.


hegemonkhan
29 Jun 2017, 03:54

P.S.

here's a step by step guide on creating your own demo game on further understanding the basics of Attribute (including status attributes) usage:

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375

and here's a guide on Attributes and the 'if' Script usage, though it's quite a big step up from just using the basics of quest and its GUI/Editor (the tutorial stuff), but if you can learn/understand this stuff, it opens up 90% of everything that you want to do with the making of your game:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk


ask if you got any questions or need help with anything


The Pixie
29 Jun 2017, 07:07

I have just realised the fourth image on that page is wrong, it is just a repeat of the third image. It has now been corrected, so it might make more sense.