Daimonin Lua Core reference - object

Automatically generated 2022-03-05 21:19:03

Attributes

object object.above (readonly)
integer object.anim_enemy_dir
integer object.anim_enemy_dir_last
integer object.anim_last_facing
integer object.anim_last_facing_last
integer object.anim_moving_dir
integer object.anim_moving_dir_last
integer object.anim_speed
integer object.anim_speed_last
integer object.armour_class (readonly if object is a player)
integer object.attack_acid (readonly if object is a player)
integer object.attack_aether (readonly if object is a player)
integer object.attack_cancellation (readonly if object is a player)
integer object.attack_channelling (readonly if object is a player)
integer object.attack_chaos (readonly if object is a player)
integer object.attack_cleave (readonly if object is a player)
integer object.attack_cold (readonly if object is a player)
integer object.attack_confusion (readonly if object is a player)
integer object.attack_corruption (readonly if object is a player)
integer object.attack_countermagic (readonly if object is a player)
integer object.attack_death (readonly if object is a player)
integer object.attack_depletion (readonly if object is a player)
integer object.attack_drain (readonly if object is a player)
integer object.attack_electricity (readonly if object is a player)
integer object.attack_fear (readonly if object is a player)
integer object.attack_fire (readonly if object is a player)
integer object.attack_godpower (readonly if object is a player)
integer object.attack_impact (readonly if object is a player)
integer object.attack_lifesteal (readonly if object is a player)
integer object.attack_light (readonly if object is a player)
integer object.attack_nether (readonly if object is a player)
integer object.attack_paralyze (readonly if object is a player)
integer object.attack_pierce (readonly if object is a player)
integer object.attack_poison (readonly if object is a player)
integer object.attack_psionic (readonly if object is a player)
integer object.attack_shadow (readonly if object is a player)
integer object.attack_slash (readonly if object is a player)
integer object.attack_slow (readonly if object is a player)
integer object.attack_snare (readonly if object is a player)
integer object.attack_sonic (readonly if object is a player)
integer object.attack_weaponmagic (readonly if object is a player)
object object.attacked_by (readonly)
object object.below (readonly)
integer object.carrying (readonly)
integer object.charisma (fix():es the player or mob after change)
integer object.constitution (fix():es the player or mob after change)
integer object.count (readonly)
integer object.damage (readonly if object is a player)
integer object.damage_round_tag
integer object.dexterity (fix():es the player or mob after change)
integer object.direction
integer object.egomode (readonly)
string object.egoname (readonly)
object object.enemy (readonly)
object object.environment (readonly)
integer object.experience (readonly if object is a player)
integer object.facing
integer object.food
integer object.glow_radius (readonly)
integer object.grace
object object.head (readonly)
integer object.hitpoints
integer object.intelligence (fix():es the player or mob after change)
object object.inventory (readonly)
integer object.item_condition
integer object.item_level
integer object.item_quality
integer object.item_race
integer object.item_skill
integer object.last_damage
integer object.last_eat
integer object.last_grace
integer object.last_heal
integer object.last_sp
integer object.layer (readonly if object is a player)
integer object.level (readonly if object is a player)
integer object.magic
map object.map (readonly)
integer object.material
integer object.material_real
integer object.max_buffs
integer object.max_grace (readonly if object is a player)
integer object.max_hitpoints (readonly if object is a player)
integer object.max_spellpoints (readonly if object is a player)
string object.message
object object.more (readonly)
string object.name (readonly if object is a player)
object object.owner (readonly)
integer object.path_attuned
integer object.path_denied
integer object.path_repelled
integer object.power (fix():es the player or mob after change)
integer object.quantity
integer object.quick_pos
string object.race
integer object.resist_acid (readonly if object is a player)
integer object.resist_aether (readonly if object is a player)
integer object.resist_cancellation (readonly if object is a player)
integer object.resist_channelling (readonly if object is a player)
integer object.resist_chaos (readonly if object is a player)
integer object.resist_cleave (readonly if object is a player)
integer object.resist_cold (readonly if object is a player)
integer object.resist_confusion (readonly if object is a player)
integer object.resist_corruption (readonly if object is a player)
integer object.resist_countermagic (readonly if object is a player)
integer object.resist_death (readonly if object is a player)
integer object.resist_depletion (readonly if object is a player)
integer object.resist_drain (readonly if object is a player)
integer object.resist_electricity (readonly if object is a player)
integer object.resist_fear (readonly if object is a player)
integer object.resist_fire (readonly if object is a player)
integer object.resist_godpower (readonly if object is a player)
integer object.resist_impact (readonly if object is a player)
integer object.resist_lifesteal (readonly if object is a player)
integer object.resist_light (readonly if object is a player)
integer object.resist_nether (readonly if object is a player)
integer object.resist_paralyze (readonly if object is a player)
integer object.resist_pierce (readonly if object is a player)
integer object.resist_poison (readonly if object is a player)
integer object.resist_psionic (readonly if object is a player)
integer object.resist_shadow (readonly if object is a player)
integer object.resist_slash (readonly if object is a player)
integer object.resist_slow (readonly if object is a player)
integer object.resist_snare (readonly if object is a player)
integer object.resist_sonic (readonly if object is a player)
integer object.resist_weaponmagic (readonly if object is a player)
integer object.run_away
string object.slaying
float object.speed (readonly if object is a player)
float object.speed_left
integer object.spellpoints
integer object.state (readonly)
integer object.strength (fix():es the player or mob after change)
integer object.sub_type_1
integer object.subtype
integer object.terrain_flag
integer object.terrain_type
integer object.thac0 (readonly if object is a player)
integer object.thacm (readonly if object is a player)
string object.title
integer object.type (readonly)
integer object.update_tag
integer object.value
integer object.weapon_class (readonly if object is a player)
float object.weapon_speed
float object.weapon_speed_left
integer object.weight
integer object.weight_limit (readonly if object is a player)
integer object.wisdom (fix():es the player or mob after change)
integer object.x (readonly)
integer object.y (readonly)

Back to the index


Flags

