class Object

class Object
ActionCloseDoor(door)

An action that causes an object to close a door.

Parameters:
  • door (Door) – Door to close
ActionGiveItem(item, target)

Gives a specified item to a target creature.

Parameters:
  • item (Item) – Item to give.
  • target (Object) – Receiver
ActionLockObject(target)

An action that will cause a creature to lock a door or other unlocked object.

Parameters:
  • target (Door or Placeable) – Door or placeable object that will be the target of the lock attempt.
ActionOpenDoor(door)

An action that will cause a creature to open a door.

Parameters:
  • door (Door) – Door to close
ActionPauseConversation()

Pause the current conversation.

ActionResumeConversation()

Resume a conversation after it has been paused.

ActionSpeakString(message[, volume])

Causes an object to speak.

Parameters:
  • message (string) – String to be spoken.
  • volume (int) – VOLUME_* constant. Default: VOLUME_TALK
ActionSpeakStringByStrRef(strref, volume)

Causes the creature to speak a translated string.

Parameters:
  • strref (int) – Reference of the string in the talk table.
  • volume (int) – VOLUME_* constant. Default: VOLUME_TALK
ActionStartConversation(target[, dialog[, private[, hello]]])

Action to start a conversation with a PC

Parameters:
  • target (Object) – An object to converse with.
  • dialog (string) – The resource reference (filename) of a conversation. Default: “”
  • private (bool) – Specify whether the conversation is audible to everyone or only to the PC. Default: false
  • hello (bool) – Determines if initial greeting is played. Default: true
ActionTakeItem(item, target)

Takes an item from an object.

Parameters:
  • item (Item) – The item to take.
  • target (Object) – The object from which to take the item.
ActionUnlockObject(target)

Causes a creature to unlock a door or other locked object.

Parameters:
  • target (Door or Placeable) – Door or placeable object that will be the target of the unlock attempt.
ActionWait(time)

Adds a wait action to an objects queue.

Parameters:
  • time (float) – Time in seconds to wait.
ApplyEffect(dur_type, effect, duration)

Applies an effect to an object.

Parameters:
  • dur_type (int) – DURATION_TYPE_* constant.
  • effect (Effect) – Effect to apply.
  • duration (float) – Time in seconds for effect to last. Default: 0.0
ApplyVisual(vfx, duration)

Applies visual effect to object.

Parameters:
  • vfx (int) – VFX_* constant.
  • duration (float) – Duration in seconds. If not passed effect will be of duration type DURATION_TYPE_INSTANT
AssignCommand(f)

Assigns a command to an object.

Note

No longer really necessary as all actions are explicitly assigned.

Parameters:
  • f (function) – A closure.
BeginConversation(target, conversation)

Begin conversation.

Parameters:
  • target – Object to converse with
  • conversation (string) – Dialog resref. Default: “”
ChangeFaction(faction)

Changes objects faction.

Parameters:
  • faction (Object) – Object of desired faction.
CheckType(...)

Checks object type.

Parameters:
  • ... – Any number of OBJECT_TYPE_* constants
ClearAllActions([clear_combat])

Removes all actions from an action queue.

Parameters:
  • clear_combat (bool) – combat along with all other actions. Default: false.
Copy(location, owner, tag)

Copies an object

Parameters:
  • location – Location to copy the object to.
  • owner – Owner of the object
  • tag (string) – Tag of new object. Default: “”
CountItem(id[, resref])

Get number of items that an object carries.

Parameters:
  • id (string) – Tag or Resref.
  • resref (bool) – If true count by resref. Default: false
DecrementLocalInt(name, val)

Decrements local integer variable.

Parameters:
  • name (string) – Variable name.
  • val (int) – Amount to decrement. Default: 1
Return type:

New value.

DelayCommand(delay, action)

Delays a command.

Parameters:
  • delay (float) – Time in seconds.
  • action (function) – A closure.
DeleteLocalBool(name)

Boolean wrapper around DeleteLocalInt Int/Bool values are stored under the same name

Parameters:
  • name (string) – Variable name.
DeleteLocalFloat(name)

Delete a local float variable

