Game
Game.createContainer
Returns a Container userdata
Game.createContainer(itemId, size[, position])
itemId
Required
Type: Integer
Description: The item ID to create a new container as. Item must not be stackable, usable, movable, pickupable, depot, splash, or door.
size
Required
Type: Integer
Description: Size of the container.
position
Optional
Type: Position
Default: nil
Description: Position to add the container to. When defaulted to nil, the container is considered virtual and has no reference in-game.
-- Create a new virtual container which is a book that cannot be moved or picked up
local container = Game.createContainer(12396, 6)
-- Add 100 crystal coins to the new container
container:addItem(2160, 100)
-- Get player's backpack
local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
if backpack then
-- Add the newly created book-container to player's backpack (which contains 100 crystal coins)
backpack:addItemEx(container, true, INDEX_WHEREEVER, FLAG_IGNORENOTMOVEABLE)
endGame.createItem
Returns an Item userdata
Game.createItem(itemId[, count[, position]])
itemId
Required
Type: Integer
Description: The item ID to create.
count
Optional
Type: Integer
Default: 1
Description: Stack count of the item.
position
Optional
Type: Position
Default: nil
Description: Position to add the item to. When defaulted to nil, the item is considered virtual and has no reference in-game.
-- Create a Might Ring at position X: 1000, Y: 1000, Z: 7
local item = Game.createItem(2164, 1, Position(1000, 1000, 7))
-- Set the charges of the Might Ring to 5
item:setAttribute(ITEM_ATTRIBUTE_CHARGES, 5)Game.createMonster
Returns a Monster userdata
Game.createMonster(monsterName, position[, extended = false[, force = false]])
monsterName
Required
Type: String
Description: Name of the monster (registered in monsters.xml) to create.
position
Required
Type: Position
Description: Position at which the monster will be created at.
extended
Optional
Type: Boolean
Default: false
Description: Will try to spawn monster within 2sqm instead of 1sqm if the specified position is unavailable.
force
Optional
Type: Boolean
Default: false
Description: Forces the monster to spawn on the specified position regardless if the tile is blocked or not.
-- Create a new Rabbit at position X: 1000, Y: 1000, Z: 7, which is forced to spawn
local monster = Game.createMonster("Rabbit", Position(1000, 1000, 7), false, true)
-- Remove 1 health from the rabbit
monster:addHealth(-1)Last updated
Was this helpful?