How do you kill or disable the player?
JustinHopewell
11 Oct 2016, 02:00After finishing the text adventure tutorial, I wanted to make a few test rooms with some instant death traps. I realized, though, that I have no idea how to "kill" a player or disable them from continuing to play the game after they triggered a trap. I could have a message displaying that they died, but nothing would stop them from continuing to play the game.
Basically what I want to do is make it so the only thing they can do after dying is
-
Reload a previous save
and/or
-
Start over from the beginning.
I understand that there is not an easy way to do a restart other than closing the program and reopening it, and that's fine. I just want to make sure they can't keep progressing through the game after they "die".
Thanks,
Justin
hegemonkhan
11 Oct 2016, 03:38quest has a built-in Function for ending the game:
http://docs.textadventures.co.uk/quest/scripts/finish.html (in code)
in the GUI~Editor:
add new script -> 'game something or whatever' section/category -> 'Finish the game (or something like this)' Script
you can just have some action/event (scripting) kill the player (for example: entering 'blah' room kills the player) or you can of course give your player 'life/health/hp/etc' Integer Attribute, which upon becoming zero or less, kills the player, for example, in code:
if (player.current_life <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
}
you can use the documentation, to see most of what quest can do, even if you don't know coding:
http://docs.textadventures.co.uk/quest/
specifically (well, there's a few more links, but these are the main ones for the most part):
http://docs.textadventures.co.uk/quest/scripts/
http://docs.textadventures.co.uk/quest/functions/ (categorical order)
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (alphabetical order)
and then try to find that 'add new script -> blah blah blah' option within the GUI~Editor
P.S.
XanMag has a "tutorials and templates" (tutorial 2) demo game for people, to help with the still big transition from the tutorial to making your own game.
Also, onimike, has youtube tutorial videos, as well
or, if you want to jump into understanding the 'bread and butter' (Attributes and the 'if' Script usage) of game making/coding:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
ask, if you need any help or need any explanation of anything.
JustinHopewell
11 Oct 2016, 04:55Hey thanks for all that. That second tutorial sounds especially useful, but I'm gonna check all of this out.
hegemonkhan
11 Oct 2016, 08:16also, for more guides:
http://docs.textadventures.co.uk/quest/guides/ (guides)
http://textadventures.co.uk/forum/samples (more guides: libraries and code samples)
and this is a good starting point for a quick taste of coding (though it sounds like you do know some coding already, but it's still a good guide, as it helps with doing the often game-needed 'character creation' stuff, in the GUI~Editor, and introduces you to using Lists/Arrays and getting user typed-in input, if you're not familiar with this coding/quest-coding stuff):
http://docs.textadventures.co.uk/quest/guides/character_creation.html
again, ask about anything you need help with or explanation upon