object.f_allowsview
object.f_applied
object.f_been_applied
object.f_berserk
object.f_blocksview
object.f_can_open_door
object.f_can_pass_thru
object.f_can_reflect_castable
object.f_can_reflect_missile
object.f_can_roll
object.f_can_see_in_dark
object.f_can_stack
object.f_can_use_armour
object.f_can_use_ring
object.f_can_use_weapon
object.f_changing
object.f_confused
object.f_corpse
object.f_corpse_forced
object.f_cursed
object.f_cursed_perm
object.f_damned
object.f_damned_perm
object.f_door_closed
object.f_egolock (readonly)
object.f_feared (readonly)
object.f_fix_player (readonly)
object.f_fly_off
object.f_fly_on
object.f_flying
object.f_friendly
object.f_has_ready_bow
object.f_has_ready_spell
object.f_has_ready_weapon
object.f_hitback
object.f_homeless_mob (readonly)
object.f_identified
object.f_in_activelist (readonly)
object.f_inserted (readonly)
object.f_inv_locked
object.f_invulnerable
object.f_is_aged
object.f_is_animated
object.f_is_assassin
object.f_is_blind
object.f_is_cauldron
object.f_is_donation (readonly)
object.f_is_dust
object.f_is_eating (readonly)
object.f_is_ethereal
object.f_is_evil
object.f_is_female
object.f_is_good
object.f_is_hilly
object.f_is_initialized (readonly)
object.f_is_invisible
object.f_is_linked (readonly)
object.f_is_magical
object.f_is_male
object.f_is_missile
object.f_is_named
object.f_is_neutral
object.f_is_removed (readonly)
object.f_is_thrown
object.f_is_traped
object.f_is_turnable
object.f_is_used_up
object.f_is_wooded
object.f_known_cursed
object.f_known_magical
object.f_levitate
object.f_lifesave
object.f_make_ethereal
object.f_make_invisible
object.f_no_attack
object.f_no_drop
object.f_no_fix_player
object.f_no_inv (readonly)
object.f_no_pass
object.f_no_pick
object.f_no_prayers
object.f_no_save (readonly)
object.f_no_send (readonly)
object.f_no_spells
object.f_no_steal
object.f_no_teleport
object.f_obscuresview
object.f_one_drop
object.f_one_hit
object.f_only_attack
object.f_paralyzed (readonly)
object.f_pass_ethereal
object.f_pass_thru
object.f_player_only
object.f_proof_ele
object.f_proof_mag
object.f_proof_phy
object.f_proof_sph
object.f_quest_item
object.f_random_move
object.f_reflecting
object.f_reg_f
object.f_rooted (readonly)
object.f_run_away
object.f_scared
object.f_see_anywhere
object.f_see_invisible
object.f_sentient
object.f_sleep
object.f_slowed (readonly)
object.f_spawn_mob (readonly)
object.f_splitting
object.f_stand_still
object.f_stealth
object.f_surrendered
object.f_sys_object (readonly)
object.f_tear_down
object.f_unaggressive
object.f_undead
object.f_unidentifiable
object.f_unpaid
object.f_use_dmg_info
object.f_walk_off
object.f_walk_on
object.f_was_reflected
object.f_xrays
object.is_giving (readonly)
object.no_apply (readonly)

Back to the index


Functions

object:AcquireSkill(skillno, mode)

Parameter types:
skillno: integer (required)
mode: integer (required)

object will learn or unlearn skill.
mode should be game.LEARN or game.UNLEARN
Get skill number with game:GetSkillNr()

Back to the index


object:AcquireSpell(spell, mode)

Parameter types:
spell: integer (required)
mode: integer (required)

object will learn or unlearn spell.
mode should be game.LEARN or game.UNLEARN

Back to the index


object:ActivateRune(what)

Parameter types:
what: object (required)

Back to the index


object:AddBuff(buffname, buffstring)

Parameter types:
buffname: string (required)
buffstring: string (required)

Creates a force with specified stats that is added to the object.
The stats of that force are then added to the object. buffstring should be
an arch definition string, excluding the arch, name, and end attributes.
Returns:
BUFF_ADD_SUCCESS - Nothing went wrong.
BUFF_ADD_EXISTS - The buff exists, but that does not mean it failed.
BUFF_ADD_LIMITED - Too many of the same buff.
BUFF_ADD_MAX_EXCEEDED - item->max_buffs exceeded.
BUFF_ADD_BAD_PARAMS - item or buff == NULL
BUFF_ADD_NO_INSERT - Something went wrong in insert_ob_in_ob - unlikely

Back to the index


object:AddMoney(copper, silver, gold, mithril)

Parameter types:
copper: integer (required)
silver: integer (required)
gold: integer (required)
mithril: integer (required)

adds to inventory of caller coin object = money

Back to the index


object:AddMoneyEx(copper, silver, gold, mithril)

Parameter types:
copper: integer (required)
silver: integer (required)
gold: integer (required)
mithril: integer (required)

Same as AddMoney but with message to player how much he got

Back to the index


object:AddOneDropQuest(archetype, name, title)

Parameter types:
archetype: object (required)
name: string (required)
title: string (optional)

Adds a one drop item to the player.
(Creates the quest container if needed.)

Back to the index


object:AddQuest(name, mode, start, stop, level, skill, msg, reps)

Parameter types:
name: string (required)
mode: integer (required)
start: integer (required)
stop: integer (required)
level: integer (required)
skill: integer (required)
msg: string (optional)
reps: integer (optional)

Only works for player objects. Other types generate an error.
Add a quest_trigger to a quest_container = give player a quest.

Back to the index


object:AddQuestItem(nrof, arch, face, name, title)

Parameter types:
nrof: integer (required)
arch: string (required)
face: string (required)
name: string (optional)
title: string (optional)

Add a quest item to a quest or base object
(see GameObject_AddQuestTarget)

Back to the index


object:AddQuestTarget(chance, nrof, arch, name, race, title, lev)

Parameter types:
chance: integer (required)
nrof: integer (required)
arch: string (optional)
name: string (optional)
race: string (optional)
title: string (optional)
lev: integer (optional)

define a kill mob. Careful: if all are nil then ALL mobs are part
of this quest. If only arch set, all mobs using that base arch

TODO: Improve docs.

Back to the index


object:AddSparkly(arch_id, s)

Parameter types:
arch_id: string (required)
s: float (optional)

