Clearing screen once a turn?

KennedyM
19 Sept 2016, 23:01

Can anyone recommend how to go about coding it so that the screen gets cleared once per turn kind of like was done in previous versions? The first thing that came to mind was to put a ClearScreen command in the turn box of the script page, but when I tried that It didn't show any text at all.


hegemonkhan
19 Sept 2016, 23:39

create a (global: it's not contained-in/within a Room Object) Turnscript, and (probably) have as the last script of it, be: ClearScreen ( http://docs.textadventures.co.uk/quest/scripts/request.html : scroll down to 'ClearScreen')

<game name="whatever">
</game>

<turnscript name="a_global_turnscript">
  <enabled />
  <script>
    // blah script(s)
    // any 'msg' or 'whatever' Scripts' output will be cleared too fast to be read by a human, if it happens before the 'ClearScreen' and without any handling/controls, such as using the 'wait' Function or your own custom Attributes/Flags for its control.
    ClearScreen
  </script>
</turnscript>

and you might want to use the 'wait' Function with it, so that the screen is not cleared until they: click on the blue 'continue' hyperlink or hit the [enter] key:

http://docs.textadventures.co.uk/quest/scripts/wait.html

wait {
  ClearScreen
}

so, you could do this:

<game name="whatever">
</game>

<turnscript name="a_global_turnscript">
  <enabled />
  <script>
    // blah script(s)
    // any 'msg' or 'whatever' Scripts' output now WILL be able to be seen, due to using the 'wait' Function (below) as a control
    wait {
      ClearScreen
    }
  </script>
</turnscript>

alternatively to using the internal turns, you can use changing room locations too, instead. This can be done using a (global) Turnscript and, if 'parent' Attribute checking, or using the special 'changedparent' Script Attribute on your Player Objects (or any other Objects which change their room locations, though this is probably a niche usage, albiet interesting idea, lol).


The Pixie
20 Sept 2016, 07:39

The turn script fires after all the rest of the stuff is done, so Quest will print the room description, then run the turn script, then clear the screen. End result; no room description seen. HK's solution is to have a wait, but that would require the player to click continue before every command. What you really need is something that fires between the player typing and the room description being shown.

That means you will need to override an exist function, so is only possible if using the offline editor. I would suggest putting your ClearScreen at the start of the HandleSingleCommand function.


hegemonkhan
20 Sept 2016, 12:44

There's also custom controls (using the 'if' Script and example Boolean Attributes), if you don't want to mess with the built-in universal/global functionality (the 'HandleSingleCommand' Function), though this takes more operations and work/management on your part.

I just offered the 'wait' Function (in my previous post) as it was the simpliest/quickest, but it's certainly not the only method to control the clearing of the screen.


you could probably even make a 'hook' quest Command, such as if you hit the [spacebar], it'll clear the screen for you, though I'm not sure how much coding you'd need to do (depends on how quest handles keyboard input and if it already has functionality with the [spacebar] key already), via using a 'regular expression (regex)' --- I think --- in order to be able to catch and check for spaces (whitespaces / [spacebar] key), if you can't do so through the Command's simple pattern expression.