Wait/Pause/Timeout in Gamebook mode.

There's a million vampire ponies charging at you. Quick hit this link to dodge!
[DODGE LINK]

[GAME WAITS/PAUSES/TIMEOUTS/ETC. FOR 1.5 SECONDS]
[IF YOU DON'T HIT THE DODGE LINK IN 1.5 SECONDS, YOU GET MOVED TO PAGE 2]
[IF YOU HIT THE DODGE LINK WITHIN 1.5 SECONDS, YOU GO THE DODGE LINK PAGE]

Is that possible?


I'm pretty sure that the Game Book has the 'Timer' Element, so yes, this can be done, but you're going to have to code it in yourself.

if you need help with hw to code this in, let us know and we'll help you with it.

do note that working with actual time can be very problematic, especially over online play... as it can be too fast or too long, or just for some people (with good/bad connection/speed) vs the other people with bad/good connection/speed. Also, it might be perfect amount of time/timing offline, but not online... (lag/latency issues)


Awesome HK. Ok, so this is how dumb I am. I think I'm gathering that a timer is a "function." Correct?

What would be the most basic way to start a timer? In pure code. Is it:

SetTimerInterval (timer, interval)

And then from there, how do I say, in code, "after the interval, go to page x?"

If I could just get that far I would be more than half way there.

edit: (And I hear you that it can be problematic for a number of reasons, I'm just really curious if I can get it to work at all)


I know you work in code and (at that) only text adventure mode, so Gamebook GUI isn't your forte. But when you click to add a script command in Gamebook mode these are literally all the options (minus the effects at the bottom 'typewriter' and 'unscramble'). Like, which of these would I select if I were using it this way. I can also put in lines of code in different places, I'm not afraid of breaking stuff. But I'm just curious what you think:


no, the Timer is an Element (Elements are quest's underlying code OBJECTS of OOP/OOD: Object Oriented Programming/Design, not to be confused with the user level 'Object' Element):

Elements: Objects, Exits (Text Adventure), Verbs, Commands, Functions, Object Types, etc

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

which you have to create and define (set up) the Timer (what it does and its interval):

<timer name="NAME_OF_TIMER">
  <enabled /> // only have this here if you want the timer to be enabled when the game begins, otherwise, you can control when/where it's enabled/disabled // the long version of it, looks like this: <attr name="enabled" type="boolean">true</attr>
  <interval>SOME_NUMBER</interval> // this is the interval (in seconds) of when it fires/activates/runs/executes (only when it is enabled of course), for example: 5: every 5 seconds its scripting is executed/activated, so it would be on/at: 5, 10, 15, 20, 25, etc etc etc seconds
  <script>
    // scripting: actions/events (what it does)
  </script>
</timer>

there's various helper Functions though for you to use as well:

http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html

EnableTimer (NAME_OF_TIMER) // http://docs.textadventures.co.uk/quest/functions/corelibrary/enabletimer.html
DisableTimer (NAME_OF_TIMER) // http://docs.textadventures.co.uk/quest/functions/corelibrary/disabletimer.html
create timer (NAME_OF_TIMER) // http://docs.textadventures.co.uk/quest/scripts/create_timer.html // creates a timer as well
etc etc etc // http://docs.textadventures.co.uk/quest/functions/corelibrary/settimerinterval.html
etc etc etc // http://docs.textadventures.co.uk/quest/functions/corelibrary/settimerscript.html
etc etc etc // http://docs.textadventures.co.uk/quest/functions/corelibrary/settimeout.html
et etc etc // http://docs.textadventures.co.uk/quest/functions/corelibrary/settimeoutid.html // this also creates a Timer, so you can use this Function, or you can create/add a Timer through the GUI/Editor, or in code via the 'timer' creation tag block (see the code box above)


see if you can figure it out from these links, if not, let me know, and I'll help you with it


P.S.

Timers (and Turnscripts and Commands) can be global (game wide: NOT trapped within a specific room) or local (within a specific room only):

// using a Text Adventure for example, but still about the same

// global timer:

<asl version="550">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="example_game">
    // blah Attributes
  </game>

  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>

  <timer name="example_timer">
    // blah Attributes (set it up)
  </timer>

</asl>

-----------

// local Timer:

<asl version="550">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="example_game">
    // blah Attributes
  </game>

  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>

  <object name="example_room_object">
    <inherit name="editor_room" />
    <timer name="example_timer">
      // blah Attributes (set it up)
    </timer>
  </object>

</asl>

design concept/hint/help for you:

// Page X:

msg ("There's a million vampire ponies charging at you. Quick hit this link to dodge!")
// script to display your [DODGE LINK]
EnableTimer (timer_1)
if (player.parent = NAME_OF_DODGE_PAGE) {
  DisableTimer (timer_1)
}

--------

// Page X:

put this timer within page X:

<object/page name="Page_X">
  <script>
    msg ("There's a million vampire ponies charging at you. Quick hit this link to dodge!")
// script to display your [DODGE LINK]
    EnableTimer (timer_1)
    if (player.parent = NAME_OF_DODGE_PAGE) {
      DisableTimer (timer_1)
    }
  </script>
  <timer name="timer_1">
    <attr name="enabled" type="boolean">false</atr>
    <attr name="interval" type="int">2</attr> // I don't think you can do fractional seconds as this is the Integer Data Type, as even if you did: 3/2, it'll truncate (I think): 1.5 ---> 1.0, otherwise, it rounds up (2.0) or down (1.0), but it can't be 1.5 as that's not an Integer Value
    <script>
       // script that moves you to [PAGE 2]
      DisableTimer (timer_1)
    </script>
  </timer>
</object/page>

Wow nice. Just read this. Will check back in with my coding adventures. Thanks man.


Ok wait, I started reading and trying things and errors kept getting returned.

Let me clarify.

When I tell Quest to SetCounter, it sets the counter. Just right there on the page.

SetCounter ("counter1", 10)

Boom, the game knows from then on that counter1 is 10.

How do I, in that way, right on the page, just say, "Set/Enable/Start timer" ?

My problem is I can't tell if I'm supposed to set the timer's attributes on in the overarching "game" page, or if I can set all the conditions of the timer just right on the page that I want them on.

Does that make sense?


I'm not quite sure I understand what you're asking, so let me know if I'm off with my repsonses


"How do I, in that way, right on the page, just say, "Set/Enable/Start timer" ? (Major Powers)"

in code, to 'turn on/off' (maybe this makes more sense) the Timer, it's: EnableTimer (NAME_OF_TIME) / DisableTimer (NAME_OF_TIMER), and I'm sure through the GUI/Editor, one of those Script options (run as script -> add new script -> ??? Script) should be called something similiar.

You got to, set up / create, the Timer though of course first, so that it's actually doing something, when you enable it: an interval of/for when it runs its script, and the scripting for it doing stuff (and it's name, for being able to reference/'call'/use it)


"My problem is I can't tell if I'm supposed to set the timer's attributes on in the overarching "game" page, or if I can set all the conditions of the timer just right on the page that I want them on. (Major powers)"

The Timer itself, holds/has it's own Attributes: interval, script, enabled (true, or not:false), and (its name can be included as an Attribute for completeness)

do NOT put the Timer inside of the 'game' Game Settings Object (this will likely cause errors):

<asl version="555"> // the 'asl' block is the actual GAME OBJECT, which holds all the content/code that is your game
  <game name="THIS_IS_THE_GAME_SETTINGS_OBJECT">
  </game>
</asl>

you can set up the timer before the game even begins (either as global or local - determined by where it's placed):

<timer name="blah">
  // optional: <enabled />
  <interval>5</interval>
  <script>
    msg ("example")
  </script>
</timer>

you can create and set it up (set it's attributes' values) during game play, via using the scripting:

http://docs.textadventures.co.uk/quest/scripts/create_timer.html (this example, shown below, does some stuff that you're probably not interested in doing for your game, but it's an example of creating a timer and setting it up)

create timer (“test_timer”)
o = GetTimer (“test_timer”)
msg (TypeOf(o))
o.script => { msg (“timer=” + this.name) }
o.interval = 10
EnableTimer(o)

you can also individually set and/or re-set/change the timer's attributes too, via:

(see the links in a few posts of mine up)

SetTimerInterval
SetTimerScript


Ok. Where... where do I set it up. I have the "full" code view, which shows the entire code for the whole game, which is your forte. Whenever I mess with the root code I break the whole game.

I also have the "code" view in the GUI in the desktop Quest thingy, where you hit this button and it shows the code in the page, like this:



If you don't open the "code" view, (I wrote NO! the GUI looks like this (this is the same input code from above):




Based on that bullshit, where do I even start to enter the timer code? How do I write it?



I don't even know where to put:

create timer (“test_timer”)
o = GetTimer (“test_timer”)
msg (TypeOf(o))
o.script => { msg (“timer=” + this.name) }
o.interval = 10
EnableTimer(o)

What does that even mean?

Sorry for being an idiot....


alright, been trying to get this to work in Game book, due to my failure to be of help, coding is not easy and I was very vague to you, so you're certainly not an idiot, I'm the idiot for failing to help you with this stuff successsfully.


anyways, unfortunately, the 'Timer' Element is not added to the Game Book

fortunately, you can certainly add it to the Game Book

I've been trying to do so, but I'm not familiar enough with the underlying code of quest, as there's a lot of dependant chunks of code spread over/within the various 'core' library files, and I've not located every bit of code needed to implement the 'Timer' Element fully into the Game Book.

Pixie (and probably Pertex too) are more familiar with this built-in stuff and the underlying code of quest, (Pixie already created a hybrid library: a Text Adventure, meaning it has the entire/full features/capabilities of quest, but it looks/feels like it's a Game Book, I'd assume this would include having the 'Timer' Element implemented)


I got it somewhat working so far of what code I could find in the libraries...

here's my example game:

(create a new Game Book game, go into full code view --- if you don't know how, let me know and I'll help you with it --- next, delete all the code, and then copy and paste this code of mine into your blank-coded Game Book game, and save it. then you can study it in the GUI/Editor and run/play it too. But, there's still a lot of issues I've not been able to fix yet... due to not finding all of the dependency coding parts within the various libraries)

(I'm still using the older quest.exe, of version "550", so in my code below, just change it to: version="560", or: version="570", or just go into the GUI/Editor, and click on the 'help' in the horizontal menu bar at the top, and click on 'about', this will show you the quest.exe version you got, only the first two digits matter, and then add a zero for the 3rd digit, for example, my 'about' says: Quest 5.6, Build 5.6.5514.32136, so, in code, it would just be this: version="560". Oops, forgot this: the version didn't change the engine/quest much from v550 to v560, so that's why you can use version="550" in the code, even though you've got installed the v560 quest.exe, I don't think this is true for v570, but you'd have to ask Pixie about it, or jsut try/test it yourself)

(WARNING: don't mess, aka do NOT change them and then save, with these files unless you know what you're doing, as if you mess up, you break quest and will have to uninstall and reinstall quest again ---- but, if interested, just open up your quest folder, in your: programs files or program files (x86) folder, on/in your c-drive, and then open up the 'core' folder, and in here, are all the library files that make up the quest engine! Alex and co made quest really powerful, if you're a good programmer, you can code in your own engine! if you create a new Text Adventure or Game Book game, look at the full code view, and near the top will be the 'include ref="xxx.aslx" code lines, these are the library files that make up and/or hub to more library files, which is what gives us the Text Adventure mode/engine and the Game Book mode/engine)

<asl version="550">

  <include ref="GamebookCore.aslx" />

  <include ref="CoreTimers.aslx" />
  <include ref="CoreEditorTimer.aslx" />
  <include ref="CoreEditorScriptsTimers.aslx" />

  <implied element="timer" property="interval" type="int" />
  <implied element="timer" property="script" type="script" />

  <game name="test">

    <gameid>877a6b90-ab33-4c8e-bb36-b34b2c452db9</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>

    <timeelapsed type="int">0</timeelapsed> // not sure if adding this fixed the issue of a missing code part dependency, which caused/causes an error when trying to use the 'EnableTimer(Page1_local_timer)', and thus I instead have it set to be enabled at game start, but you might want to try, having the 'enabled' Boolean Attribute on my 'Page1_local_timer' Timer be set to False. Actually, I already changed it to be 'false', so if you get an error, change it back from 'false' to 'true'.

  </game>

  <object name="Page1">

    <inherit name="scripttext" />

    <description>This is page 1. Type a description here, and then links to other pages below.</description>

    <options type="simplestringdictionary">Page2 = This link goes to page 2; Page3 = And this link goes to page 3</options>

    <script type="script">
     msg ("There's a million vampire ponies charging at you. Quick hit this link to dodge!")
     msg ("{page:Page2:DODGE}")
     EnableTimer (Page1_local_timer)
    </script>

    <object name="player">
      <inherit name="defaultplayer" />
    </object>

  </object>

  <object name="Page2">

    <inherit name="scripttext" />

    <description>This is page 2. Type a description here, and then links to other pages below.</description>

    <script type="Script">
      if (Page1_local_timer.enabled) {
        DisableTimer (Page1_local_timer)
      }
    </script>

  </object>

  <object name="Page3">

    <inherit name="scripttext" />

    <description>This is page 3. Type a description here, and then links to other pages below.</description>

    <script type="Script">
      if (Page1_local_timer.enabled) {
        DisableTimer (Page1_local_timer)
      }
    </script>

  </object>

  <timer name="Page1_local_timer">

    <parent type="object">Page1</parent>

    <attr name="enabled" type="boolean">false</attr> // if you're getting an error, change the 'false' to 'true'

    <interval>5</interval>

    <script>
      MovePlayer (Page3)
    </script>

  </timer>

</asl>

let me know if the code produces any errors... as I literally typed this into this post from writing it from another source/computer (instead of just copy and pasting it), so there's likely typos/mistakes that I made... and I'll help you fix them up.


ask if you got any questions too, or about whatever.... if you want to understand what my lines in my code are doing and etc.


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

Support

Forums