Put MULTIPLE OBJECTS in Container ("put" command mod for Quest 5.8)

This version of the put command is not included in Quest 5.8!

This is a mod.


mrangel came up with a PUT ALL IN #CONTAINER# command less than twenty-four hours ago.

...but, since then (or possibly at the same time), Pixie added a new attribute for commands: allow_all.

I immediately added this attribute to put and tried PUT BAT AND BALL IN BAG, and Quest yelled at me.

So, I looked at wear, and I added multiple to put going by that script. (I think allow_all is still doing something, but I'm not positive.)


TRANSCRIPT

Transcript enabled for:
TITLE: All Tester 580
VERSION: 1.0
IFID: c85bd44a-a9a0-4c73-9c15-4ac514d2b494



[ Enter SCRIPT OFF to disable the transcript. ]

> put all in bag
bat: You are not carrying it.
ball: You are not carrying it.

> get all
bat: You pick it up.
bag: You pick it up.
ball: You pick it up.

> put all in bag
bat: Done.
ball: Done.

> i
You are carrying a bag (containing a bat and a ball).

> get bat
You pick it up.

> get ball
You pick it up.

> i
You are carrying a bat, a bag and a ball.

> put bat and ball in bag
bat: Done.
ball: Done.

> i
You are carrying a bag (containing a bat and a ball).

> put bag in bag
You can't do that.

> get bat and ball
bat: You pick it up.
ball: You pick it up.

> i
You are carrying a bat, a bag and a ball.

> put bat and bag in bag
bag: You can't do that.
bat: Done.

> i
You are carrying a bag (containing a bat) and a ball.

> get bat
You pick it up.

> drop all
bat: You drop it.
bag: You drop it.
ball: You drop it.

> put bag and bat in bag
bag: You can't do that.
bat: You are not carrying it.

> get all
bat: You pick it up.
bag: You pick it up.
ball: You pick it up.

> put all in bag
bat: Done.
ball: Done.

> put bat and bag in bag
bag: You can't do that.
bat: It is already there.

> put all in bag
bat: It is already there.
ball: It is already there.

> i
You are carrying a bag (containing a bat and a ball).

MODIFIED put command

  <command name="put">
    <pattern type="string"><![CDATA[^put (?<object1>.*) (on|in) (?<object2>.*)$]]></pattern>
    <scope>object1=inventory|object2=container</scope>
    <allow_all />
    <script><![CDATA[
      if (not IsDefined("multiple")) {
        multiple = false
      }
      if (multiple and ListCount(object1) = 0) {
        msg ("You're not carrying anything.")
      }
      else if (multiple and ListCount(object2) > 1) {
        msg ("You'll have to pick one target.")
      }
      else {
        object2 = ListItem(object2, 0)
        if (not LCase(ToString(DictionaryItem(game.pov.currentcommandvarlist,"object1"))) = "all" and ListContains(object1,object2)) {
          if (ListCount(object1)>1) {
            OutputTextNoBr (GetDisplayAlias(object2) + ": ")
          }
          msg (Template("CannotDoThat"))
        }
        foreach (obj, ListExclude(object1, object2)) {
          if (multiple) {
            OutputTextNoBr (GetDisplayAlias(obj) + ": ")
          }
          // put object1 in/on object 2
          canbedropped = true
          if (HasBoolean(obj, "drop")) {
            if (not obj.drop) {
              canbedropped = false
            }
          }
          if (obj.parent = object2) {
            msg (DynamicTemplate("AlreadyThere", obj))
          }
          else if (obj = object2) {
            msg ("You can't do that.")
          }
          else if (not ListContains(ScopeInventory(), obj)) {
            msg (DynamicTemplate("NotCarrying", obj))
          }
          else if (not canbedropped) {
            msg (DynamicTemplate("ObjectCannotBeStored", obj))
          }
          else if (not ListContains(ScopeReachable(), obj)) {
            msg (DynamicTemplate("ObjectNotOpen", GetBlockingObject(obj)))
          }
          else if (not ListContains(ScopeReachable(), object2)) {
            msg (DynamicTemplate("ObjectNotOpen", GetBlockingObject(object2)))
          }
          else if (not object2.container) {
            msg (Template("CannotDoThat"))
          }
          else if (not object2.isopen) {
            msg (DynamicTemplate("ObjectNotOpen", object2))
          }
          else {
            if (GetBoolean(object2, "hidechildren")) {
              object2.hidechildren = false
            }
            params = NewDictionary()
            dictionary add (params, "object", obj)
            dictionary add (params, "destination", object2)
            if (HasScript(object2, "addscript")) {
              do (object2, "addscript", params)
            }
            else if (HasScript(obj, "drop")) {
              do (obj, "drop", params)
            }
            else {
              obj.parent = object2
              msg (Template("Done"))
            }
          }
          // must be carrying object1
          // item cannot be dropped
          // object1 must not be inside a closed container
          // object2 must not be inside a closed container
          // object2 must be an open container or surface
        }
      }
    ]]></script>
  </command>

At present, "multiple" has enough issues that I'd rather work with separate "all" commands.
(Did you see my version with "all flowers" and similar? I like that, and I think I can see a way to put it into the parser to work with any command… at some point when I don't have 75 pages of a novel to proofread and correct before the end of the day)


In 5.8, if you flag a command with "allow_all" it should handle ALL - as you found out. However, the special variable "object" in the command script will then be a list of objects rather than a single object (plus there will be Boolean "multiple").


However, the special variable "object" in the command script will then be a list of objects rather than a single object

I found that out when I added allow_all to "put". It was an adventure!


plus there will be Boolean "multiple"

I haven't completely given up on QuestJS, which is why I add this to any command with multiple involved:

if (not IsDefined ("multiple")) multiple = false

Otherwise, a single object throws an error once compiled to JS.


If you can't override commands (can online users override commands?):

https://github.com/KVonGit/QuestStuff/wiki/Command--PUT-MULTIPLE-OBJECTS-IN-CONTAINER


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

Support

Forums