After 3 weeks I have my first game done, but I don't know how to set (multiple) conditionals to trigger 'end the game'.
The player has to return to their home (room) and if they have all the items they need in their inventory the game ends.
the conditionals is via using the 'if' Script, and you literally can use 'and' or 'or' (in your case, I believe you want 'and', if I understand correctly) for connecting as many conditionals as you want. Though the caveat is that each conditional must be a full statement.
------------------------------
a full quest code statement has this form/syntax:
NAME_OF_OBJECT.NAME_OF_ATTRIBUTE
~ or ~
NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION
---------------------
to end the game:
in code: finish
in the GUI~Editor: (run as script) -> add new script -> '?game?' section/category -> 'finish the game' (or something like this) Script
-------------
so, for an example:
'room' Object -> '?Scripts?' Tab -> 'onenterroom' Script -> (see below)
(run as script), or set the 'onenterroom' type from [string] to [script] -> add new script -> 'scripts' section/category -> 'if' Script -> (see below, for an example)
if [EXPRESSION] NAME_OF_ITEM_1.parent = player and NAME_OF_ITEM_2.parent = player and NAME_OF_ITEM_3.parent = player and ... etc etc etc conditionals (or less)
// just to make clear the full statements for you, using parenthesis:
// if [EXPRESSION] (NAME_OF_ITEM_1.parent = player) and (NAME_OF_ITEM_2.parent = player) and (NAME_OF_ITEM_3.parent = player)
then,
-> add new script -> '?game?' section/category -> 'finish the game' (or something like this) Script
-------------------
an in-code example:
<object name="room">
// actually, I'm not sure how the 'onenterroom' Script looks/works (and am too lazy to open up quest to find out), so the below syntax/header/signature/etc for it, could be wrong:
<attr name="onenterroom" type="script">
if (ball.parent = player and book.parent = player and hat.parent = player and candy.parent = player and wallet.parent = player and necklace.parent = player) {
msg ("Congratulations, you won the game!") // forgot to mention putting in (adding) this 'msg' (Print a message) Script in the GUI~Editor section above
finish
}
</attr>
</object>
if you use the 'onenterroom' Script, then you'll have to have the required items in your inventory, ALREADY BEFORE, you then move to/into the 'room' Room Object. You can't put the item into your inventory while in the 'room' Room Object, as that doesn't trigger/re-trigger the 'onenterroom' Script, which is what does the checking of if you got the items in your inventory, determining whether you win the game or not.
My solution:
Optional:
It's been a while since I tinkered on Quest, but this is a solution I became familiar with and used it quite often in my games. Someone out there, if this is not a reasonable solution, please point out my errors or a simpler way to get it done. I guess the complexity of the game-end script here is largely dependent on how many objects are needed in the inventory to win the game.
If you have any questions, please let me know! Happy Gaming!
XanMag
err, whoops on my part...
XanMag's mentioning of using 'afterenteringroom' Script would be better than my worse use of 'onenterroom' Script, my apologies (I'm not that familiar with the built-in stuff).
... or maybe it doesn't matter... which one you use... meh... Pixie or Jay can jump in on which one would be better, as they understand this stuff way better than I, lol.