Associates a sparkly with object.
Arg : arch_id is the name of the arch to use as the sparkly.
s is the time (in seconds, may be fractional) for the sparkly to
last. This time is converted to server ticks (the exchange rate
may change) so may not be 100% exact. If unspecified (or <= 0),
the arch default is used.
Error : arch_id does not refer to an archetype or is not a sparkly
archetype.
Return : The newly created sparkly object (which may be nil under certain
circumstances). 0
Note : Sparklies in general, and therefore the Lua UI to that system,
suffers from several substantial problems and is easily broken.
There will be fairly major update at some point.

Back to the index


object:AdjustLightSource(value)

Parameter types:
value: integer (required)

Sets the object's glow radius to value.
Any object can have a glow radius, though there are two specific
light types (applyable and static). Applyable lights generally
give some sort of message when applied and can even be set up to
not be applyable at all! This method ignores all that: An
applyable light adjusted with this method is always guaranteed to
turn on/off (depending on value -- 0 means off, any other value
means on) and no message will be generated.
The mandatory value argument is an integer from -9 to 9.
The method returns nil.
Notes : If you want to apply an applyable light according to normal
rules, this is the wrong method. Use object:Apply().

Back to the index


object:Apply(what, flags)

Parameter types:
what: object (required)
flags: integer (required)

forces object to apply what.
flags should be a reasonable combination of the following:
Daimonin.APPLY_TOGGLE - normal apply (toggle)
Daimonin.APPLY_ALWAYS - always apply (never unapply)
Daimonin.UNAPPLY_ALWAYS - always unapply (never apply)
Daimonin.UNAPPLY_NOMERGE - don't merge unapplied items
Daimonin.UNAPPLY_IGNORE_CURSE - unapply cursed items
returns: 0 - object cannot apply objects of that type.
1 - object was applied, or not...
2 - object must be in inventory to be applied

Back to the index


object:CastSpell(target, spell, mode, direction, option)

Parameter types:
target: object (required)
spell: integer (required)
mode: integer (required)
direction: integer (required)
option: string (required)

object casts the spell numbered spellno on target.
mode = game.CAST_NORMAL or game.CAST_POTION
direction is the direction to cast the spell in
option is additional string option(s)
NPCs can cast spells even in no-spell areas.
FIXME: only allows for directional spells
FIXME: is direction/position relative to target? (0 = self)

Back to the index


object:ChannelMsg(channel, message, mode)

Parameter types:
channel: string (required)
message: string (required)
mode: integer (optional)

object sends message on the channel according to mode.
object can be any object, not just a player and does not need to
be subscribed to channel. The message is attributed to the
object's name. This is underlined to show it came from a script.
See also mode below.
channel must be a full channel name, not an abbreviation.
message is an arbitray string of less than 250 characters or so.
mode should be one of:
game.CHANNEL_MODE_NORMAL: message is sent as a normal message.
This is the default.
game.CHANNEL_MODE_EMOTE: message is sent as an emote.
game.CHANNEL_MODE_SYSTEM: message is sent as a system message.
It is attributed to |Daimonin| rather than the object name.
Return: True on success. False on failure.

TODO: Where object is a (channel) muted player nothing should be posted.
The main problem here is that we nedd the checks to be done
silently -- ie, on mute just fail, don't notify the player -- but
the code has not been written in such a flexible way.

Back to the index


object:CheckBuff(buffname)

Parameter types:
buffname: string (required)

Check if this buff can be added. It goes through the same process
as AddBuff but doesn't modify the item at all
Returns:
BUFF_ADD_SUCCESS - Nothing went wrong.
BUFF_ADD_EXISTS - The buff exists, but that does not mean it failed.
BUFF_ADD_LIMITED - Too many of the same buff.
BUFF_ADD_MAX_EXCEEDED - item->max_buffs exceeded.
BUFF_ADD_BAD_PARAMS - item or buff == NULL
BUFF_ADD_NO_INSERT - Something went wrong in insert_ob_in_ob - unlikely

Back to the index


object:CheckGuild(name)

Parameter types:
name: string (required)

Back to the index


object:CheckInstance(entrance_path)

Parameter types:
entrance_path: string (required)

Check player has this instance active
Only checks the player instance data match - NO map loading
Return : boolean.
Gotcha : Only valid on players.

Back to the index


object:CheckInventory(mode, arch, name, title, type)

Parameter types:
mode: integer (required)
arch: string or nil (required)
name: string or nil (optional)
title: string or nil (optional)
type: integer (optional)

returns the first found object with the specified name if found
in object's inventory, or nil if it wasn't found.
title, arch or object == nil will be ignored for search
also type == -1
mode: 0: only inventory, 1: inventory and container, 2: all inv.

Back to the index


object:CheckInvisibleInside(id)

Parameter types:
id: string (required)

Back to the index


object:CheckOneDropQuest(archetype, name)

Parameter types:
archetype: string (required)
name: string (optional)

Check the one drop and single quest item container for an item

Back to the index


object:CheckQuestLevel(level, skill_group)

Parameter types:
level: integer (required)
skill_group: integer (required)

Check if a quest is possible to start based on a minimum required
level in a specified skill group.
the skill_group parameter _must_ be one of the
game.ITEM_SKILL_XXX constants. game.ITEM_SKILL_NO checks against
the player's main level.
This function is only valid for objects of TYPE_PLAYER.
Normally, the QuestManager wrapper is used instead of calling
this function directly. Please see the lua scripting docs for
QuestManager details.

Back to the index


object:CheckTrigger(what)

Parameter types:
what: object (required)

Back to the index


object:Clone(mode)

Parameter types:
mode: integer (optional)

mode = game.MODE_INVENTORY (default) or
game.MODE_NO_INVENTORY
You should do something with the clone.
SetPosition() and InsertInside() are useful functions for this.

Back to the index


object:Communicate(message)

Parameter types:
message: string (required)

object says message to everybody on its map
but instead of CFSay it is parsed for other npc or magic mouth

Back to the index


object:CreateArtifact(base_obj, artifact_mask)

Parameter types:
base_obj: object (required)
artifact_mask: string (required)

Create an artifact = apply a artifact mask to an object

