buldthensnip/docs/modding_lua.txt
2012-11-05 20:16:19 +13:00

95 lines
2.6 KiB
Plaintext

work in progress
libraries are "client" and "server"
stuff in both is also put in "common"
note, behaviour might be subtly different
all files must use "/" as a path separator (Unix Master Race)
valid characters are listed here (ignoring the path separator):
-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_abcdefghijklmnopqrstuvwxyz
anything else is invalid and will just be outright rejected
maximum path length is 128
stuff that's actually implemented will be marked with an @
lua base library stuff:
math.* @
string.* @
pcall @
error @
print @
loadstring @
nothing else yet
(TODO: stop leaking the whole base library)
check http://www.lua.org/manual/5.1/ for more info on these
client/server.hook_tick = fn(sec_curtime, sec_delta)->sec_wait @
sets a hook called every "tick"
returns a number telling it how long it wants to wait for
"sec_curtime" is the current time elapsed from the start
"sec_delta" is the time elapsed from the start of the last
call to the hooked function
setting this to nil will quit your game
NOTE: DO NOT USE COMMON FOR THIS HOOK!
(only client/server is accepted)
client.hook_key = fn(key, state) @
sets a hook called every time a key changes
state is either true or false
success = server.stream_new_map(fname, fmt = "auto")
loads a map, either .vxl or some format we might invent
which will probably be .vxl with our own header
+ changed meaning for the 4th colour byte
this will also send the map to the other clients
success = server.create_new_map(lx, ly, lz)
creates a new map
note, ly is the *height* of the new map
also all dimensions must be powers of two,
otherwise this will fail horribly!
success = common.save_map(fname, fmt = "bsm")
saves a map to a file
lx, ly, lz = common.get_map_dims() @
gets the map's dimensions
these will be nil if there is no map loaded
table = common.get_map_pillar(px, pz) @
returns a full pillar of data, skipping the total size header
this will be nil if there is no map loaded
note, the data wraps around here!
client.camera_point(dx, dy, dz, zoom = 1.0, roll = 0.0) @
points the camera in a direction with zoom factor "zoom"
and roll "roll" (in radians, sorry)
client.camera_move_local(dx, dy, dz) @
moves the camera in the camera-local direction (dx,dy,dz)
client.camera_move_global(dx, dy, dz) @
moves the camera in the world direction (dx,dy,dz)
client.camera_move_to(px, py, pz) @
moves the camera to the world position (px,py,pz)
px, py, pz = client.camera_get_pos() @
gets the camera's position
dx, dy, dz = client.camera_get_forward() @
gets the camera's forward vector