Parameters:
  • name (string) – Variable to delete
DeleteLocalInt(name)

Delete a local int variable

Parameters:
  • name (string) – Variable name.
DeleteLocalLocation(name)

Delete a local location variable

Parameters:
  • name (string) – Variable to delete
DeleteLocalObject(name)

Delete a local object variable

Parameters:
  • name (string) – Variable to delete
DeleteLocalString(name)

Delete a local string variable

Parameters:
  • name (string) – Variable to delete
Destroy([delay])

Destroy an object.

Parameters:
  • delay (float) – Delay (in seconds) before object is destroyed. Default: 0.0
DoCommand(action)

Inserts action into action queue.

Parameters:
  • action (function) – A closure.
DoDamage(amount)
Effects([direct])

An iterator that iterates over applied effects.

Parameters:
  • direct (bool) – If true, the actual effect will be returned. Modifying it will modify the applied effect. If false, a copy of the effect will be returned.
FortitudeSave(dc, save_type, vs)

Do fortitude save.

Parameters:
  • dc (int) – Difficult class
  • save_type (int) –
  • vs (Object) – Save versus object
GetAllVars([match[, type]])

Get all variables. TODO: Document variable type constant.

Parameters:
  • match (string) – A string pattern for testing variable names. See string.find
  • type (int) – Get variables of a particular type.
GetArea()

Get area object is in.

GetCasterLevel()

Determines caster level.

GetColor(channel)
GetCommandable()

Get is object commandable.

GetCurrentAction()

Returns the currently executing Action.

GetCurrentHitPoints()

Gets an object’s current hitpoints

GetDescription([original[, identified]])

Get object’s description.

Parameters:
  • original (bool) – If true get original description. Default: false
  • identified (bool) – If true get identified description. Default: true
GetDistanceToObject(obj)

Get distance between two objects.

Parameters:
  • obj (Object) – Object to determine distance to.
GetEffectAtIndex(idx)

Get an effect.

Note

This returns effects directly. Modifying them will modify the applied effect.

Parameters:
  • idx (int) – Index is zero based.
Return type:

Effect or nil

GetEffectCount()

Get the number effects applied to an object;

GetFacing()

Get direction object is facing.

GetFactionAverageGoodEvilAlignment()
GetFactionAverageLawChaosAlignment()
GetFactionAverageLevel()
GetFactionAverageReputation(target)
GetFactionAverageXP()
GetFactionBestAC([visible])

Get faction member with best AC.

Parameters:
  • visible (bool) – If true member must be visible. Default: false.
GetFactionGold()

Get factions gold.

GetFactionId()

Gets an objects faction ID.

GetFactionLeader()
GetFactionLeastDamagedMember(visible)
GetFactionMostDamagedMember(visible)
GetFactionMostFrequentClass()
GetFactionStrongestMember(visible)
GetFactionWeakestMember(visible)
GetFactionWorstAC(visible)
GetFortitudeSavingThrow()

Get fortitude saving throw.

GetGold()

Get object’s gold.

GetHardness()

Determine object’s ‘hardness’.

GetHasEffectById(id)

Get if an object has an effect by ID.

Parameters:
  • id (int) – Effect ID.
GetHasInventory()

Determines if object has an inventory.

GetHasSpellEffect(spell)

Get if object has an effect applied by a spell.

Parameters:
  • spell (int) – SPELL_* constant.
GetIsDead()

Determine if dead.

GetIsImmune(immunity)

Determines if object is immune to an effect.

Parameters:
  • immunity (int) – IMMUNITY_TYPE_* constant.
Return type:

Always false.

GetIsInvulnerable()

Determine if object is invulnerable.

GetIsListening()

Get if object is listening.

GetIsOpen()

Get is object open.

GetIsTimerActive(name)

Determine if named timer is still active.

Parameters:
  • name (string) – Timer name.
Return type:

bool

GetIsTrapped()

Check whether an object is trapped.

Return type:bool
GetIsValid()

Determines if an object is valid.

GetItemPossessedBy(tag[, is_resref])

Determine if object has an item.

