Define Properties() -- container contains all objects -- create tables of Ids for container paperDoll = { head = 0, armor = 0, r_hand = 0, l_hand = 0, belt_1 = 0, belt_2 = 0, belt_3 = 0, belt_4 = 0 } PersistProperty("paperDoll") backpack = { {0, 0, 0, 0, 0 }, {0, 0, 0, 0, 0 }, {0, 0, 0, 0, 0 } } PersistProperty("backpack") inHand = 0 end Trigger checkInventory() AlertToUser(GetObjectById(self.owner), 1500, "Contained Objects: %d", GetContainerSize(self)) end Trigger pickupObject(object, location) -- handle paperdoll location = location or "backpack" if (location == "backpack") then Debug("Backpack! %d", object.id) if (addToBackpack(self, object.id) ~= 1) then AlertToUser(GetObjectById(self.owner), 1500, "Backpack full!") return end else Debug("PaperDoll: %s", location) if (self.paperDoll[location] ~= 0) then Debug("%s in %s slot, moving to backpack", GetObjectById(self.paperDoll[location]).name, location) -- TODO: should probably let the user specify where to put it if (addToBackpack(self, self.paperDoll[location]) ~= 1) then AlertToUser(GetObjectById(self.owner), 1500, "Backpack full!") return end end self.paperDoll[location] = object.id end PlaceToContainer(self, object) end Trigger dropObject(object, x, y, z, facing) --removeFromPaperDoll(self, object) Debug("Moving to place: %d %d", x, y) ContainerToPlace(self, object, x, y, z, facing) self.inHand = 0 UiSetCursor(GetObjectById(self.owner), -1, 0, 0) end Trigger useItem(location, delay, user) SendTo(GetObjectById(self.paperdoll[location]), "use", delay, user) end Trigger addToBackpack(object) addToBackpack(self, object.id) end function removeFromPaperDoll(self, object) local doll = self.paperDoll for k,v in pairs(doll) do if (v == object.id) then Debug("Dropping from %s", k) doll[k] = 0 return end end end function addToBackpack(self, objectId) --Debug ("?? %d", self.backpack[1][1]) local iRow = 0 local jCol = 0 local rows = 3 local cols = 5 for iRow=1, rows do for jCol=1, cols do --Debug("%d %d: %d BP: ", iRow, jCol, objectId)-- self.backpack[iRow][jCol]) if (self.backpack[iRow][jCol] == 0) then self.backpack[iRow][jCol] = objectId SendTo(self, "refreshSlot", 0, iRow, jCol) --Debug("%d %d: %d", iRow, jCol, objectId) return 1 end end end return nil end