Object to disappear

Doctor Agon
24 Apr 2017, 20:50Hi All. I've got a room in my adventure, where I want it so that any item dropped within that room disappears. I thought a turn script might be the way to go, but can't seem to find the right option. Any help would be much appreciated
The Pixie
24 Apr 2017, 21:12Have the turn script in the room, enabled from the start. Paste in this code (it iterates through all objects in the room, removing them all):
foreach (obj, GetDirectChildren(player.parent)) {
RemoveObject(obj)
}
hegemonkhan
24 Apr 2017, 21:20conceptually:
- need a list of room's original items
- need a list of room's current (original + possibly new) items
- using iteration (foreach): if the room has new items (new items: items different from the room's original items), 'RemoveObject' or 'destroy' those new items
http://docs.textadventures.co.uk/quest/guides/using_lists.html
http://docs.textadventures.co.uk/quest/scripts/foreach.html
http://docs.textadventures.co.uk/quest/functions/contains.html
http://docs.textadventures.co.uk/quest/functions/listcontains.html
http://docs.textadventures.co.uk/quest/scopes.html
http://docs.textadventures.co.uk/quest/functions/corelibrary/removeobject.html
http://docs.textadventures.co.uk/quest/scripts/destroy.html
example:
<object name="example_room">
<attr name="original_objects_in_room_list" type="objectlist">ball;shoe;hat</attr>
<turnscript name="local_turnscript">
<enabled />
<script>
foreach (current_object_in_room_variable, ScopeVisibleNotHeld()) {
if (not ListContains (original_objects_in_room_list, current_object_in_room_variable)) {
RemoveObject (current_object_in_room_variable)
}
}
</script>
</turnscript>
</object>
<object name="ball">
<attr name="parent" type="object">example_room</attr>
</object>
<object name="shoe">
<attr name="parent" type="object">example_room</attr>
</object>
<object name="hat">
<attr name="parent" type="object">example_room</attr>
</object>

Doctor Agon
24 Apr 2017, 21:54Not really had the effect I was looking for. Either produced a load of error messages, or I was mugged. Unless I've typed in something wrong. I want to be able to hold onto the items I have in my inventory(items I'm carrying), then if I drop an object in the room, it disappears.
hegemonkhan
25 Apr 2017, 03:36are you talking about trying my code? it should work (you'd have to of course adjust it for what you're doing and/or are using, a bit)... unless I'm over-looking something (or used the wrong Scope, I still have such trouble understanding the difference between them, laughs). My code should do exactly what you've described that you want it to do.

DarkLizerd
25 Apr 2017, 03:44When dropped, move the item to an inaccessible room...
(don't know the code required... yet)
In the UI, under drop, there is a section called:
After dropping the object:
Add this code:
Move object [object] (the object you are dropping) to [object] (your room of lost stuff)
or in code view ( and I used the newspaper from the tut game, and put it in the bin in the kitchen)
MoveObject (newspaper, bin)
jmnevil54
25 Apr 2017, 03:51I think inventory objects and room objects have different codes.
You could just specify that all object under the parent player are kept.
Or just give all the objects you want to throw away a certain name, and all the ones you went to keep another name.
Pertex
25 Apr 2017, 11:32Perhaps you can create a local command "drop #object#" in that room executing a script like this:
msg (object.name + " disappears")
MoveObject (object, room2)

Doctor Agon
25 Apr 2017, 20:10That's great Pertex, that did the trick, I didn't know you could localise a command like that. Thanks again