Difference between revisions of "Lua API:Simulation"

From The Powder Toy
Jump to: navigation, search
m
m (Constants)
Line 48: Line 48:
  
 
== Constants ==
 
== Constants ==
 +
Any of these constants can be accessed with simulation.<constant name here>
 +
 +
=== DECO ===
 +
; DECO_DIVIDE
 +
; DECO_SMUDGE
 +
; DECO_ADD
 +
; DECO_SUBTRACT
 +
; DECO_CLEAR
 +
; DECO_DRAW
 +
; DECO_MULTIPLY
 +
 +
=== FIELD ===
 +
; FIELD_DCOLOUR
 +
; FIELD_Y
 +
; FIELD_TEMP
 +
; FIELD_TYPE
 +
; FIELD_VY
 +
; FIELD_X
 +
; FIELD_TMP2
 +
; FIELD_TMP
 +
; FIELD_FLAGS
 +
; FIELD_VX
 +
; FIELD_CTYPE
 +
; FIELD_LIFE
 +
 +
=== MAX ===
 +
; MAX_TEMP
 +
 +
=== MIN ===
 +
; MIN_TEMP
 +
 +
=== NUM ===
 +
; NUM_PARTS
 +
 +
=== PT ===
 +
; PT_NUM
 +
 +
=== R ===
 +
; R_TEMP
 +
 +
=== TOOL ===
 +
; TOOL_VAC
 +
; TOOL_AIR
 +
; TOOL_NGRV
 +
; TOOL_PGRV
 +
; TOOL_HEAT
 +
; TOOL_WIND
 +
; TOOL_COOL
 +
 +
=== Uncategorized ===
 +
; YRES
 +
; XRES

Revision as of 20:39, 29 September 2013

The Simulation API allows for modifying the state and properties of particles, air and gravity

Methods

simulation.partNeighbours

number ... sim.partNeighbours(number x, number y, number radius, [number type])

Returns a list of particles indexes that neighbour the given coordinates that matches the given type (if it is specified) The resulting list does not contain the "origin particle"

simulation.partChangeType

nil sim.partChangeType(number index, number type)

Reliably change the type of a particle, this method avoids the side effects created by changing the type directly with the "partProperty" method.

simulation.partKill

nil sim.partKill(number index)
nil sim.partKill(number x, number y)

Reliably delete a particle at a specified index or location, this method avoids the side effects created by changing the type to 0/DEFAULT_PT_NONE with the "partProperty" method

simulation.partProperty

nil sim.partProperty(number index, object field, object value)

Set the property value on a particle specified by index

object sim.partProperty(number index, object field)

Get the property value on a particle specified by the index

The "field" may be a field name or field ID, see [bottom of page] for more information

simulation.partID

number sim.partID(number x, number y)

Get the index of a particle at the specified position

simulation.partPosition

number x, number y sim.partPosition(number index)

Get the location of the particle at the specified index

simulation.partCreate

Derp!

simulation.ambientHeat

simulation.pressure

simulation.velocityX

simulation.velocityY

simulation.gravMap

Constants

Any of these constants can be accessed with simulation.<constant name here>

DECO

DECO_DIVIDE
DECO_SMUDGE
DECO_ADD
DECO_SUBTRACT
DECO_CLEAR
DECO_DRAW
DECO_MULTIPLY

FIELD

FIELD_DCOLOUR
FIELD_Y
FIELD_TEMP
FIELD_TYPE
FIELD_VY
FIELD_X
FIELD_TMP2
FIELD_TMP
FIELD_FLAGS
FIELD_VX
FIELD_CTYPE
FIELD_LIFE

MAX

MAX_TEMP

MIN

MIN_TEMP

NUM

NUM_PARTS

PT

PT_NUM

R

R_TEMP

TOOL

TOOL_VAC
TOOL_AIR
TOOL_NGRV
TOOL_PGRV
TOOL_HEAT
TOOL_WIND
TOOL_COOL

Uncategorized

YRES
XRES