Recalling Command Menu from Function [Solved]

Hello 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.


Or maybe there is no way to do it? @_@


I'm not sure what you're asking.

Is game.restmenu a script attribute?


Hey ^_^

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.


Hopefully, I explained that well enough. If not, let me know and I can clarify further!

Anonynn.


HandleSingleCommand ("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.


I'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.


since 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>

Oooh 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.


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

Support

Forums