<command name="putall">
<pattern>put all in #object#</pattern>
<script>
params = NewDictionary()
dictionary add (params, "object2", object)
to_do = ListExclude (ScopeReachableInventory(), object)
found = false
foreach (obj, to_do) {
if (ListContains (ScopeReachable(), obj) and not Contains(object, obj)) {
OutputTextNoBr(GetDisplayAlias(obj)+": ")
found = true
dictionary add (params, "object1", obj)
do (put, "script", params)
dictionary remove (params, "object1")
}
}
if (not found) {
msg ("You have nothing to put in "+GetTheDisplayAlias(object)+".")
}
</script>
</command>
Here's a thought. In my games, I often give objects an alternate alias like "flower" or "ingredient" representing a generic type. So the player can say "get flower", and it will give a disambiguation menu listing all the visible flowers.
But how about this, so you can say put all flowers in vase
or put all food on table
?
<command name="putalltype">
<pattern>put all #text# in #object#</pattern>
<script>
params = NewDictionary()
mtext = LCase(Trim(text))
if (EndsWith(text, "es")) {
mtext = Left (mtext, LengthOf(mtext)-2)
}
else {
if (EndsWith(mtext, "s")) mtext = Left (mtext, LengthOf(mtext)-1)
}
dictionary add (params, "object2", object)
matches = NewObjectList()
partialmatches = NewObjectList()
foreach (obj, ListExclude (ScopeReachableInventory(), object)) {
CompareNames (LCase(GetDisplayName(obj)), mtext, obj, matches, partialmatches)
if (HasAttribute(obj, "alt")) {
foreach (name, obj.alt) {
CompareNames (LCase(name), mtext, obj, matches, partialmatches)
}
}
}
if (ListCount (matches) = 0) {
matches = partialmatches
}
found = false
foreach (obj, matches) {
if (ListContains (ScopeReachable(), obj) and not Contains(object, obj)) {
OutputTextNoBr(GetDisplayAlias(obj)+": ")
found = true
dictionary add (params, "object1", obj)
do (put, "script", params)
dictionary remove (params, "object1")
}
}
if (not found) {
msg ("You have no "+text+" to put in "+GetTheDisplayAlias(object)+".")
}
</script>
</command>
Actually...
<command name="putall">
<pattern>put all #text#in #object#;put all #text#on #object#</pattern>
<script>
params = NewDictionary()
mtext = LCase(Trim(text))
if (EndsWith(text, "es")) {
mtext = Left (mtext, LengthOf(mtext) - 2)
}
else if (EndsWith(mtext, "s")) {
mtext = Left (mtext, LengthOf(mtext) - 1)
}
dictionary add (params, "object2", object)
if (mtext = "") {
matches = ListExclude (ScopeReachableInventory(), object)
}
else {
matches = NewObjectList()
partialmatches = NewObjectList()
foreach (obj, ListExclude (ScopeReachableInventory(), object)) {
CompareNames (LCase(GetDisplayName(obj)), mtext, obj, matches, partialmatches)
if (HasAttribute(obj, "alt")) {
foreach (name, obj.alt) {
CompareNames (LCase(name), mtext, obj, matches, partialmatches)
}
}
}
if (ListCount (matches) = 0) {
matches = partialmatches
}
}
found = false
foreach (obj, matches) {
if (ListContains (ScopeReachable(), obj) and not Contains(object, obj)) {
OutputTextNoBr(GetDisplayAlias(obj)+": ")
found = true
dictionary add (params, "object1", obj)
do (put, "script", params)
dictionary remove (params, "object1")
}
}
if (not found) {
if (mtext = "") {
msg ("You have nothing to put in "+GetTheDisplayAlias(object)+".")
}
else {
msg ("You have no "+text+" to put in "+GetTheDisplayAlias(object)+".")
}
}
</script>
</command>