Parameters:
  • tag (string) – Object tag to search for
  • is_resref (bool) – If true search by resref rather than tag. Default: false
GetKeyRequired()

Determine if a key is required.

GetKeyRequiredFeedback()

Feedback for when missing key.

GetKiller()

Gets the object’s killer.

Return type:Object
GetLastAttacker()

Determine who last attacked a creature, door or placeable object.

GetLastDamager()

Get the object which last damaged a creature or placeable object.

GetLastHostileActor()

Gets the last living, non plot creature that performed a hostile act against the object.

GetLastOpenedBy()

Gets the last object to open an object.

GetLocalBool(name)

A wrapper around GetLocalInt returning false if the result is 0, true otherwise.

Parameters:
  • name (string) – Variable name
GetLocalFloat(name)

Get local float variable

Parameters:
  • name (string) – Variable name
GetLocalInt(name)

Get a local int variable

Parameters:
  • name (string) – Variable name
GetLocalLocation(name)

Get local location variable

Parameters:
  • name (string) – Variable name
GetLocalObject(name)

Get local object variable

Parameters:
  • name (string) – Variable name
GetLocalString(name)

Get local string

Parameters:
  • name (string) – Variable name.
GetLocalVarByIndex(index)

Get local variable by index. TODO: Return type???

Parameters:
  • index – Positive integer.
GetLocalVarCount()

Get local variable count.

GetLocation()

Get object’s location.

Return type:Location
GetLockDC()

Get lock’s DC.

GetLockKeyTag()

Get lock’s key tag.

Return type:string
GetLockable()

Get if object is lockable.

GetLocked()

Get if object is locked.

GetMaxHitPoints()

Get object’s max hitpoints.

GetName([original])

Get object’s name.

Parameters:
  • original (bool) – If true returns object’s original name, if false returns overridden name. Default: false.
GetNearestCreature(type1, value1, nth, ...)

Gets nearest creature by criteria types and values.

GetNearestObject([obj_type[, nth]])

Get nearest object.

Parameters:
  • obj_type (int) – OBJECT_TYPE_* constant. Default: OBJECT_TYPE_ALL
  • nth (int) – Which object to return. Default: 1
GetNearestObjectByTag(tag[, nth])

Get nearest object by tag.

Parameters:
  • tag (string) – Tag of object
  • nth (int) – Which object to return. Default: 1
GetNearestTrap(is_detected)

Get nearest trap.

Parameters:
  • is_detected (bool) – If true return only detected traps. Default: false.
GetPlotFlag()

Get plot flag.

GetPortraitId()

Get portrait ID.

GetPortraitResRef()

Get portrait resref.

Return type:string
GetPosition()

Get object’s position.

Return type:Vector
GetReflexSavingThrow()

Get reflex saving throw.

GetResRef()

Returns the Resref of an object.

Return type:string
GetSpellCastAtCaster()

Gets the caster of the last spell.

GetSpellCastAtHarmful()

Determine if the last spell cast at object is harmful.

GetSpellCastAtId()

Determine spell id of the last spell cast at object.

GetSpellCastClass()

Determine class of the last spell cast at object.

GetSpellCastItem()

Get item of that last spell cast.

GetSpellId()

Get spell id of that last spell cast.

GetSpellResistance()

Get spell resistance.

GetSpellSaveDC(spell)

Determine spell save DC.

Parameters:
  • spell (int) – SPELL_* constant.
GetSpellTargetLocation()

Get spell target location.

Return type:Location
GetSpellTargetObject()

Get last spell target.

Return type:Object
GetTag()

Determine the tag associated with an object.

Return type:string
GetTransitionTarget()

Gets transition target.

GetTrapBaseType()
GetTrapCreator()

Get traps creator

GetTrapDetectable()

Get if trap is detectable.

GetTrapDetectDC()

Get the DC required to detect trap.

GetTrapDetectedBy(creature)

Get if trap was detected by creature

GetTrapDisarmable()

Get if trap is disarmable

GetTrapDisarmDC()

Get DC required to disarm trap

GetTrapFlagged()

Get if trap is flagged

GetTrapKeyTag()

