Recalling Command Menu from Function [Solved]

Anonynn
29 Jul 2019, 06:54Hello everyone ^_^
So I have this...
FUNCTION
do (game, "restmenu")
which I'm trying to have recall my Command Rest's switch menu.
COMMAND REST
Switch
game.restmenu
But I'm getting a lot of "reference object not set to the instance of an object"
Do I have the code wrong for this?
do (objectname,"attributename")
Thanks for your help in advance!
Anonynn.

Anonynn
30 Jul 2019, 18:00Or maybe there is no way to do it? @_@
mrangel
30 Jul 2019, 21:55I'm not sure what you're asking.
Is game.restmenu
a script attribute?

Anonynn
01 Aug 2019, 02:48Hey ^_^
I think so? Sorry, let me try to clarify!
I have a SWITCH script called game.restmenu in my Rest Command which calls a menu of several choices, each of which, call a FUNCTION.
At the end of each those specific FUNCTION(S), I'm trying to recall that Rest Command Switch script game.restmenu again.
Is that clarified?
Anonynn.

Anonynn
04 Aug 2019, 03:03Hopefully, I explained that well enough. If not, let me know and I can clarify further!
Anonynn.

Dcoder
04 Aug 2019, 03:26HandleSingleCommand ("rest")
game.suppressturnscripts = true
Put that at the end of your function(s). That will cause Quest to act as if the player typed "rest". The game.suppressturnscripts = true
keeps the turnscripts from firing an additional time. Keep in mind that this code will produce an endless loop unless there is a way for the player to break out of it.

Anonynn
04 Aug 2019, 05:56I'll try it, although I was hoping to not have the opening dialogue of the Rest Command fire again and again, that's why I was wanting to call just the Switch script within it @_@ Is there a way to do just that?
Thanks for the help so far, Dcoder ^_^
Anonynn.
hegemonkhan
04 Aug 2019, 06:25since the 'switch' is a built-in Script, (maybe there's a way to call it, but this would take internal coding knowledge, if it can be done), you can't call it, but, you can "cheat" by:
have/putting your 'switch' Script within a Function (or it can be within a Script Attribute for an Object, like your 'game.restmenu' Script Attribute)
<game name="NAME_OF_GAME">
<attr name="start" type="script">
// you may be able to call the Command's Script itself (but am not sure):
//
// do (rest, "script")
// or:
// invoke (rest.script)
// if you just want to call the 'switch' script (Function of Script Attribute of Object):
//
// as a Function:
//
// SWITCH_FUNCTION
//
// or, as a Script Attribute of an Object:
//
// do (game, "SWITCH_SCRIPT_ATTRIBUTE")
// or:
// invoke (game.SWITCH_SCRIPT_ATTRIBUTE)
<attr name="restmenu" type="script">
// WHATEVER scripting
</attr>
<attr name="SWITCH_SCRIPT_ATTRIBUTE" type="script">
switch (XXX) {
case ("XXX") {
// XXX
}
}
</attr>
</game>
<command name="rest">
<pattern>rest</pattern>
<script>
// as a Function:
//
// SWITCH_FUNCTION
//
// or, as a Script Attribute of an Object:
//
// do (game, "SWITCH_SCRIPT_ATTRIBUTE")
// or:
// invoke (game.SWITCH_SCRIPT_ATTRIBUTE)
do (game, "restmenu")
// or:
// invoke (game.restmenu)
</script>
</command>
<function name="SWITCH_FUNCTION">
switch (XXX) {
case ("XXX") {
// XXX
}
}
</function>

Anonynn
04 Aug 2019, 07:04Oooh that's smart.
Like, copy the Switch Menu from the Command and put that menu into a Function and then from the other Functions call that Function to recall the menu. I'll try it and let you know!
EDIT
That worked ^_^ Thank you all so much!
Anonynn.