Skip to content
aubergine10 edited this page Oct 29, 2015 · 3 revisions

Overview

Each [Scriptable Object](Scriptable Objects) exposes multiple properties, some of which are dependent on the type of object. For example, Entity objects will have many properties that aren't found in Utility objects, and vice versa.

All kown properties are listed in the sidebar.

To find out which properties are available on standard game objects, see Objects.

Local object properties

You can access the properties of the object your script is associated with via [this](this (Global)), for example:

local x, y = this.Pos.x, this.Pos.y

this.Pos.x = x + 2 -- move two tiles to the right

External object properties

To access the properties of any other object, you must first obtain a reference to that object.

To do this use the .GetNearbyObjects() method; it returns a table where the keys are objects and the values are distances from the search origin to that object.

For example, if you wanted to shift the position of all nearby Prisoners two tiles to the right, you could do:

-- create a shortcut to the function for cleaner/faster code
local Find = this.GetNearbyObjects

for prisoner in next, Find( 'Prisoner', 5 ) do
  prisoner.Pos.x = prisoner.Pos.x + 2
end

##Custom Properties

You can define your own custom properties on objects, simply by setting the property name to a value. For example:

this.foo = 'bar' -- create this.foo and set value to 'bar'

To differentiate custom properties from standard game properties, name them with camelCase (properties defined by the game are always in PascalCase).

A custom property can be deleted by setting its value to nil, for example:

this.foo = nil -- delete this.foo

##Persistence

During the [Save-Load Cycle](Save-Load Cycle Guide), custom properties will only be persisted if they are of the following primitive data types:

  • boolean
  • number
  • string

Anything else will be discarded.

^ Open "Pages" to Search



Guides:

  • [Lua Basics](Lua Basics Guide)
  • [Save-Load Cycle](Save-Load Cycle Guide)

[Globals](Object Globals):

  • [Game](Game (Global))
  • [me](me (Global))
  • [Object](Object (Global))
  • [this](this (Global))

[Events](Object Events):

Psuedo-Types:

  • [Rotation table](Rotation table)
  • [Id table](Id table)
  • [Location table](Location table)
  • [Velocity table](Velocity table)

[Methods](Object Methods):

[Properties](Object Properties):

Clone this wiki locally