Get trap’s key tag

GetTrapOneShot()

Get if trap is oneshot

GetType()

Get an object’s type.

Return type:OBJECT_TYPE_* or OBJECT_TYPE_NONE on error.
GetUnlockDC()

Get lock unlock DC.

GetWillSavingThrow()

Get will saving throw.

GiveItem(resref[, stack_size[, new_tag[, only_once]])

Create a specific item in an objects inventory.

Parameters:
  • resref (string) – The blueprint ResRef string of the item to be created or tag.
  • stack_size (int) – The number of items to be created. Default: 1
  • new_tag (string) – If this string is empty (“”), it be set to the default tag from the template. Default: “”
  • only_once (bool) – If true, function will not give item if object already possess one. Default false
HasItem(tag)

Determines if an object has an item by tag.

Parameters:
  • tag (string) – Tag to search for.
IncrementLocalInt(name, val)

Increment local integer variable

Parameters:
  • name (string) – Variable name
  • val (int) – Amount to increment. Default: 1
Return type:

New local variable value.

Items()

Iterator over items in an object’s inventory.

LineOfSight(target)

Get is target in line of sight

Parameters:
  • target (Object) – Target to check.
ModifyCurrentHitPoints(amount)

Modifies an object’s current hitpoints.

Parameters:
  • amount (int) – Amount to modify.
OpenInventory(target)

Open Inventory of specified target

Parameters:
  • target – Creature to view the inventory of.
PlaySound(sound)

Causes object to play a sound

Parameters:
  • sound (string) – Sound to play
PlaySoundByStrRef(strref[, as_action])

Causes object to play a sound.

Parameters:
  • strref (int) – Sound to play
  • as_action (bool) – Determines if this is an action that can be stacked on the action queue. Default: true
ReflexSave(dc, save_type, vs)

Do reflex save.

Parameters:
  • dc (int) – Difficult class
  • save_type (int) –
  • vs (Object) – Save versus object
RemoveEffect(effect)

Removes an effect from object

Parameters:
  • effect (Effect) – Effect to remove.
RemoveEffectByID(id)

Removes an effect from object by ID

Parameters:
  • id (int) – Effect id to remove.
RemoveEffectsByType(type)

Remove effect by type.

Parameters:
  • type (int) – EFFECT_TYPE_*
ResistSpell(vs)

Attempt to resist a spell.

Parameters:
  • vs (Object) – Attacking caster
SetColor(channel, value)
SetCommandable([commandable])

Set is object commandable.

Parameters:
  • commandable (bool) – New value. Default: false.
SetCurrentHitPoints(hp)

Sets an object’s current hitpoints.

Parameters:
  • hp (int) – A number between 1 and 10000
SetDescription(description[, identified])

Set object’s description.

Parameters:
  • description (string) – New description.
  • identified (bool) – If true sets identified description. Default: true
SetFacing(direction)

Set direction object is facing in.

SetFacingPoint(target)

Set the point the object is facing.

Parameters:
  • target (Vector) – Vector position.
SetFactionId(faction)

Sets an objects faction ID.

Parameters:
  • faction (int) – New faction ID.
SetFortitudeSavingThrow(val)

Set fortitude saving throw.

Parameters:
  • val (int) – New value
SetHardness(hardness)

Sets an object’s hardness.

Parameters:
  • hardness (int) – New hardness value.
SetIsDestroyable([destroyable[, raiseable[, selectable]])
Parameters:
  • destroyable (bool) – Default: false
  • raiseable (bool) – Default: false
  • selectable (bool) – Default: true
SetKeyRequired(key_required)

Set lock requires key

Parameters:
  • key_required (bool) – If true key is required, if false not.
SetKeyRequiredFeedback(message)

Set feedback message

Parameters:
  • message (string) – Message sent when creature does not have the key
SetKeyTag(tag)

Set lock’s key tag

Parameters:
  • tag (string) – New key tag.
SetLastHostileActor(actor)

Sets the last hostile actor.

Parameters:
  • actor (Object) – New last hostile actor.
SetListenPattern(pattern, number)

Set listening patterns.

Parameters:
  • pattern (string) – Pattern to listen for.
  • number (int) – Number. Default: 0
SetListening(val)

Set object to listen or not.

Parameters:
  • val (bool) – New value.
SetLocalBool(name, val)

A wrapper around SetLocalInt.

Parameters:
  • name (string) – Variable name
  • val (bool) – Value
SetLocalFloat(name, val)

Set local float variable

Parameters:
  • name (string) – Variable name
  • val (float) – Value
SetLocalInt(name, val)

Set local int variable

Parameters:
  • name (string) – Variable name
  • val (int) – Value
SetLocalLocation(name, val)

Set local location variable

Parameters:
  • name (string) – Variable name
  • val (Location) – Value
SetLocalObject(name, val)

Set local object variable

Parameters:
  • name (string) – Variable name
  • val (Object) – Value
SetLocalString(name, val)

Set local string variable

Parameters:
  • name (string) – Variable name
  • val (string) – Value
SetLockDC(dc)

Set lock’s lock DC.

Parameters:
  • dc (int) – New DC.
SetLockLockable(lockable)

Set lock to be lockable.

Parameters:
  • lockable (bool) – if true lock can be locked, if false it can’t.
SetLocked(locked)

Set object locked

Parameters:
  • locked (bool) – If true object will be locked, if false unlocked.
SetMaxHitPoints(hp)

Sets an object’s max hitpoints.

Parameters:
  • hp (int) – New maximum hitpoints.
SetName([name])

Set object’s name.

Parameters:
  • name (string) – New name.
SetPlotFlag(flag)

Set object’s plot flag.

Parameters:
  • flag (bool) – If true object is plot. Default: false.
SetPortraitId(id)

Set portrait ID.

Parameters:
  • id (int) – Portrait ID
SetPortraitResRef(resref)

Set Portrait resref.

Parameters:
  • resref (string) – Portrait resref
SetReflexSavingThrow(val)

Set reflex saving throw

Parameters:
  • val (int) – New value.
SetTag(tag)

Changes an objects tag.

Parameters:
  • tag (string) – New tag.
SetTimer(var_name, duration[, on_expire])

Sets a timer on an object

Parameters:
  • var_name (string) – Variable name to hold the timer
  • duration (float) – Duration in seconds before timer expires.
  • on_expire (function) – Function which takes to arguments then object the timer was set on and the variable.
SetTrapDetectedBy(object[, is_detected])

Set whether an object has detected the trap

Parameters:
  • object (Creature) – the detector
  • is_detected (bool) – Default: false
SetTrapKeyTag(tag)

Set the trap’s key tag

Parameters:
  • tag (string) – New key tag.
SetUnlockDC(dc)

Set lock’s unlock DC.

Parameters:
  • dc (int) – New DC.
SetWillSavingThrow(val)

Set will saving throw.

Parameters:
  • val (int) – New value.
SpeakString(text, volume)

Forces an object to immediately speak.

Parameters:
  • text (string) – Text to be spoken.
  • volume (int) – VOLUME_* constant. Default: VOLUME_TALK
SpeakStringByStrRef(strref, volume)

Causes an object to instantly speak a translated string.

Parameters:
  • strref (int) – TLK string reference to speak.
  • volume (int) – VOLUME_* constant. Default: VOLUME_TALK
TakeItem(id[, count[, resref]])

Take an item from an object.

Note

This function handles stack size reduction. It also checks if the object posses enough of them before taking any.

Parameters:
  • id (string) – Tag or Resref.
  • count (int) – How many of the items to take. Default: 1
  • resref (bool) – If true take by resref. Default: false.
Return type:

Amount taken.

Trap(type, faction, on_disarm, on_trigger)

Traps an object.

Parameters:
  • type (int) – TRAP_BASE_TYPE_*
  • faction (int) – STANDARD_FACTION_*
  • on_disarm (string) – OnDisarmed script. Default: “”
  • on_trigger (string) – OnTriggered script. Default: “”
WillSave(dc, save_type, vs)

Do will save :param int dc: Difficult class :param int save_type: :param vs: Save versus object. :type vs: Object