Control computer

(Desktop Version)
I have a room with some stasis pods in it.
I just added an object called computer.
Enabled the feature use/give on the object 'computer'
On the object 'computer' under the use/give tab i checked the box 'display menu of objects this can be used on'
Under "Use this on (other object)" i changed action to handle object individually and added what i wanted in there.

Everything's working great except for one small detail.

My character is wearing an object i created (jumpsuit).

When i type use computer. The first object on the list is the jumpsuit i'm wearing. Then after that is all of the stasis pods.

How do I get the clothes off the auto generated menu? How is this menu generated? I was actually surprised it listed all the stasis pod in room without telling it to do so somehow.


I was looking through the code and found:
selfuseon type="scriptdictionary"

I image this is where the menu is coming from?

How do I mod this to not include my clothes or any other object in the room other than the pods?

I want it to only list the 6 stasis pods in the room.


You need to override the CreateUseMenuList function. This will be sent the object being used (the computer) and needs to return an object list with each pod. I would suggest the code checks if the object is the computer first. If it is, return the list of pods. If not, do the default code.

objectlist = NewObjectList()
if (object = computer) {
  list add (objectlist, pod1)
  list add (objectlist, pod1)
  return (objectlist)
}
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)

It works!!

\o/

You're the best. :] Thank you


It does, however, seem a little awkward having a special case for that one room.

I'm wondering if it might not be advantageous for the default "use" command to include this type of functionality. Perhaps calling GetScope() to get the list of valid objects? (which would work better if the changecommandscope script on object1 was run when determining the scope for object2)

This is why I thought the relation between GetScope and GetScoping is backwards; but at the time I couldn't think of an example. I think it should be possible for an object to have an attribute which overrides the command's scope for "use X on Y" or "give X to Y" commands. Maybe scopefor_use or something?

I'm kind of rambling here. But I think I can see some benefit in something like this:

  <function name="GetScope" parameters="variable, value, objtype" type="objectlist"><![CDATA[
    items = NewObjectList()
// changes start here
    scopestrings = NewStringList()
    if (HasAttribute (game.pov, "currentcommandresolvedelements")) {
      foreach (key, game.pov.currentcommandresolvedelements) {
        value = DictionaryItem (game.pov.currentcommandresolvedelements, key)
        if (TypeOf (value) = "object") {
          if (HasString (value, "scopefor_"+game.pov.currentcommandpattern.name)) {
            list add (scopestrings, GetString (value, "scopefor_"+game.pov.currentcommandpattern.name))
          }
        }
      }
    }
    if (HasString(game.pov.currentcommandpattern, "scope")) {
      list add (scopestrings, game.pov.currentcommandpattern.scope)
    }
    if (ListCount(scopestrings) > 0) {
      scoping = GetScoping(Join (scopestrings, "|"), variable)
// changes end here
      foreach (partscope, Split(scoping, ";")) {
        switch (partscope) {

This would mean that if you type "use spanner on br", and the spanner has an attribute "scopefor_use" with the value "inventory", the disambiguation menu would only consider objects in the inventory starting with "br".

Not sure how easy it would be to have CreateUseMenuList() just call GetScope() so that this menu works the same way. Would the game.pov.currentcommand* variables still be in scope?


Would it not be easier for CreateUseMenuList to check if the object has a scopeforuse script, and if it does, use that to get an object list, other do the default?

Same for CreateGiveMenuList.


If you want scopeforuse to be a script, yes. I was thinking that for most users (and most use cases), a string formatted like the command's scope string would be more intuitive. But as it's currently set up, GetScope takes game.pov.currentcommandpattern.scope directly, meaning that you can't run it on a string from somewhere else.


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

Support

Forums