📓
TFS Guide
  • Preface
  • Progress
  • Unique TFS Concepts
  • Interface - Actions
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - Chatchannels
    • Registration
    • Scripting
  • Interface - Creaturescripts
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - Events
    • Registration
    • Scripting
  • Interface - Globalevents
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - Monster
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - Movements
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - NPC
    • Registration
    • Scripting
  • Interface - Spells
    • Registration
    • Scripting
  • Interface - Talkactions
    • Registration
    • Scripting
  • Interface - Weapons
    • Registration
    • Scripting
  • Source Editing
    • Creating new events
    • Creating new Lua functions
  • Function Documentation
    • Game
Powered by GitBook
On this page
  • Game.createContainer
  • Game.createItem
  • Game.createMonster

Was this helpful?

  1. Function Documentation

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

Game.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)
PreviousCreating new Lua functions

Last updated 5 years ago

Was this helpful?