local position = Position(100, 100, 7)
local tile = Tile(position) -- or Tile(x, y, z)
if tile then
local backpack = tile:getItemById(backpackId)
if backpack then
backpack:addItem(itemId, count)
end
end
local backpack = Game.createItem(backpackId, 1, position)
if backpack then
backpack:addItem(itemId, count)
end
I can be talking nonsense, but that way he creates the bau!, I wanted a script that would take a container that already exists on the map and add the item inside it.LUA:local backpack = Game.createItem(backpackId, 1, position) if backpack then backpack:addItem(itemId, count) end
local position = XXXX -- Position where container is supposed to be
local tile = Tile(position)
local item
local itemId = XXXX -- Container
local id = XXXX -- Item added to container
if tile then
if tile:getItemCountById(itemId) == 0 then
print("Container not found")
end
if tile:getItemCountById(itemId) == 1 then
item = tile:getItemById(itemId)
end
if item then
item:addItem(id, 1)
end
end
local position = Position(100, 100, 7)
local tile = Tile(position) -- or Tile(x, y, z)
if tile then
local backpack = tile:getItemById(backpackId)
if backpack then
backpack:addItem(itemId, count)
end
end
What the guy shows in the previous comment is fine, but he can just do it like this:
LUA:local position = Position(100, 100, 7) local tile = Tile(position) -- or Tile(x, y, z) if tile then local backpack = tile:getItemById(backpackId) if backpack then backpack:addItem(itemId, count) end end
local position = Position(32103, 32194, 7)
local tile = Tile(position) -- or Tile(x, y, z)
if tile then
local case = tile:getItemById(books[1].bookCaseId)
if case then
book = case:addItem(books[1].id, 1)
doSetItemText(book, "hi")
end
end
local position = Position(32103, 32194, 7)
local tile = Tile(position) -- or Tile(x, y, z)
if tile then
local case = tile:getItemById(books[1].bookCaseId)
if case then
book = case:addItem(1950, 1)
book:setAttribute(ITEM_ATTRIBUTE_TEXT, books[1].texto)
end
end