Back to the index


object:CreateInvisibleObjectInside(id)

Parameter types:
id: string (required)

Back to the index


object:CreateObjectInside(archname, identified, number, value)

Parameter types:
archname: string (required)
identified: integer (optional)
number: integer (optional)
value: integer (optional)

Creates an object from archname and inserts into object.
identified is either game.IDENTIFIED or game.UNIDENTIFIED
number is the number of objects to create in a stack
If value is >= 0 it will be used as the new object's value,
otherwise the value will be taken from the arch.

Back to the index


object:CreateObjectInsideEx(archname, identified, number, value)

Parameter types:
archname: string (required)
identified: integer (optional)
number: integer (optional)
value: integer (optional)

Same as GameObject_CreateObjectInside but give message to player
Creates an object from archname and inserts into object.
identified is either game.IDENTIFIED or game.UNIDENTIFIED
number is the number of objects to create in a stack
If value is >= 0 it will be used as the new object's value,
otherwise the value will be taken from the arch.

Back to the index


object:CreatePlayerForce(force_name, time)

Parameter types:
force_name: string (required)
time: integer (optional)

Creates and insters a player force named force_name in object.
The values of a player force will effect the player.
If time is given and > 0, the force will be removed again after
time/0.02 ticks.

Back to the index


object:CreatePlayerInfo(name)

Parameter types:
name: string (required)

Creates a player_info object of specified name in object's
inventory.
The values of a player_info object will NOT effect the player.
Returns the created object

Back to the index


object:DecreaseNrOf(nrof)

Parameter types:
nrof: integer (optional)

Reduces the quantity of a stack by nrof, removing the object if
the entire stack is removed.
nrof is optional. If not given (or 0) it is the same as
object:DecreaseNrOf(1). If negative, it is the same as
object:DecreaseNrOf(object.quantity).
Note : This method handles stacks properly. Do not be tempted to use
object:Remove() as a shortcut for
object:DecreasNrOf(object.quantity) or vice versa.
Also : If you want to genuinely remove an object, regardless of its
quantity, use object:Remove(). If you want to represent the
destruction of an object, use object:Destruct().

Back to the index


object:DeleteInstance(entrance_path)

Parameter types:
entrance_path: string (required)

Delete the instance for a player
NOTE: this function don't touches the instance directory or
deletes a map - it only removes the ID tags from the player
IF mapname is the same as the player saved instance
Return : boolean.
Gotcha : Only valid on players.

Back to the index


object:Deposit(what, string)

Parameter types:
what: object (required)
string: string (required)

Only works for players and monster objects. Other types generate
an error.
Deposits an amount of money (as described by string) to what (a
bank force) from object's inventory.
Return : nil if there was a syntax error in string; false if the object
did not have sufficient money; true if the deposit succeeded (and
what->value is updated).

Back to the index


object:Destruct()

Only works for monster objects. Other types generate an error.
Removes the object from the game and drops all items in object's
inventory on the floor or in a corpse
The method takes no arguments.
Also : If you want reduce the quantity of a stack, use
object:DecreaseNrOf(). If you want to quietly remove an object,
not fiddle with the stack, use object:Remove()

Back to the index


object:DoKnowSpell(spell)

Parameter types:
spell: integer (required)

true if the spell is known by object, false if it isn't

Back to the index


object:Drop(what, nrof)

Parameter types:
what: object (required)
nrof: integer (optional)

Only works for players and monster objects. Other types generate
an error.
Causes object to drop what if possible (according to standard
rules such as players cannot drop locked items and mobs cannot
drop no drops).
nrof is optional and specifies the nrof from a stack (the default
is the entire stack).

Back to the index


object:FindMarkedObject()

Returns the marked object in object's inventory, or None if no
object is marked.

Back to the index


object:FindNextObject(type, mode, root, arch_name, name, title)

Parameter types:
type: integer (required)
mode: integer (optional)
root: object (optional)
arch_name: string (optional)
name: string (optional)
title: string (optional)

Returns the next object in object's local inventory tree, or nil.

TODO: Proper doc.
Extended return.

Back to the index


object:FindSkill(skill)

Parameter types:
skill: integer (required)

skill ptr if the skill is known by object, NULL is it isn't
Note : Deprecated, use object:GetSkill().

Back to the index


object:Fix()

Recalculates a player's or monster's stats depending on
equipment, forces, skills etc.

Back to the index


object:GetAI()

Get the AI object for a mob. Mostly useful in behaviours.
Will return nil if the mob's AI hasn't been initialized yet

Back to the index


object:GetAccountName()

Only works for player objects. Other types generate an error.
Returns the account name of the player. If the object is not
controlled by a player, this is logged and the return is nil.

Back to the index


object:GetAlignmentForce()

This gets the aligment_force from a inventory (should be player?)

Back to the index


object:GetAnimation()

Returns the name of object's animation, if any.

Back to the index


object:GetArchName()

Returns the name of object's arhetype.

Back to the index


object:GetCombatMode()

Only works for player objects. Other types generate an error.
The function takes no arguments.
The return is true if object is in combat mode, false otherwise.

Back to the index


object:GetConnection()

Gets an object's connection value.
The function takes no arguments.
The return is the object's connection value (0 means none).

Back to the index


object:GetEquipment(slot)

Parameter types:
slot: integer (required)

Get a player's current equipment for a given slot. slot must be
one of the Game.EQUIP_xxx constants, e.g. Game.EQUIP_GAUNTLET
If the selected slot is empty, this method will return nil.

Back to the index


object:GetFace()

Returns the name of object's face, if any.

Back to the index


object:GetGender()

Gets the gender of object. Returns five values: an integer and
and four strings (the noun, objective pronoun, subjective pronoun
and possessive pronoun for that gender). So the possibilities are
game.NEUTER, "neuter", "it", "it", "its"
game.MALE, "male", "he", "him", "his"
game.FEMALE, "female", "she", "her", "her"
game.HERMAPHRODITE, "hermaphrodite", "they", "them, "their"

Back to the index


object:GetGmasterMode()

