API/sides: Difference between revisions
Jump to navigation
Jump to search
Clean up Markdown artifacts from DokuWiki migration |
Clean up page from mechanical import |
||
| Line 3: | Line 3: | ||
This "API" provides a global table to allow you to refer to sides / directions by name, as opposed to their numbers. The underlying number values are identical to Minecraft's internal numbering (as well as the <code>ForgeDirection</code> Enum). This table serves as a two-directional look-up, so you can resolve names to numbers, but also numbers back to a human readable name. For example, <code>sides.top</code> has the value <code>1</code>, whereas <code>sides[1]</code> has the string value <code>top</code>. A couple of aliases for the side names are available, so it's less likely to accidentally pick the wrong one. These are the basic values: | This "API" provides a global table to allow you to refer to sides / directions by name, as opposed to their numbers. The underlying number values are identical to Minecraft's internal numbering (as well as the <code>ForgeDirection</code> Enum). This table serves as a two-directional look-up, so you can resolve names to numbers, but also numbers back to a human readable name. For example, <code>sides.top</code> has the value <code>1</code>, whereas <code>sides[1]</code> has the string value <code>top</code>. A couple of aliases for the side names are available, so it's less likely to accidentally pick the wrong one. These are the basic values: | ||
* Bottom (<code>bottom</code>), Number: 0 | * Bottom (<code>bottom</code>), Number: 0 | ||
* Top (<code>top</code>), Number: 1 | |||
* Back (<code>back</code>), Number: 2 | |||
* Front (<code>front</code>), Number: 3 | |||
* Right (<code>right</code>), Number: 4 | |||
* Left (<code>left</code>), Number: 5 | |||
The following aliases are defined per default: | The following aliases are defined per default: | ||
* Bottom: <code>down</code>, <code>negy</code> | * Bottom: <code>down</code>, <code>negy</code> | ||
* Top: <code>up</code>, <code>posy</code> | |||
* Back: <code>north</code>, <code>negz</code> | |||
* Front: <code>south</code>, <code>posz</code>, <code>forward</code> | |||
* Right: <code>west</code>, <code>negx</code> | |||
* Left: <code>east</code>, <code>posx</code> | |||
Useful for setting or getting redstone outputs or inputs, for example: <syntaxhighlight lang="lua"> | Useful for setting or getting redstone outputs or inputs, for example: | ||
local component = require("component") local sides = require("sides") local rs = component.redstone rs.setOutput(sides.back, rs.getInput(sides.left)) | <syntaxhighlight lang="lua"> | ||
local component = require("component") | |||
local sides = require("sides") | |||
local rs = component.redstone | |||
rs.setOutput(sides.back, rs.getInput(sides.left)) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 22:15, 14 October 2026
Sides API
This "API" provides a global table to allow you to refer to sides / directions by name, as opposed to their numbers. The underlying number values are identical to Minecraft's internal numbering (as well as the ForgeDirection Enum). This table serves as a two-directional look-up, so you can resolve names to numbers, but also numbers back to a human readable name. For example, sides.top has the value 1, whereas sides[1] has the string value top. A couple of aliases for the side names are available, so it's less likely to accidentally pick the wrong one. These are the basic values:
- Bottom (
bottom), Number: 0 - Top (
top), Number: 1 - Back (
back), Number: 2 - Front (
front), Number: 3 - Right (
right), Number: 4 - Left (
left), Number: 5
The following aliases are defined per default:
- Bottom:
down,negy - Top:
up,posy - Back:
north,negz - Front:
south,posz,forward - Right:
west,negx - Left:
east,posx
Useful for setting or getting redstone outputs or inputs, for example:
local component = require("component")
local sides = require("sides")
local rs = component.redstone
rs.setOutput(sides.back, rs.getInput(sides.left))Contents
| APIs | |
|---|---|
| OpenOS | buffer - colors - component - computer - event - filesystem - uuid - internet - keyboard - note - process - rc - robot - serialization - shell - sides - term - text - thread - transforms - unicode |
| Lua Libraries | coroutine - package - io - os |