Skip to content
MrChoke72 edited this page Jan 14, 2017 · 14 revisions

Index

damageTile

damageTile(level, x, y, direction, elevation, flags, damageType, power)

Damages all creatures including the party in a given tile. direction specifies the direction of the attack for projectiles or melee attacks (0=north, 1=east, 2=south, 3=west). damageType must be one of the following: "physical", "fire", "poison", "cold", "shock". Damage is rolled individually for all creatures using the power as base value. See also DamageFlags.

delayedCall

delayedCall(receiver, delay, functionName, ...)

Executes receiver.script.functionName(...) after delay in seconds. Accepts a variable number of arguments, but all arguments must be numbers or strings.

Example:

delayedCall("my_script_entity", 1.5, "doTheThing", "argument1", "argument2")

findEntity

findEntity(id)

Returns an entity with given id or nil if no such entity exists.

getDirection

getDirection(dx, dy)

Converts a delta-x and delta-y value (these are positive or negative differences in two square's coordinates) to a corresponding compass direction (0 to 3).

getForward

getForward(direction)

Converts direction, a number between 0 and 3 corresponding to a compass direction, to delta-x and delta-y values.

getMouseItem

getMouseItem()

Returns the "mouse item", the item attached to the mouse pointer. If there is no mouse item, nil is returned.

hudPrint

hudPrint(text)

Prints a line of text to the text area at the bottom of the screen.

iff

iff(cond, a, b)

Returns a if cond is true, otherwise returns b.

playSound

playSound(sound)

Plays a sound effect. sound must be a name of a built-in or custom sound effect.

playSoundAt

playSoundAt(sound, level, x, y)

Plays a sound effect at given position. sound must be a name of a built-in or custom sound effect.

print

print(...)

Prints all arguments to the console.

rollDamage

rollDamage(power)

Returns a random amount of damage for an attack with given power.

setMouseItem

setMouseItem(item)

Sets the given item as mouse item, or destroys the mouse item if item is nil.

shootProjectile

shootProjectile(projectile, level, x, y, direction, speed, gravity, velocityUp, offsetX, offsetY, offsetZ, attackPower, ignoreEntity, fragile, championOrdinal)

DOESN'T WORK IN LOG2

Shoots a projectile item. The parameters are:

  • projectile
    The name of the item to shoot.
  • level, x, y
    The initial position of the projectile in a level.
  • direction
    The shooting direction (0=north, 1=east, 2=south, 3=west).
  • speed
    The speed of the projectile (metres/second). Typical values around 10.
  • gravity
    The gravity force in y-direction. Typical values around 0.
  • velocityUp
    The initial velocity in y-direction. Typically set to 0.
  • offsetX, offsetY, offsetZ
    3D offset in world space from the center of cell.
  • attackPower
    Attack power of the projectile.
  • ignoreEntity
    The entity to be ignored for collisions (or nil if the entity should not ignore any collisions).
  • fragile
    A boolean flag, if set the projectile is destroyed on impact.
  • championOrdinal
    A champion ordinal number, used for dealing experience points. This parameter is optional.

spawn

spawn(object, level, x, y, facing, elevation, [id])

Spawns a new object at given position on a dungeon level where x and y specify the x- and y-coordinates on the map and level is a level index. facing must be a number between 0 and 3 and it indicates the following directions: 0=north, 1=east, 2=south, 3=west. id parameter is optional. If given it must be an unique id in the context of the dungeon. If not given an unique id is automatically generated.

toLocal

toLocal(ox, oy, facing, x, y)

Given original X and Y coordinates, facing, and new X and Y coordinates, returns delta X and delta Y values local to facing. Meaning these are the steps the party would need to take to get from original coordinates to new. For example, toLocal(1,2,0,3,5) returns (2,-3), the X and Y movement necessary for a party facing north to get from (1,2) to (3,5). A positive delta means walk forward or right. A negative means backward or left.

vec

vec(x, y, z, w)

Returns a new vector. All components are optional and default to 0.