Container script move all children here?
Jennifer Wren
14 Mar 2024, 14:57I have three containers. need a script to move all children to here (the room).
I think I will just add a function that lists every game object and if reachable moveobjecthere plus msg.
I think this will work well enough fory current game idea, only because it is a limited game, but a greater project would really need to have more specific script.
I know someone else has to know how it's done.
Any ideas?
mrangel
14 Mar 2024, 20:25So you want to move all objects from a container to the player's location?
Probably something like:
foreach (obj, GetDirectChildren (container)) {
obj.parent = game.pov.parent
}
Or, if you want objects in containers inside that container to be moved,
foreach (obj, GetAllChildObjects (container)) {
obj.parent = game.pov.parent
}
Or if you want the contents of all reachable containers to be moved (it's a little ambiguous the way you phrased it):
foreach (obj, ScopeReachableNotHeld ()) {
obj.parent = game.pov.parent
}
or to include the contents of containers the player is carrying, but not the containers themselves:
foreach (obj, ScopeReachable ()) {
if (not obj.parent = game.pov) {
obj.parent = game.pov.parent
}
}
Jennifer Wren
15 Mar 2024, 17:50Amazing! Thank you for these. I will tell you when I use it. I have to finish another part of the detail work in the game first. I will soon use your script though. Thanks.
Jennifer Wren
18 Mar 2024, 03:41This is a great script. It works! Thanks.
I'm using the very first you gave me. I love that I have all four, though, for future reference, just in case.
Jennifer Wren
02 Apr 2024, 20:42I get this occasionally. Does it have anything to do with the wind? I mean it must. Or is it my listing objects in room?
Error running script: Error evaluating expression 'RemoveSceneryObjects(GetDirectChildren(parent))': Collection was modified; enumeration operation may not execute.
Error running script: Object reference not set to an instance of an object.
Is it connected to my listing objects in room?
s = FormatObjectList ("Here there is ", GetNonTransparentParent(game.pov.parent), Template("And"), ".")
msg (s)