Create new verbs for npc

Like if you ask for permisikn to hug during part of its 'speak to' script, it makes a new verb for the npc object.


The usual way to do that would be to make the verb to start with, but have it check some flag to see if you have permission, and respond accordingly.

If you really want the character not to have the verb initially, you can create it like any other script attribute:

john.hug => {
  msg ("You hug him. He seems happy.")
}

This will only work if there is already a verb named "hug". In the web editor, a verb is created the first time you give it to any object, and can't be deleted. So you could create the verb and then remove it again, so that you can create it during the game.

If you want to make the verb appear in the menu when you click on John, that's a separate thing. You can add it like this:

list add (john.generatedverbslist, "Hug")

That just adds it to the menu, and is completely separate from whether he has the verb or not.

If you give the character a verb but you want to hide it from the menu, you could put something like this in your start script:

GetDisplayVerbs(john)
list remove (john.generatedverbslist, "Hug")

and then add it back to the list when you want it to be visible.


So im going to try putting hug as a verb on npc and putting that 'list remove' as an instalation script with an if to 'list add'....

Edit: that dosent hide the verb from in-game menu...


Each object in game has a displayverbs list and an inventoryverbs list.

You can change a npc's displayverbs list and inventory verbs list.

npc.displayverbs = Split("Look at;Speak To", ";")
npc.displayverbs = Split("Look at;Speak To;Hug", ";")

There are 3 separate lists of verbs.

  • displayverbs and inventoryverbs can be changed in the editor
    • inventoryverbs is for objects in the inventory, and displayverbs for objects that aren't
  • generatedverbslist contains all the verbs on the object's "Verbs" tab.

Which of these lists is used in the menu will depend on your settings:

  • If you choose "Disable automatically generated display verb list for this object" for the object, or disable "Automatically generate object display verbs list" for the game, it will only use displayverbs and inventoryverbs.
  • If you select "Only display verbs from this object's Verbs tab" for the object it will only use generatedverbslist.
  • Otherwise it will combine both lists.

So you need to look at which options you have chosen, and see which lists "hug" is on. You can use it to remove it from the list initially, and add it again once the verb is enabled.

But sometimes using list add and list remove on these lists won't work.

  • generatedverbslist is only created when it is needed. If you want to change the menu before the player sees the object, you will need to run the GetDisplayVerbs command first (as I showed in my example above)
  • Because of the way inheritance works in Quest, if displayverbs and inventoryverbs haven't been modified in the editor, you will need to do the line object.displayverbs = object.displayverbs before you can add or remove items.

If that doesn't help, could you share your game (on this website, or on pastebin) so we can take a look at the code? It's easier to work out what the problem is if I can see your code.


Just realised there was a typo in my first post above. It should be Hug, not hug, in the verbs list. The remove command will only work if you type the verb exactly the same.

The hazards of typing on my phone. Sorry about that.
I would have expected that to give an error when the game starts, saying that hug isn't in the list… that would have made it easier to spot the problem.


I got 'only display from verbs tab' on

So i need to do

GetDisplayVerbs(john)
list remove (john.generatedverbslist, "Hug")

Where though? At start of game? Or on the npc?

Then

list add (john.generatedverblist, "Hug")

At the point where it want it available?

Edit: putting quotes around Hug in lisd add seems to cause internal error...


Where though? At start of game? Or on the npc?

Any time before the player gets a chance to see the menu. The start of the game is usually a good choice.

Edit: putting quotes around Hug in lisd add seems to cause internal error...

And that should work. Can you show us the game so we can see what the problem is?
Does it just say internal error; no more detailed message?


I am hesitant to link to game as it has NSFW elements...

So i'll just copy/paste relevant parts of codeview

As npc object's only installation script:

GetDisplayVerbs (Mayuri)
list remove (Mayuri.generatedverblist, "comply")

At a point during talk to spript (glossing over a few other scripts that work without error and have no intended effect on npc verb list)

list add (Mayuri.generatedverblist, comply)

This results in an error in game :
"Unrecognized list type"


The name is generatedverbslist. It seems illogical to me, but that's what Quest names it.

Does that work any better?

The verbs that are automatically added by running GetDisplayVerbs will usually have the first letter capitalised. So I think you need the initialisation script to be:

GetDisplayVerbs (Mayuri)
list remove (Mayuri.generatedverbslist, "Comply")

and the later script:

list add (Mayuri.generatedverbslist, "Comply")

In the second case, you could put comply rather than Comply, and it will appear that way on the menu.
In the first case, putting comply will not remove anything because that's not what's on the list.

You do need to remember the quotes.


Just tried that, internal error after changing the later script with quotes

Ill try that npc.displayverbs thing since i dont want the player to carry npc like piggyback ride.


Mayuri.displayverbs = Split("Look at;Speak To;Comply", ";")

Isnt working either?


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

Support

Forums