stendhal/doc/mkdocs/lua/objects/game.md

10 KiB


Contents

[TOC]


Introduction

Object instance: game


Description

The main object that handles setting zone & adding entities to game.


Methods


game:add

game:add (obj)
game:add (obj, expire)
game:add (npc)
game:add (creature, x, y)
  • Adds an object or entity instance to the current zone.
  • Parameters:
    • obj: (RPObject) Object to add.
    • expire: (bool) true if the item should expire according to its normal behavior, false otherwise.
    • npc: (NPC) NPC to add.
    • creature: (Creature) Creature to add.
    • x: (int) Horizontal position of where to add creature.
    • y: (int) Vertical position of where to add creature.
  • Returns: (Creature) game:add(creature) only

game:addGameEvent

game:addGameEvent (source, event, params)

game:createEvent

game:createEvent (source, event, param, ...)
game:createEvent (source, event, params)

game:getCreature

game:getCreature (clazz)

game:getCreatures

game:getCreatures ()

game:getItem

game:getItem (name)
  • Retrieves a registered item.
  • Parameters:
    • name: (string) Name of the item.
  • Returns: (Item)
    • Item or nil if not registered.

game:getItems

game:getItems ()
  • Retrieves all registered items.
  • Returns: (Item[])
    • An array of all available items.

game:getMessage

game:getMessage ()
  • Retrieves exception message set by script.
  • Returns: (string)

game:getZone

game:getZone (name)
game:getZone (obj)
  • Retrieves a registered zone.
  • Parameters:
    • name: (string) Retrieve zone by name.
    • obj: (RPObject) Retreive zone where obj is located.
  • Returns: (StendhalRPZone)
    • Zone or nil if not registered.

game:modify

game:modify (entity)
  • Notifies the StendhalRPWorld that this entity's attributes have changed.
  • Parameters:
    • entity: (RPEntity) Entity being modified.

game:playerIsInZone

game:playerIsInZone (player, zone)
  • Checks if a player is in a specific zone.
  • Parameters:
    • player: (Player) Player to check.
    • zone: (string) Name of zone.
  • Returns: (bool)
    • true if player's zone matches zone.

game:privateText

game:privateText (player, text)
  • Sends a private text to a player.
  • Parameters:
    • player: (Player) Player to receive the message.
    • text: (string) Message text to send to player.

game:raiseEvent

game:raiseEvent (source, event, param, ...)
game:raiseEvent (source, event, params)

game:remove

game:remove (object)
game:remove (npc)
  • Removes an object or entity from world.
  • Parameters:
    • object: (RPObject) Object to remove.
    • npc: (NPC) NPC to remove.

game:runAfter

game:runAfter (turns, func)
  • Executes a function after a specified number of turns.
  • Parameters:
    • turns: (int) Number of turns to wait.
    • func: (function) Function to be executed.
  • TODO:
    • FIXME: how to invoke with parameters?

game:setMusic

game:setMusic (filename)
game:setMusic (filename, args)
  • Sets the background music for the current zone.
  • Parameters:
    • filename: (string) File basename excluding .ogg extension.
    • args: (table) Table of key=value integer values.
      • Keys:
        • volume: Volume level (default: 100).
        • x: The X coordinate of the sound source (default: 1).
        • y: The Y coordinate of the sound source (default: 1).
        • radius: The radius from which the music can be heard (default: 10000).

game:setZone

game:setZone (name)
game:setZone (zone)
  • Selects the zone to be configured.
  • Parameters:
  • Returns: (bool)
    • true if zone was successfully set.