Only works for player objects. Returns one of the
Game.GMASTER_MODE_* constants:
Game.GMASTER_MODE_NO if the object is not SA/MM/MW/GM/VOL
Game.GMASTER_MODE_SA if the object is SA
Game.GMASTER_MODE_MM if the object is MM
Game.GMASTER_MODE_MW if the object is MW
Game.GMASTER_MODE_GM if the object is GM
Game.GMASTER_MODE_VOL if the object is VOL

Back to the index


object:GetGod()

Back to the index


object:GetGroup()

Only works for player objects. Other types generate an error.
The function takes no arguments.
If the player is in a group, the return is a table with numerical
where [1] is the leader and [2] onwards are the other members.
Otherwise, the return is nil.

TODO: Much.

Back to the index


object:GetGuild(name)

Parameter types:
name: string (required)

Back to the index


object:GetIP()

Only works for player objects. Other types generate an error.
Returns the IP of the player (as a string). If the object is not
controlled by a player, this is logged and the return is nil.

Back to the index


object:GetInvAnimation()

Returns the name of object's inventory animation, if any.

Version notes: Introduced in beta 4 pre4

Back to the index


object:GetInvFace()

Returns the name of object's inventory face, if any.

Version notes: Introduced in beta 4 pre4

Back to the index


object:GetItemCost(object,type)

Parameter types:
object: object (required)
type: integer (required)

type is one of game.COST_TRUE, game.COST_BUY or game.COST_SELL

Back to the index


object:GetMoney()

returns the amount of money the object carries in copper

Back to the index


object:GetName(owner)

Parameter types:
owner: object (optional)

same as QUERY_SHORT_NAME()

Back to the index


object:GetNextPlayerInfo(player_info)

Parameter types:
player_info: object (required)

get next player_info in who's inventory with same name as
player_info

Back to the index


object:GetPersonalLight()

Only works for player objects. Other types generate an error.
The function takes no arguments.
The return is the object's personal light value (0 means off).

Back to the index


object:GetPets()

Returns an array of all pets currently owned by @object

Back to the index


object:GetPlayerInfo(name)

Parameter types:
name: string (required)

get first player_info with the specified name in who's inventory

Back to the index


object:GetPlayerWeightLimit()

Only works for player objects. Returns the real weight limit
of a player including stat bonus

Back to the index


object:GetPrivacy()

Queries a player's privacy setting.
Arg : -
Error : object is not a player.
Return : The player's privacy setting (true or false).
Note : There is intentionally no SetPrivacy().

Back to the index


object:GetQuest(name)

Parameter types:
name: string (required)

Checks if object (which must be a player) knows about the named
quest (means it has been or is being done), and its active
status. Note that active status is not the same as status.
Status includes whether or not a player is eligible for the quest
(QSTAT_NO or QSTAT_DISALLOW) and therefore cannot be
QSTAT_UNKNOWN. Status can only be ascertained with a script
(because the eligibility criteria rely on certain checks and
lists defined only within the script).
Active status therefore cannot check eligiblity. Hence
QSTAT_UNKNOWN says nothing of eligibility, it just means the
player is not doing/has not done this quest (and that includes
because the quest -- or player -- does not exist).
Additionally, where a quest has been done but is still
repeatable, QSTAT_NO is returned. Again, this does not imply
actual eligibility, it just differentiates the return from
QSTAT_DONE.
So two values are returned: a GameObject, which is the quest
itself, if it is known, or nil otherwise; a number to indicate
its active status.
This number is one of:
game.QSTAT_UNKNOWN - no quest of that name is currently or
has ever been undertaken by the player.
game.QSTAT_NO - the named quest has previously been done by
the player but is repeatable.
game.QSTAT_DONE - the named quest has previously been done by
the player and is not repeatable.
game.QSTAT_ACTIVE -- the named quest is one the player has
accepted and is still actively working on.
game.QSTAT_SOLVED -- the named quest is one the player has
accepted and has completed all tasks on; he has only to
report back to the quest giver to pick up a reward.

Back to the index


object:GetRepairCost()

Back to the index


object:GetSkill(type, nr)
object:GetSkill(name)

Parameter types:
type: integer (required)
nr: integer (required)

Gets a skill or skillgroup GameObject if object has that skill.
The type argument must be either game.TYPE_SKILL for a particular
skill or game.TYPE_SKILLGROUP for a skill group. nr must be a
legal value accordingly.
For particular skills, the second form of call may be used where
the string name is internally translated into a skill number.
Various major problems with the arguments generate Lua errors
(such as if object is not a player or nr is negative).
There are 3 varieties of skill: non-leveling skills do not
gain/lose levels or exp (you either have them or you don't, eg,
common literacy); direct skills gain/lose levels directly (eg,
find traps); indirect skills accumulate exp which means the skill
gains/loses levels as the total crosses certain thresholds (eg,
punching).
Two values are returned: the GameObject (or nil); a game constant
number representing whether/how the skill may be leveled.
This number is one of:
game.NONLEVELING - if the previous return was nil, or type
was TYPE_SKILLGROUP, or the skill has already reached
maximum level, or the skill is truly non-leveling;
game.INDIRECT - if the skill is leveled indirectly and may
gain exp via a script this level;
game.INDIRECT_NO - if the skill is leveled indirectly and may
not gain exp via a script this level;
game.DIRECT - if the skill is leveled directly.

Back to the index


object:GetTarget()

Only works for player or monster objects. Other types generate
an error.
The function takes no arguments.
The return is the object that is the current target.

TODO: To be expanded to handle monsters.

Back to the index


object:GetVector(other)

Parameter types:
other: object (required)

Get the distance and direction from object to other
Returns NIL if it couldn't be calculated (either object wasn't
on a map, they were in separate mapsets or too far away from
eachother)
On success, returns the following 4 values:
- distance (absolute euclidian distance)
- direction (0-8), corresponds to game.NORTH, game.EAST etc
- x distance (can be negative)
- y distance (can be negative)

Back to the index


object:Give(what, whom, nrof)

Parameter types:
what: object (required)
whom: object (required)
nrof: integer (optional)

