How to remove all of the player's items in inventory? (SOLVED)

There is part in my game where the player is captured and has all their possessions taken away, obviously its easy to remove item x, using the 'remove from inventory' script but I don't know what the player will still be carrying at this point and just want to remove everything.

I'm using the online editor btw.


Will the objects be retrievable at a later point? If not the easiest way to do it is to swap the PC that is carrying stuff with a PC that is carrying nothing.
Otherwise you need to know where the objects will be ending up.

no they are gone for the rest of the game, by PC you mean player character? how to I create a second one? And how do I swap from one to the other? Sorry for noob questions!

Go though the inventory, call RemoveObject on each object. In code:

foreach (o, ScopeInventory()) {

Thanks Pixie, but I don't know what items the player will be carrying at that point, or does it not matter? Do I just paste that code in as it is?

If the objects don't need to be retrievable then the easiest way is to abandon the player object carrying the objects for a player object carrying nothing. Here's the quest documentation on player objects:

I can write some code for this (if nobody beats me to it) when I'm not AFK.

OK, if I do that do I need to place the other 'player' in the room where the currently player is or does that happen automatically? Do I need to make the current player invisible when I do this.


I always have a room in my game called 'junk' (you can call it anything). The room isn't accessible in the game, it merely serves to hold objects I move around for various scene changes etc.

So you could have your second player object in this room. When they get arrested you could code to have the player object change to the one in the room 'junk' (that has no inventory) then move that player object to the room 'cell' triggering code that you've been thrown into a cell. You then move the original player object to the room 'junk' so it isn't in the game anymore.

got ya! Thanks.

Let us know how you get on. I can write a sample game if you can't get it to work.

This worked perfectly, many thanks for your time, people on this forum are damn nice

No worries. Good luck with your game. :)

the 'ScopeInventory' Function gets/returns the built-in 'inventory' Objectlist Attribute for your 'player' Player Object. This special hidden 'inventory' Objectlist Attribute, holds the object references (names) of all of the Objects contained within your 'player' Player Object, as it's items (Values).

the 'foreach' Function iterates through a List Attribute (aka, through its items/values, for this case, your object references: names, of all of the Objects contained within the 'player' Player Object), allowing you to do (or not do) whatever script/action for in this case, for each of your Objects in your 'player' Player Object.

here's an explanation of how Lists and iteration (usually via quest's 'foreach' Function, in quest) work:

<game name="example">
  <attr name="start" type="script">
    foreach (team_member, team.member_list) {
      do (team_member, "run_laps")
      // it's effectively doing this:
      // team_member = joe
      // do (team_member, "run_laps")
      // do (joe, "run_laps")
      // team_member = jeff
      // do (team_member, "run_laps")
      // do (jeff, "run_laps")
      // team_member = john
      // do (team_member, "run_laps")
      // do (john, "run_laps")
      // result/output:
      // Joe runs laps
      // Jeff runs laps
      // John runs laps

<object name="team">
  <attr name="member_list" type="objectlist">joe;jeff;john</attr>

<object name="joe">
  <attr name="run_laps" type="script">
    msg ("Joe runs laps")

<object name="jeff">
  <attr name="run_laps" type="script">
    msg ("Jeff runs laps")

<object name="john">
  <attr name="run_laps" type="script">
    msg ("John runs laps")

  <defaultexpression>It can't run laps!</defaultexpression>

and here's a bit on having/using multiple Player Objects (you're only in control of one of them at a time, of course, but you can switch between them):

will go into more details/explanation if you're interested in this...

and here's more detailed guide on using Lists/Dictionaries:

and sample code (but it's old/poor/bad code) of an application of List/Dictionary usage:

I'd already posted that link... :-p

oops, didn't see it in your post, my bad... oh well

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