Object to disappear

Hi 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


Have 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)
}

conceptually:

  1. need a list of room's original items
  2. need a list of room's current (original + possibly new) items
  3. 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>

Not 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.


are 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.


When 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)


I 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.


Perhaps you can create a local command "drop #object#" in that room executing a script like this:

msg (object.name +  " disappears")
MoveObject (object, room2)

That's great Pertex, that did the trick, I didn't know you could localise a command like that. Thanks again


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

Support

Forums