Unlocking Exits

USGOVGroup3
I am trying to make a game where you cannot go into the next room without correctly answering the question, but I am new to this program and cannot figure it out. Could you please tell me if this is possible and how to do it?
Thanks!

HegemonKhan
I'm still not too familiar with the built-in scripts and etc of quest, and I've been confused with the 'open~close' and 'unlocked~locked' features in quest too when I was working with the GUI~Editor long ago, but I'll give it a go regardless, lol:

here's what it's generally (an example, it's a bit more expansive~complex though) like in code:

<function name="question_function">
msg ("What is your choice?")
msg ("(1) red or (2) blue")
get input {
if (IsInt (result) = true)) {
if (ToInt (result) = 1) {
Object.Exit.Locked = false
Object.Exit.IsOpen = true
msg ("You unlock and open the door")
} else if (ToInt (result) = 2) {
msg ("Sorry, you chose the wrong answer, and die a gruesome death.")
msg ("GAME OVER")
finish
} else {
msg ("Wrong input, try again.")
question_function
}
} else {
msg ("Wrong input, try again.")
question_function
}
}
</function>


if you need help figuring out what scripts to add via using the GUI~Editor, let me know and I'll help you.

--------------

Code ~~~ GUI~Editor (run as a script -> add a script -> see below)

msg ("XXX") ~~~ Output -> Print a message -> [MESSAGE] for just text, OR: [EXPRESSION] for variable usage + text

if (XXX) { scripts } else if (XXX) { scripts } else { scripts } ~~~ Scripts -> if -> [EXPRESSION] as this allows you to type in what you want, then (script), else if (script), then (script), else (script)

'question_function' ~~~ Output or Scripts (can't remember which category it is under, lol) -> call function -> Name: 'question_function', Parameters: (leave blank, unless you know what are params and how to use them)

etc etc etc

jaynabonne
To unlock an exit, either use:

UnlockExit(exitname)

or

exitname.locked = false

In order to do this, you *must* name your exit. Then you can reference it by name. Exits don't have names by default. After you create the exit, go back and click on the exit in the room that you wish to control (since exits can run in both directions), and then give it a name. Then when you go in to the GUI editor and select UnlockExit, the exit name will show up in the drop down.

A note on the question handling: it's much easier and less painful (in my opinion) to use a menu if you're going to do a multiple choice question. If you do want to use "get input", you can simply compare the result to "1" or "2" as strings rather than doing all the ToInt conversions.

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

Support

Forums