Give Command Should Generate Menu, but of course it doesn't...

Dcoder
12 Dec 2016, 11:17

I copied the Give command and modified it. I want it to work with 2 objects (object1 and object2). Under the Give Command tab, the Pattern = Regular Expression, and it says:

^give (?

The above is what it said by default; I didn't change it. Here is the modified script:

if (object1.parent <> player) {
  msg ("You can only give things that you are carrying.")
}
else {
  if (not IsDefined("object2") or object2 = null) {          <<<-------Starting here,----------
    GiveToMenu = NewStringList()
    foreach (item, ScopeReachable) {                       <<<-------this section----------
      list add (GiveToMenu, item.name)
    }                                                      <<<---------doesn't register------
    ShowMenu ("To whom?", GiveToMenu, true) {
      object2 = GetObject(result)                          <<<--------------------------------
    }
  }
  if (not HasAttribute(object2, "animate")) {
    msg ("Silly lout, you can't give something to an inanimate object.")
  }
  else if (object1 = object2) {
    msg ("You can't give something to itself!")
  }
  else if (object2 = player) {
    msg ("You already have that!")
  }

I left out some minor code at the bottom, as it works and is not relevant. Strangely, everything in the above code works, except for the menu section (starting from where it says "Starting here,"). The menu doesn't even come up -- no error messages, like that section doesn't even exist. I want the menu to show up if the player types "give widget" but leaves out object2. Instead, the program says "You can't give it." If you type "give widget to somebody", it works.

Where is the code wrong? Thanks in advance.


Dcoder
12 Dec 2016, 11:23

This forum will not post correctly the above part where it says what the Regular Expression says. But it is whatever the Quest default is.

^give (?


Dcoder
12 Dec 2016, 11:24

When I post reply, this forum cuts it off.


The Pixie
12 Dec 2016, 11:39

I think you need two different commands. Leave the GIVE X TO Y as it is, and create a new GIVE X command. The way commands work is then try to match the text first, so GIVE X will fail to match the existing pattern, as it is missing the second part.


Dcoder
12 Dec 2016, 12:04

I copied the GiveSingle command and didn't change it. If I type "give widget", it still says "You can't give it.". Didn't want to modify this command as it looks like a mess, haha. Regular Give command still works the same.

By default, the Give and GiveSingle commands come with a new game. But if you type "give xyz" in a new game, it says "You can't give it". Shouldn't Quest generate a menu by default, since that's built into the GiveSingle command?


The Pixie
12 Dec 2016, 13:34

For the widget, got to the Features tab, and tick Use/Give. Then on the Use/Give tab, tick "Display menu of object this can be given to". Then trying giving it.


Dcoder
12 Dec 2016, 16:15

The use/give tab does work, but then I have to adjust those settings for every takeable object in the game. I was hoping to get the object2 menu to show up as a command for every takeable object. Alas!