aboutsummaryrefslogtreecommitdiff
path: root/build/android/src
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-03-31 23:30:44 -0400
committerkwolekr <kwolekr@minetest.net>2015-03-31 23:30:44 -0400
commit699e066beab969156223eb3b04cc04fde091fca2 (patch)
treeb5ce51c951ee2982d9cca73e4b0ab8db0ee06de8 /build/android/src
parent337e79c656a12bcf0dac4b25d5f0e021188e383a (diff)
downloadminetest-699e066beab969156223eb3b04cc04fde091fca2.tar.gz
minetest-699e066beab969156223eb3b04cc04fde091fca2.tar.bz2
minetest-699e066beab969156223eb3b04cc04fde091fca2.zip
Fix set_bits
Diffstat (limited to 'build/android/src')
0 files changed, 0 insertions, 0 deletions
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215

#### Advtrains - Lua Automation features

This mod offers components that run LUA code and interface with each other through a global environment. It makes complex automated railway systems possible.

### atlatc
The mod is sometimes abbreviated as 'atlatc'. This stands for AdvTrainsLuaATC. This short name has been chosen for user convenience, since the name of this mod ('advtrains_luaautomation') is very long.

### Privilege
To perform any operations using this mod (except executing operation panels), players need the "atlatc" privilege.
This privilege should never be granted to anyone except trusted administrators. Even though the LUA environment is sandboxed, it is still possible to DoS the server by coding infinite loops or requesting expotentially growing interrupts. 

### Active and passive
Active components are these who have LUA code running in them. They are triggered on specific events. Passive components are dumb, they only have a state and can be set to another state, they can't perform actions themselves.

### Environments

Each active component is assigned to an environment. This is where all data are held. Components in different environments can't inferface with each other.
This system allows multiple independent automation systems to run simultaneously without polluting each other's environment.

/env_create <env_name>
Create environment with the given name. To be able to do anything, you first need to create an environment. Choose the name wisely, you can't change it afterwards.

/env_setup <env_name>
Invoke the form to edit the environment's initialization code. For more information, see the section on active components. You can also delete an environment from here.

### Active components

The code of every active component is run on specific events which are explained soon. When run, every variable written that is not local and is no function or userdata is saved over code re-runs and over server restarts. Additionally, the following global variables are defined:

# event
The variable 'event' contains a table with information on the current event. How this table can look is explained below.

# S
The variable 'S' contains a table which is shared between all components of the environment. Its contents are persistent over server restarts. May not contain functions, every other value is allowed.
Example:
Component 1: S.stuff="foo"
Component 2: print(S.stuff)
-> foo

# F
The variable 'F' also contains a table which is shared between all components of the environment. Its contents are discarded on server shutdown or when the init code gets re-run. Every data type is allowed, even functions.
The purpose of this table is not to save data, but to provide static value and function definitions. The table should be populated by the init code.

# Standard Lua functions
The following standard Lua libraries are available:
string, math, table, os
The following standard Lua functions are available:
assert, error, ipairs, pairs, next, select, tonumber, tostring, type, unpack

Every attempt to overwrite any of the predefined values results in an error.

# LuaAutomation-specific global functions

POS(x,y,z)
Shorthand function to create a position vector {x=?, y=?, z=?} with less characters

In the following functions, all parameters named 'pos' designate a position. You can use either:
- a default Minetest position vector (like {x=34, y=2, z=-18})
- the POS(34,2,-18) shorthand
- A string, the passive component name. See 'passive component naming'.

getstate(pos)
Get the state of the passive component at position 'pos'. See section on passive components for more info.
pos can be either a position vector (created by POS()) or a string, the name of this passive component.

setstate(pos, newstate)
Set the state of the passive component at position 'pos'.

is_passive(pos)
Checks whether there is a passive component at the position pos (and/or whether a passive component with this name exists)

interrupt(time, message)
Cause LuaAutomation to trigger an 'int' event on this component after the given time in seconds with the specified 'message' field. 'message' can be of any Lua data type.
Not available in init code!

interrupt_pos(pos, message)
Immediately trigger an 'ext_int' event on the active component at position pos. 'message' is like in interrupt().
USE WITH CARE, or better don't use! Incorrect use can result in expotential growth of interrupts.

digiline_send(channel, message)
Make this active component send a digiline message on the specified channel.
Not available in init code!

-- The next 4 functions are available when advtrains_interlocking is enabled: --

can_set_route(pos, route_name)
Returns whether it is possible to set the route designated by route_name from the signal at pos.

set_route(pos, route_name)
Requests the given route from the signal at pos. Has the same effect as clicking "Set Route" in the signalling dialog.

cancel_route(pos)
Cancels the route that is set from the signal at pos. Has the same effect as clicking "Cancel Route" in the signalling dialog.

get_aspect(pos)
Returns the signal aspect of the signal at pos. A signal aspect has the following format:
aspect = {
	main = { -- the next track section in line. Shows blocked for shunt routes
		free = <boolean>,
		speed = <int km/h>,
	},
	shunt = { -- whether a "shunting allowed" aspect should be shown
		free = <boolean>,
	}
	dst = { -- the aspect of the next main signal on (at end of) route
		free = <boolean>,
		speed = <int km/h>,
	}
	info = {
		call_on = <boolean>, -- Call-on route, expect train in track ahead
		dead_end = <boolean>, -- Route ends on a dead end (e.g. bumper)
	}
}
As of August 2018, only the aspect.main.free field is ever used by the interlocking system.

## Components and events

The event table is a table of the following format:
{
	type = "<type>",
	<type> = true,
	... additional content ...
}
You can check for the event type by either using
if event.type == "wanted" then ...do stuff... end
or
if event.wanted then ...do stuff... end
(if 'wanted' is the event type to check for)

# Init code
The initialization code is not a component as such, but rather a part of the whole environment. It can (and should) be used to make definitions that other components can refer to.
Examples: