THIS IS AN INCOMPLETE DRAFT
These are the functions and variables exposed to the Lua puzzle programs
Lua puzzles should probably not rely on specific values for the STREAM_
and TILE_
constants.
STREAM_INPUT
= 2000. TIS
STREAM_OUTPUT
= 2001. TIS
STREAM_IMAGE
= 2002. TIS
TILE_COMPUTE
= 1000. TIS
TILE_MEMORY
= 1001. TIS
TILE_DAMAGED
= 1002. TIS
_VERSION
= "MoonSharp 0.9.5.0". Moon
assert(v [, message])
- Base If v
evaluates to false, causes compilation to fail. If message
is specified, it will be included as the error message. In theory could be caught using pcall
, but pcall
is not available in TIS-100. Of dubious use in puzzle Lua. Lua documentation.
collectgarbage([opt [, arg]])
- Base Interface for managing garbage collection. Of dubious use in puzzle Lua. Lua documentation.
error(message [, level])
- Base If opt
is not specified, is "collect", or "restart," forces the Lua interpreter to run a garbage collection pass. In theory could be caught using pcall
, but pcall
is not available in TIS-100. Of dubious use in puzzle Lua. Lua documentation.
ipairs(t)
- Base Iterates over the table t
as though it was an array, returning the keys 1, 2,... and their matching values until the next integer key is missing. Lua documentation. Example:
local input = { 1, 2, 3, 4, 5 }
local output = {}
for i,v in ipairs(input) do
output[i] = input[i] * 2
end
next(table [, index])
- Base Returns the next index and value from the table
. If index
is nil, returns the first index and value. Items in the table may be returned in any order. Adding a new index to the table may cause existing indices to be invalid. In most cases pairs()
or ipairs()
will be simpler. Lua documentation
pack(...)
- Moon Alias for table.pack
.
pairs(t)
- Base Iterates over all index value pairs in table t
. If the table is being used as an array with integer indices, ipairs()
may be a better solution. Lua documentation
print(...)
- Base Prints one or more values separated with tabs and terminated with a newline. Likely of dubious value in puzzle Lua. Lua documentation
select(index, ...)
- Base If index
is a integer value greater or equal to 1, returns remaining arguments from that point forward. Lua documentation
tonumber(e [, base])
- Base Return e
as a number. If base
is specified, e
is interpreted as being in that base. Return nil is e cannot be parsed. Lua documentation
tostring(v)
- Base Return v
as a string. Numbers are converted to a string representation. Functions and tables return "function: address" and "table: address" respectively. Lua documentation
type(v)
- Base Returns a string describing the type of v
. Responses include "string", "number", "boolean", "nil", "table", and "function". May return "userdata" or "thread" in some cases. Lua documentation
unpack(list [, i [, j]]))
- Moon Alias for table.unpack
.
A table containing the math library. The entire standard Lua math library is present.
math.pi
= 3.14159265358979 Base π
math.huge
= 1.79769313486232E+308 - Base The largest possible number Lua can represent.
math.abs
- Base Lua documentation
math.acos
- Base Lua documentation
math.asin
- Base Lua documentation
math.atan
- Base Lua documentation
math.atan2
- Base Lua documentation
math.ceil
- Base Lua documentation
math.cos
- Base Lua documentation
math.cosh
- Base Lua documentation
math.deg
- Base Lua documentation
math.exp
- Base Lua documentation
math.floor
- Base Lua documentation
math.fmod
- Base Lua documentation
math.frexp
- Base Lua documentation
math.ldexp
- Base Lua documentation
math.log
- Base Lua documentation
math.max
- Base Lua documentation
math.min
- Base Lua documentation
math.modf
- Base Lua documentation
math.pow
- Base Lua documentation
math.rad
- Base Lua documentation
math.random
- Base This is slightly different from the standard implementaiton; see math.random() for details. Lua documentation
math.randomseed
- Base Do not use: of dubious use in puzzle Lua. TIS-100 will handle seeding the random number generator to ensure the first three tests are constant. See the Puzzle Lua page for details. Lua documentation
math.sin
- Base Lua documentation
math.sinh
- Base Lua documentation
math.sqrt
- Base Lua documentation
math.tan
- Base Lua documentation
math.tanh
- Base Lua documentation
A table containing the bit manipulation library.
????The entire standard Lua math library is present.
bit32.extract
bit32.replace
bit32.arshift
bit32.rshift
bit32.lshift
bit32.band
bit32.btest
bit32.bor
bit32.bnot
bit32.bxor
bit32.lrotate
bit32.rrotate
Information about the MoonSharp implementation. It is recommended that Lua puzzles do not interact with these variables. The below values are from the Linux version of TIS-100 and may vary on other platforms.
is_aot
= false
is_clr4
= false
is_mono
= true
is_pcl
= false
is_unity
= true
luacompat
= "5.2"
platform
= "limited.unity.mono.clr2"
version
= "0.9.5.0"
_G
- Base Lua. A table containing all of these variables, tables, and functions, including _G
itself.
package.loaded
- package
only contains loaded
string
- Alias for string
table
- Alias for table
math
- Alias for math
bit32
- Alias for bit32
string
dump
char
byte
unicode
len
match
gmatch
gsub
find
lower
upper
rep
format
reverse
sub
table
unpack
pack
sort
insert
remove
concat
These functions are present in standard Lua, but are not available in TIS-100.
coroutine
debug
dofile
load
loadfile
loadstring
module
os
pcall
rawequal
rawget
rawlen
rawset
require
setmetatable
xpcall
Copyright Copyright 2015 Alan De Smet. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Fork this on GitHub!