How can I make use of the health variable in Quest through the editor

0 votes
113 views
asked Aug 14 in Authoring by Robert GAC (3 points)

The player attribute 'health' can be turned on using the game features tab in the editor. It then displays 100% in the status window, and I can find how to raise or lower it using scripts, but when it reaches 0 nothing happens, and I want to be able to print a message and end the game when that happens.

1 Answer

0 votes
answered Aug 14 by hegemonkhan (161 points)

alright... hopefully this is what you want to get the health's value to appear in the 'status' pane during game play...

'game' Game Object -> 'Attributes' Tab -> Status Attributes -> Add -> (see below)

Attribute Name: health

Format String: !
~ or (both of these formats should output, Health: yourcurrenthealth_amount) ~
Format String: Health: !

the '!' is a special command which will tell the quest engine to output whatever your current health is at during game play in the 'status' pane.

so now you should be seeing (for example):

Health: 999
Health: 500
Health: 100
Health: 50
Health: 0
Health: -100
etc etc etc

(you need to do some check 'if' scripting to prevent going into negative health values, so you may not be ready for this, and I don't think it matters, as you have it be a 'game over' anyways)


as for the multiple health displayment messages...

if the zombie screenshot is a Turnscript... you're going to constantly lose health until you're dead, due to the nature of the Turnscript and~or your lack of needed scripting to prevent this... if the zombie screen shot is a Timer, than you're okay... but you're still going to see the message at every interval that the Timer activates its scripting.

and for your 'object attribute equals ~ end game' screenshot... unfortunately... with the script you're using... in order for the game to end (for you to die) ... your health must land on exactly 0 ... which it may not due so, based on your starting health and the amount you reduce your health by.

what you want is this script (in code, hopefully it doesn't scare you, but it should be pretty straight forward in at least comprehension of it... I hope):

if (player.health <= 0)

if (player.health <= 0) {
  // if the player's health is 0 or less, then:
  msg ("You were killed or you died.")
  msg ("GAME OVER")
  finish
}

a way to do the above via using the GUI~Editor:

(you're going to need to delete your scripts, and then redo them, using my help below):

run as script -> add new script -> scripts -> 'if' Script -> if [EXPRESSION] player.health <= 0
-> then, -> add new script -> output -> 'print a message' script -> print [MESSAGE] You are dead.
-> add new script -> game state -> 'finish the game' Script

commented Aug 14 by Robert GAC (3 points)
Thanks HK, I will see if I can get this sorted with the help of your advice. I do already have the neccesary script to kill off my player when health reaches 0, but I want to get that extra health out of the staus pane. http://play.textadventures.co.uk/Play.aspx?id=y03paqfxkuoy39rq8tfbqq
commented Aug 15 by Robert GAC (3 points)
It actually turned out to be very simple

I had added a health I didn't need in player attributes, and there was a place in the editor to do the death message and end game - under 'game -player'

If only someone could have simply told me that. At least I found it just by looking harder in the end. But I didn't find the online help at http://docs.textadventures.co.uk/quest/ all that useful, given that ending game at health 0 is not the default.
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...