Exclude Irrelevant Objects from Use Menu

Hello! I'm pretty new to Quest and am not very familiar with its coding documentation - so, I was hoping someone could help me modify a built-in function to meet my needs.

Here's the scenario: I have an object called glass_shard, and glass_shard can only be used on exactly ONE object in a certain room. Under "Use this on (other object)", there is only bubblewrap. There is no other object this will have a meaningful interaction with if it's interacted with, and I purposefully omitted every other object in the room from the list under "Handle Objects Individually". The command bar is disabled in my game, so it's absolutely crucial that a list comes up if a player attempts "Use" with an object in their inventory.

However, when I check the box for "Display menu of objects this can be used on", and I attempt to use glass_shard in my inventory, an ordered list of EVERY object in the room appears - even if the Use/Give attribute is not turned on. I want to limit this selection to ONLY the objects that glass_shard will interact with (only bubblewrap in this case). I assume I need to modify the source for CreateUseMenuList(), but I'm not sure how to modify it to exclude objects that will not have meaningful interactions with the selected inventory object. Here is the code for CreateUseMenuList():

objectlist = NewObjectList()
objectlist = ScopeReachableInventory()
objectlist = ListCombine (objectlist, ScopeReachableNotHeld())
excludelist = NewObjectList()
list add (excludelist, game.pov)
list add (excludelist, object)
candidates = NewObjectList()
candidates = ListExclude(RemoveSceneryObjects(objectlist), excludelist)
return (candidates)

How should I go about modifying this code, so that objects that do not interact with my inventory object will be excluded from the Use List? Basically, I want to add more objects to the excludelist, that meet this point of crtieria. Thanks a lot in advance, and I'd appreciate any advice or further resources!


I was able to find a solution by playing with it myself. I basically decided to take the approach of "instead of excluding things, how about we only include what's actually necessary". Here is the modified CreateUseMenuList() code:

objectlist = NewObjectList()
foreach (key, object.selfuseon) {
  list add (objectlist, GetObject(key))
}
return (objectlist)

Any advice or suggestions beyond this are greatly appreciated. This post can be closed by a moderator if desired!


Hmm… so any time the player tries to use a shard, it gives them a menu with a single item on it? In that case, wouldn't it be simpler to just give the shard a single 'use' verb that says you use it on the bubble wrap, rather than presenting a menu?


If the menu is preferable, I'd suggest not letting the player choose the bubblewrap until they found it. So it would be something like:

objectlist = NewObjectList()
foreach (other_obj, ScopeReachable()) {
  if (DictionaryContains (object.selfuseon, other_obj.name)) {
    list add (objectlist, other_obj)
  }
}
return (objectlist)

That way if the player hasn't found the bubble wrap, it will come up with the standard "there are no objects you can use this on" message (I forget the exact wording),


No no, sorry if I was not clear. This was a specific example in the scenario I gave. It would need to list out any object that said inventory object would be capable of interacting with. If you check out my code snippet in the second message, it ends up giving me exactly what I wanted, which should clarify any ambiguity. I ended up solving the issue.

Note: The idea was that glass_shard can interact with bubble wrap, but not the converse. So, in fact, there's no way to use the glass shard unless the glass shard was already found and in the inventory. The glass shard has the attribute useon, but not the bubble wrap.


Log in to post a reply.

Support

Forums