[][src]Module sulis_state::script

This module contains Sulis' scripting API. Most structs are inserted into lua scripts as objects. The documentation for each struct describes the available functions on each object when interacting with them within a lua script.

There are currently four kinds of scripts:

  1. AI Scripts: These are attached to a given actor in their resource definition under ai. Whenever the parent entity is active, the ai_action(parent, state) method is called.
  2. Area / Trigger Scripts: These are called by triggers, conversations, and cutscenes. Named script functions are called, via a fire_script type containing an id for the script and a func.
  3. Ability Scripts: These are called when activating an ability or when an active ability meets certain conditions. The entry point for the script is on_activate(parent, ability). When using a targeter, on_target_select(parent, ability, targets) is the return from that targeter.
  4. Item Scripts: Similar to ability scripts, but called when using an item. The entry point is on_activate(parent, item).

Since standard Lua methods for referencing other script files will not work, Sulis includes a simple facility to include the contents of a script into another script. This is done with a line in the target script: --INCLUDE <other_script_id> The entire contents of the referenced script will be placed into the script file in place of the --INCLUDE directive at evaluation time. --INCLUDE directives are only evaluated one level deep at this time.

Re-exports

pub use self::script_callback::CallbackData;
pub use self::script_callback::FuncKind;
pub use self::script_callback::ScriptCallback;
pub use self::script_callback::ScriptHitKind;
pub use self::script_callback::TriggeredCallback;
pub use self::targeter::TargeterData;

Modules

script_cache
script_callback
targeter

Structs

AreaTargeter

A created AreaTargeter, built from a Targeter

InstructionState
ModuleExport

A data structure representing all data that will be transfered from this module to the specified subsequent module. This is created with game:create_module_export(module_id). It is assumed the player character will always be exported.

Script

Script Helper module for easily calling various script methods

ScriptAbility

Represents a specific active ability. This is passed into ability scripts in the ability field, and can also be obtained by iterating over a ScriptEntitySet

ScriptAbilitySet

Represents the set of abilities that a given Entity has access to. This will only include active abilities, not passive ones. See ScriptEntity

ScriptActiveSurface

Represents a surface that already exists, and is being passed into a Lua script. Not used during effect creation

ScriptAppliedEffect

An already applied effect, in contrast to an effect being created via ScriptEntity:create_effect

ScriptColorAnimation

A color animation changing a parent entity's base or secondary color. Created normally by ScriptEntity:create_color_anim

ScriptEffect

An effect, normally created via ScriptEntity:create_effect. The effect is then configured and then apply() is called.

ScriptEntity

Represents a single entity for Lua scripts. Also can represent an invalid, non-existant entity in some cases. Many script functions pass a parent which is a script entity, and often targets, which is a ScriptEntitySet that a ScriptEntity can be extracted from.

ScriptEntitySet

Represents a set of ScriptEntities, which can be created from a variety of sources. This is passed to many script functions as a targets variable. It includes a parent ScriptEntity, a list of target ScriptEntities, optionally a selected point (for a targeter that has been activated), and optionally a list of affected points (again for a targeter).

ScriptImageLayerAnimation

An animation that adds one or more ImageLayers to the parent creature for rendering. These override any racial or inventory image layers, with "empty" being used to hide an image layer on the parent. All layers are removed when the animation is complete.

ScriptInterface

The ScriptInterface, accessible in all Lua scripts as the global game. The following methods are available on this object (documentation WIP):

ScriptInventory

The inventory of a particular creature, including equipped items and quickslots.

ScriptItem

A ScriptItem, representing a specific item in a player or creature inventory, quick slot, or the party stash, depending on the ScriptItemKind. This is passed as the item field when using usable items with an associated script.

ScriptMenu

A user interface menu being created by a script. Normally created by game:create_menu()

ScriptMenuSelection

A user menu selection

ScriptParticleGenerator

A flexible animation type, which can be used to create particle effects, simple frame based animations, or anything in between. Typically created by ScriptEntity:create_particle_generator

ScriptScaleAnimation

An animation that changes the size of an entity. Normally created via ScriptEntity:create_scale_anim. Upon completion, the parent scale is set back to 1.0

ScriptStashItem

A representation of an item in the stash

ScriptState

A script state, containing a complete lua state.

ScriptSubposAnimation

An animation that moves the pixel precise coordinates of an entity. Normally created via ScriptEntity:create_subps_anim. When this animation is complete, the parent subpos is set back to the default, (0, 0)

ScriptUsableItem

A representation of an item that is usable and in a particular QuickSlot for a parent entity.

Enums

ScriptItemKind

A kind of Item, represented by its owner (Stash, QuickSlot, or a generic item with a specified ID)

Functions

entity_with_id

Type Definitions

Result