10 KiB
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:
- Returns: (Creature)
game:add(creature)only
game:addGameEvent
game:addGameEvent (source, event, params)
- Raises a new game event. Same function as game:raiseEvent.
- Parameters:
- See: ScriptingSandbox.addGameEvent
game:createEvent
game:createEvent (source, event, param, ...)
game:createEvent (source, event, params)
- Creates a new game event.
- Parameters:
- source: (
string) Source of the event, usually a character. - event: (
string) Name of event. - param: (
string) Event parameter. - params: (
table<string>) List of event parameters.
- source: (
- Returns: New GameEvent instance.
- See also:
game:getCreature
game:getCreature (clazz)
- Retrieves a registered creature.
- clazz: (string) Name of the creature.
- Returns: Creature or nil if not registered.
- See: ScriptingSandbox.getCreature
game:getCreatures
game:getCreatures ()
- Retrieves all registered creatures.
- Returns: (Creature[]) An array of all available creatures.
- See: ScriptingSandbox.getCreatures
- TODO:
- FIXME: should return Lua table
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:
- 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:
- Returns: (bool)
trueif player's zone matches zone.
game:privateText
game:privateText (player, text)
- Sends a private text to a player.
- Parameters:
game:raiseEvent
game:raiseEvent (source, event, param, ...)
game:raiseEvent (source, event, params)
- Raises a new game event.
- Parameters:
- source: (
string) Source of the event, usually a character. - event: (
string) Name of event. - param: (
string) Event parameter. - params: (
table<string>) List of event parameters.
- source: (
- See also:
game:remove
game:remove (object)
game:remove (npc)
- Removes an object or entity from world.
- Parameters:
game:runAfter
game:runAfter (turns, func)
- Executes a function after a specified number of turns.
- Parameters:
- 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).
- Keys:
game:setZone
game:setZone (name)
game:setZone (zone)
- Selects the zone to be configured.
- Parameters:
- name: (string) String name identifier.
- zone: (StendhalRPZone) Zone instance.
- Returns: (bool)
trueif zone was successfully set.