Only works for monster objects. Other types generate an error.
Causes object to give what to whom if possible (or technically
whom to pick up what which happens to be in object's inventory).
nrof is optional and specifies the nrof from a stack (the default
is the entire stack).
This method does not check the distance between the object and
whom. So things can be given from A to B no matter how far they
are from one another, whether they are separated by a wall or a
lake of fire, or even on distant maps, etc.
Giving has a very communist definition so ALL object's property
is open to ANYONE (though this method does limit this to object's
direct inventory -- ie, not things in containers though those
containers may themselves be given). Fortunately this sŧate only
lasts for the split second this method is actually running.
Return : A boolean to indicate whether the attempt succeeded or not
(failure can only mean that whom was not able to pick up what for
some reason -- ie, too heavy, etc).

Back to the index


object:InsertInside(where)

Parameter types:
where: object (required)

Inserts object into where.

Back to the index


object:Interface(mode, message)

Parameter types:
mode: integer (required)
message: string (optional)

This function opens a NPC gui interface on the client
A mode of 0 means to close explicit a open interface at client

Back to the index


object:JoinGuild(name, skill1, v1, skill2, v2, skill3, v3)

Parameter types:
name: string (required)
skill1: integer (optional)
v1: integer (optional)
skill2: integer (optional)
v2: integer (optional)
skill3: integer (optional)
v3: integer (optional)

Only works for player objects. Other types generate an error.
Causes object to join named guild. The default or guild
skillgroups are set as indicated.

Back to the index


object:Kill(killer)

Parameter types:
killer: object (optional)
string: string (optional)
string: string (optional)

Kills the object, awarding exp, creating a corpse, giving
deathsick, etc. as necessary.
Returns true if the object was good enough to die, false if it
had some method of saving its life, or nil if there was a
problem.

Back to the index


object:LeaveGuild()

Only works for player objects. Other types generate an error.
Causes object to leave current guild.

Back to the index


object:MakeEgo(mode[, name[, lock]])

Parameter types:
mode[: unknown (required)

Sets an object's ->egomode, ->egoname, and egolock flag according
to the arguments (or as appropriate where daft values are used).
Args : mode should be one of the game.EGOITEM_MODE_* constants or 0.
name should be an appropriate string when mode > 0 or nil (or
unspecified) otherwise (but see monster note). "*" can be used,
which matches any ego, but not if mode is EGOITEM_MODE_PLAYER.
lock should be boolean (or unspecified).
Return : Boolean.
Error : object is a player.
object is not a monster or mode is EGOITEM_MODE_PLAYER and name
is "*".
Note : This method allows scripts to unbind/rebind previously bound
egoitems or make a previously unbindable object bindable/bound.
This may have non-obvious consequences, so use with caution.
However, if the object has the egolock flag set, it cannot be
(un/re)bound unless ->egomode is already < 0.
Also, although this method can set an object's egolock flag,
there is no way for the flag to be cleared.

Back to the index


object:MakePet(owner, mode)

Parameter types:
owner: object (required)
mode: integer (optional)

Makes @object into a pet owned by @owner. @object must be a
non-pet monster, and @owner must be a player.
If mode is 0, a normal pet addition is done, which may fail for
several reasons. If mode is 1, the pet is forced which may still
fail but not as often.
Normally you should use 0, but in some cases where for example a
quest requires a specific pet you could try 1.
Returns true if object is made into a pet, and false otherwise.

Back to the index


object:Move(direction[, originator[, terrain]])

Parameter types:
direction[: integer (required)
originator[: object (optional)
terrain]]: integer (optional)

Makes the object move in the desired direction (currently at
least this is in a non-animated, non-turning, instantaneous,
slide-to-next-square kind of way).
Args : direction is one of game.NORTH, game.SOUTH, game.NORTHEAST, etc.
originator is the GameObject which caused the move. This rarely
is actually used but for example might be the player who pushed
the monster into the spiked pit so the server knows who to give
exp and credit for the kill. It may be nil or unspecified -- see
Notes.
terrain is a number to indicate which floor terrain object can
move over. So-called terrain is not well-implemented yet. Floors
can be land (1) or water (2). So this value should be 1, 2, or 3
to allow movement over the corresponding terrain(s). <=0, nil,
or unspecified means use object's terrain_flag attribute. The
attribute is persistent before, during, and after this method
while the argument is only in effect for this call.
Return : Number (one of the game.MOVE_RETURN_* constants).
SUCCESS if moving succeeded;
INSERTION_FAILED if something blocked the move;
DESTROYED if object was destroyed when moving.
*Always* check the return and behave accordingly.
Error : -
Notes : Historically, originator is rarely used, but should be, at least
in cases where the cause of movement is not environmental (such
as where the object is swept along by the tide), and especially
when this is an entity.
The docs used to claim the return was:
0 if something blocked the move;
1 if moving succeeded;
-1 if object was destroyed when moving.
This was (and is) wrong. The actual numbers are 1, 0, 2 (but
always use the game.MOVE_RETURN_* constants).

Back to the index


object:NrofQuestItem()

counts quest items inside the inventory of the player
where target_obj is inside

Back to the index


object:PayAmount(value)

Parameter types:
value: big integer (64 bit) (required)

If object has enough money, value copper will be deducted from
object, and 1 will be returned. Otherwise returns 0

Back to the index


object:PayForItem(object)

Parameter types:
object: object (required)

Back to the index


object:PickUp(what, where, nrof)

Parameter types:
what: object (required)
where: object (optional)
nrof: integer (optional)

Only works for players and monster objects. Other types generate
an error.
Causes object to pick up what if possible (according to standard
rules).
where is optional but if specified must be a container and causes
a pick up to container. Otherwise a pick up to inventory is
attempted.
nrof is optional and specifies the nrof from a stack (the default
is the entire stack).

Back to the index


object:ReadyUniqueMap(path, mode)

Parameter types:
path: string (required)
mode: integer (optional)

Loads the map pointed to by path into memory with unique status.
This creates a new persistant unique map if needed.
path is a required string. It must be an absolute path.
mode is an optional number. Use one of:
game.MAP_CHECK - don't load the map if it isn't in memory,
returns nil if the map wasn't in memory.
game.MAP_NEW - if the map is already in memory, force an
immediate reset; then (re)load it.
Return : map pointer to map, or nil
Gotcha : Only valid on players.

Back to the index


object:Remove()

Takes the object out of whatever map or environment it is in. The
object can then be inserted or teleported somewhere else, or just
left alone for the garbage collection to take care of.
The method takes no arguments.
Note : This method does not handles stacks properly. Do not be tempted
to use object:Remove() as a shortcut for `
object:DecreasNrOf(object.quantity) or vice versa.
Also : If you want reduce the quantity of a stack, use
object:DecreaseNrOf(). If you want to represent the destruction
of an object, use object:Destruct().

Back to the index


object:RemoveBuff(buffname, nrof)

Parameter types:
buffname: string (required)
nrof: integer (optional)

Removes the specified amount of a buff. Nrof 0 means remove all.
Returns:
BUFF_ADD_BAD_PARAMS - Something was null
BUFF_ADD_EXISTS - That buff doesn't exist (poorly-named)
BUFF_ADD_SUCCESS - Success

Back to the index


object:RemoveQuestItem(nrof)

Parameter types:
nrof: integer (optional)

removes the items from the players inventory.
Get the template info from the kill target obj inventory
NOTE: the function tries to remove given objects even when there,
are not enough! count them before calling this function.

TODO: I am very unhappy with this function. It does not work well and
in fact I am not clear why it is not done automatically when a
quest is finished or skipped anyway; AFAICS there is never a need
to call it explicitly anyway. Will be addressed in SEQSy.

Back to the index


object:Repair(skill_nr)

Parameter types:
skill_nr: integer (optional)

Back to the index


object:Save()

Back to the index


object:Say(message, mode, range)

Parameter types:
message: string (required)
mode: integer (optional)
range: integer (optional)

object says message to players within range or to all on its map
mode: 0 (default) talk to object - adds a "xxx says:" as prefix
mode: 1 raw message
range: MAP_INFO_NORMAL (default) limited range (within 12 tiles)
range: MAP_INFO_ALL all players on map
Note : If range is specified, mode must also be explicitly specified.

Back to the index


object:SayTo(target, message, mode, range)

Parameter types:
target: object (required)
message: string (required)
mode: integer (optional)
range: integer (optional)

NPC talks only to player but map may get a "xx talks to" msg too
(depends on mode).
mode: 0 (default) talk to object - adds a "xxx says:" as prefix
mode: 1 raw message
mode: 2 adds as global map msg: xxx talks to yyy (was b3 default)
range: MAP_INFO_NORMAL (default) limited range (within 12 tiles)
range: MAP_INFO_ALL all players on map
Note : If range is specified, mode must also be explicitly specified.
range is only meaningful when mode = 2, and defines range of
"talks to" message.

Back to the index


object:SendCustomCommand(customcommand)

Parameter types:
customcommand: string (required)

Back to the index


object:SetAlignment(alignment_string)

Parameter types:
alignment_string: string (required)

Back to the index


object:SetAnimation(anim)

Parameter types:
anim: string (required)

Sets object's animation.
Note that an object will only be animated if object.f_is_animated
is true

Back to the index


object:SetCombatMode(mode)

Parameter types:
mode: unknown (required)

Only works for player objects. Other types generate an error.
The mandatory argument is true to turn on combat mode, false to
turn it off.
The return is the new combat mode (so true or false).

Back to the index


object:SetFace(face)

Parameter types:
face: string (required)

Sets object's face.
If the object is animated (object.f_is_animated == true), then
this value will likely be replaced at the next animation step

Back to the index


object:SetGender(gender)

Parameter types:
gender: integer (required)

Changes the gender of object. gender_string should be one of
game.NEUTER, game.MALE, game.GENDER_FEMALE or
game.HERMAPHRODITE

Back to the index


object:SetGod(godname)

Parameter types:
godname: string (required)

Back to the index


object:SetInvAnimation(anim)

Parameter types:
anim: string (required)

Sets object's inventory animation.
Note that an object will only be animated if object.f_is_animated
is true

Version notes: Introduced in beta 4 pre4

Back to the index


object:SetInvFace(face)

Parameter types:
face: string (required)

Sets object's inventory face.
If the object is animated (object.f_is_animated == true), then
this value will likely be replaced at the next animation step

Version notes: Introduced in beta 4 pre4

Back to the index


object:SetPersonalLight(mode)

Parameter types:
mode: integer (required)

Only works for player objects. Other types generate an error.
The mandatory argument is the personal light value to set (this
will be normalised to the range 0 <= value <= MAX_DARKNESS). A
value of 0 means turn it off.
The return is the new personal light setting.

Back to the index


object:SetPosition(map, x, y, oflags)

Parameter types:
map: map (required)
x: integer (required)
y: integer (required)
oflags: integer (optional)

Teleports op to x,y of object.map or map (when given) according
to flags and ins_flags.
WARNING: a script developer must have in mind that SetPosition()
can result in the destruction of the transferred object. The
return value is important to check!
oflags are:
game.OVERLAY_IGNORE_TERRAIN
game.OVERLAY_WITHIN_LOS
game.OVERLAY_FORCE
game.OVERLAY_FIRST_AVAILABLE
game.OVERLAY_FIXED
game.OVERLAY_RANDOM
game.OVERLAY_SPECIAL
The default is OVERLAY_RANDOM | OVERLAY_SPECIAL which basically
means insert at the first free spot within a three square radius
of x, y. A common alternative is OVERLAY_FIXED which means
insert at x, y if free only. Many more complex variations can be
specified and will be documented in future.
Examples:
obj:SetPosition(x, y) - same as obj:SetPosition(obj.map, x,y)
obj:SetPosition(game:ReadyMap("/a_map"), x, y) - multiplayer map
obj:SetPosition(obj:StartNewInstance("/another_map"), x, y)
obj:SetPosition(obj.map:ReadyInheritedMap("/map_2"), x, y)
Return : 0: all ok, 1: object was destroyed, 2: insertion failed (map or
position error, ...)

TODO: Better document oflags.

Back to the index


object:SetQuestStatus(status, step_id)

Parameter types:
status: integer (required)
step_id: integer (optional)

We need this function because quest_trigger must be moved
q_status: -1 = done, q_type: can change type (kill, normal..)
Common call is SetQuestStatus(-1) to "finish"/neutralize a quest

Back to the index


object:SetRank(rank_string)

Parameter types:
rank_string: string (required)

Set the rank of an object to rank_string
Rank string 'Mr' is special for no rank

Back to the index


object:SetSaveBed(map, x, y)

Parameter types:
map: map (required)
x: integer (required)
y: integer (required)

Sets the current savebed position for object to the specified
coordinates on the map.

Back to the index


object:SetSkill(type, nr, level, exp)
object:SetSkill(name, level, exp)
object:SetSkill(object, level, exp)

Parameter types:
type: integer (required)
nr: integer (required)
level: integer (required)
exp: integer (required)

Tries to change a skill's experience and/or level.
The type argument must be either game.TYPE_SKILL for a particular
skill or game.TYPE_SKILLGROUP for a skill group. nr must be a
legal value accordingly. If type is TYPE_SKILLGROUP this
translates to the player's best skill in that skill group.
For particular skills, the second form of call may be used where
the string name is internally translated into a skill number.
For both skills and skillgroups, the third form of call may be
used. Again, all necessary translations and validations are
done internally.
The level and exp are arguments are what you'd expect. Note that
these (a) are relative (so X means the skill *gains* X, (b) may
be negative (loss is a possible as gain, and (c) limited (a skill
may gain to no more than the threshold of the next level or lose
to no more than 1 exp under the threshold of the current level or
gain/lose no more than 1 level).
There are 3 varieties of skill: non-leveling skills do not
gain/lose levels or exp (you either have them or you don't, eg,
common literacy); direct skills gain/lose levels directly (eg,
find traps); indirect skills accumulate exp which means the skill
gains/loses levels as the total crosses certain thresholds (eg,
punching).
Various major problems with the arguments generate Lua errors
(such as if object is not a player or nr is negative).
When an indirect skill gains any amount of exp via this method,
cannot subsequently gain more exp via a script until it reaches a
different level. This means player's cannot exploit scripts to
constantly gain experience; scripts augment normal grinding.
Four values are returned: a game constant number representing
success or failure (see below); the skill object or nil; a number
(the level gain/loss; a number (the exp gain/loss).
This first return is one of:
game.SUCCESS - success;
game.FAILURE_NOSKILL - failure (the player has no such
skill);
game.FAILURE_NONLEVELING - failure (the skill is
non-leveling);
game.FAILURE_MAXLEVEL - failure (the skill is direct or
indirect but has already reached maximum level);
game.FAILURE_INDIRECT_NO - failure (the skill is indirect and
has already gained experience via this method this
level).
On any failure, level and exp return as 0. On success they are
the actual amounts gained/lost (so may be different than the
arguments going in).

Back to the index


object:SetTarget(target)

Parameter types:
target: integer (required)

Only works for player objects. Other types generate an error.
The mandatory argument is a number, a string, or an object.
If a number, it should be one of the game.TARGET_* constants. The
*next* available target of that kind is targeted, according to
the normal rules.
If a string (it is case sensitive), all available enemies then
friends are targeted until one with a name matching the string is
found.
If an object, that object is targeted, if possible.
The return is the object which is the new target, or nil.

TODO: To be expanded to handle monsters.

Back to the index


object:ShowCost(value)

Parameter types:
value: big integer (64 bit) (required)
integer: integer (optional)

Returns a string describing value as x gold, x silver, x copper
mode 0: "4 gold coins, 3 silver coins, ..." (default)
mode 1: "4g, 3s, ..."

Back to the index


object:Sound(x, y, soundnumber, soundtype)

Parameter types:
x: integer (required)
y: integer (required)
soundnumber: integer (required)
soundtype: integer (optional)

play the sound for the given player only, sounding like it comes
from the given x,y coordinates.
If soundtype is game.SOUNDTYPE_NORMAL (the default), then
soundnumber should be one of the game.SOUND_xxx constants
If soundtype is game.SOUNDTYPE_SPELL, then the sound number
should be a spell number, to play the sound of that spell

Back to the index


object:StartNewInstance(path, mode)

Parameter types:
path: string (required)
mode: integer (optional)
integer: integer (optional)

Reloads or creates an instance for a player based on the map
loaded from path.
path is a required string. It must be an absolute path.
mode is an optional number. Use one of:
game.MAP_CHECK - don't load or create the instance if it isn't
active. Returns boolean if instance is valid
or not.
game.MAP_NEW - always create a new instance and delete any
instance the player had active.
NOTE 1: resetting an instance does not simply reset the maps, it
creates a wholly new instance for the player.
NOTE 2: a player can only have a single active instance. If a
second instance is loaded, the first one will be reset.
NOTE 3: an instance is identified by the player and entrance map.
To simulate multiple entrance maps for a single instance,
always first load the entrance map, then load a secondary
entrance with ReadyInheritedMap()
Return : If mode != game.MAP_CHECK, map pointer to the entrance map of the
instance, or nil.
If mode == game.MAP_CHECK, boolean.
Gotcha : Only valid on players.

Back to the index


object:UpdateQuest(name, text)

Parameter types:
name: string (required)
text: string (required)

Only works for player objects. Other types generate an error.
Updates name quest for player object with text string.
Return : nil if the named quest has not been undertaken by player, or true
or false otherwise to indicate whether the update was successful.

Back to the index


object:Withdraw(what, string)

Parameter types:
what: object (required)
string: string (required)

Only works for players and monster objects. Other types generate
an error.
Withdraws an amount of money (as described by string) from what
(a bank force) to object's inventory.
Return : nil if there was a syntax error in string; false if there was not
sufficient money in what; true if the withdrawal succeeded (and
what->value is updated).

Back to the index


object:Write(message, ndif)

Parameter types:
message: string (required)
ndif: integer (optional)

Only works for player objects. Other types generate an error.
Writes a message to a specific player or group.
ndif should be zero or one game.NDI_COLR_* and/or zero or more
game.NDI_FLAG_*. The default ndif is game.NDI_COLR_WHITE.
As a special case, if ndif includes game.NDI_FLAG_GSAY it is sent
to all OTHER members of the player's group, if any, and is always
yellow.
game.NDI_FLAG_VIM should be used *very* sparingly, if at all.
Note : The Lua language cannot do bitwise operations but it is fine to
add the ndif values.

Back to the index