Empty container and list all room objects
rosieclaverton
02 May 2014, 10:56Hi all,
Couple of things I can't work out despite trawling the forums and the wiki.
1) Is there a way to empty all the contents of a container into a specific room? I don't want to list specific objects as the contents of the container depend on the player actions.
2) I want a command that lists all the objects in a room. I think I should be able to use Scope for this but I can't write it properly to turn it into a command.
Couple of things I can't work out despite trawling the forums and the wiki.
1) Is there a way to empty all the contents of a container into a specific room? I don't want to list specific objects as the contents of the container depend on the player actions.
2) I want a command that lists all the objects in a room. I think I should be able to use Scope for this but I can't write it properly to turn it into a command.

jaynabonne
02 May 2014, 19:301) Something like this (untested):
2) An example command with code lifted (more or less) from the Quest core code. I broke out the prefix for clarity.
foreach (obj, GetDirectChildren(container)) {
obj.parent = targetroom
}
2) An example command with code lifted (more or less) from the Quest core code. I broke out the prefix for clarity.
<command>
<pattern>objects</pattern>
<script>
prefix = "Looking around, you notice"
msg(FormatObjectList(prefix, GetNonTransparentParent(game.pov.parent), Template("And"), "."))
</script>
</command>
HegemonKhan
02 May 2014, 19:57if you don't mind working in~with the code:
A. http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S)
B. http://quest5.net/w/index.php?title=Cat ... t#mw-pages (page 2, range: S-Z)
-------------
A. http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S)
B. http://quest5.net/w/index.php?title=Cat ... t#mw-pages (page 2, range: S-Z)
-------------
1. for some Script (Verb, Command, Function, etc):
GetDirectChildren (your_container_Object's_name_with_no_quotes)
~OR~
GetAllChildObjects (your_container_Object's_name_with_no_quotes)
there is the 'multiple' Attribute with Command for 'all', but I don't know yet exactly how it works (how to code it correctly) yet.
<command name="drop_container_objects_into_a_specific_room_command">
<pattern>drop from #object1# into #object2#</pattern>
<script>
drop_container_objects_into_a_specific_room_function (object1,object2)
</script>
</command>
// object1 -> container_object_x
// object2 -> room_x
<function name="drop_container_objects_into_a_specific_room_function" parameters="container_object_x,room_x">
container_object_list = GetDirectChildren (container_object_x)
foreach (object_x, container_object_list) {
object_x.parent = room_x
}
</function>
---------------------------
2. DisplayList ( list , boolean numbers )
ordered list: DisplayList ( list , 0 // or maybe its 1, meh, lol)
unordered list: DisplayList ( list , 1 // or maybe its 0, meh, lol)
-- don't know boolean numbers, whether: 0=true and 1=false, or 1=true and 0=false, lol. I think for 'on~off', it's: 0=off and 1=on
<command name="show_list_command">
<pattern>showlist #object#</pattern>
<script>
container_object_list = GetDirectChildren (object)
DisplayList (container_object_list, 0)
</script>
</command>
rosieclaverton
02 May 2014, 20:30Thank you both - I will try these out!