Contents


Introduction

Object instance: entities


Description

Helper for managing in-game entities.


See Also

For public methods that can be performed on Entity objects.


Methods


entities:addKnownChatOptions

entities:addKnownChatOptions npc, keywords

entities:create

entities:create def

entities:createItemSpawner

entities:createItemSpawner name, meanTurns
entities:createItemSpawner name, meanTurns, initOnAdded

entities:createShopSign

entities:createShopSign name, title, caption, seller

entities:createSign

entities:createSign
entities:createSign visible

entities:createSilentNPC

entities:createSilentNPC

entities:createSpeakerNPC

entities:createSpeakerNPC name

entities:fixedPath

entities:fixedPath nodes, loop

entities:getItem

entities:getItem name

entities:getNPC

entities:getNPC name

entities:getPlayer

entities:getPlayer name

entities:getStackableItem

entities:getStackableItem name

entities:setEntityPath

entities:setEntityPath entity, table, loop

entities:setPath

entities:setPath entity, table, loop

entities:setPathAndPosition

entities:setPathAndPosition entity, table, loop

entities:setEntityTraits

entities:setEntityTraits entity, traits

entities:setNPCTraits

entities:setNPCTraits npc, traits

entities:summonCreature

entities:summonCreature name, zone, x, y, summoner, raid
entities:summonCreature def

Entity Definition Tables

General Definition Table

Key Type Required Description
type string yes "SpeakerNPC", "SilentNPC", "Sign", "ShopSign", or "Reader".
pos table no Entity position relative to zone ({x, y}).
description string no Information for "look" command.
class string no Entity class (for signs, image to be used).
subclass string no Entity sub-class (usually image to be used).
resistance int no Amount of resistance when colliding with another entity (0-100) (default: 100).
size table no {w, h}
cursor string no Cursor to display over entity.
visibility int no Level of visibility (0-100) (default: 100).
menu string no Alternate text for menu.

SpeakerNPC & SilentNPC Definition Table

Includes: general definition

Key Type Required Description
dir Direction no Entity's initial facing direction.
ignoresCollision boolean no If false, movement won't be halted on collision.
path table no See Path Table
speed double no Entity movement speed.
basehp int no Entity base HP.
hp int no Entity actual HP.
outfit table no See Outfit Table
idea string no Icon shown representing entity's state.
sounds table<string> no Randomly played sounds emitted from entity.
teleports boolean no

SpeakerNPC Definition Table

Includes: SpeakerNPC & SilentNPC definition

Key Type Required Description
name string yes Name of the NPC.
idleDir Direction no Facing direction when NPC is idle.
chatTimeout long no Amount of idle time before NPC ends conversation (default: ???).
perceptionRange int no Distance at which NPC will hear players (default: ???).
currentState ConversationStates no Converstion state NPC is initialized with (default: ConversationStates.IDLE).
greeting table no Responses to keywords (see Greeting Table).
replies table no Responses to keywords (see Replies Table).
altImage string no Image that will be displayed on NPCs webpage.

Sign Definition Table

Includes: general definition

Key Type Required Description
text string no Text shown when sign is read.
visible boolean no Whether or not a sprite should be drawn for this sign (default: true).

ShopSign Definition Table

Includes: Sign definition

Key Type Required Description
name string yes Shop name/identfier associated with this sign.
title string yes Title displayed at top of window.
caption string yes Caption displayed at top of window.
seller boolean yes Whether sign represents a seller shop or not.

Parameter Tables

Greeting Table

Key Type Required Description
text string yes NPC response when player starts conversation.
action ChatAction no NPC action when player start conversation.

Replies Table

Key Type Required Description
quest string no Reply to "quest"/"task".
job string no Reply to "job".
help string no Reply to "help".
offer string no Reply to "offer".
bye string no Reply to "bye"/"goodbye".

Outfit Table

TODO: layers & colors data types should be the same

Key Type Required Description
layers string yes Entity's outfit.
colors table<string, int> no Entity's outfit colors.

Path Table

Key Type Required Description
nodes table yes List of positions the entity will traverse.
loop boolean no If true, entity will restart path unpon completion.
retrace boolean no If true, entity will retrace path backwards upon completion.
collisionAction CollisionAction no Action when entity collides (default: CollisionAction.REVERSE).

Summon Creature Table

Key Type Required Description
name string yes Name of creature to be summoned.
zone string yes Name of zone where creature should be summoned.
x int yes Horizontal position of summon location.
y int yes Vertical position of summon location.
summoner string no Name of entity doing the summoning (used for logging game events).
raid bool no Whether or not the creature should be a RaidCreature instance (default: true).

Members

entities.manager

This is simply the entity manager instance.


LuaSpeakerNPC

Public Methods


LuaSpeakerNPC:add

LuaSpeakerNPC:add (states, triggers, conditions, nextState, reply, actions)

LuaSpeakerNPC:setPath

entities:setPath table, loop

LuaSpeakerNPC:setPathAndPosition

entities:setPathAndPosition table, loop

LuaSilentNPC

Public Methods


LuaSilentNPC:setPath

entities:setPath table, loop

LuaSilentNPC:setPathAndPosition

entities:setPathAndPosition table, loop