Last active
January 22, 2017 07:34
-
-
Save mkarneim/4d55b3573209200edcf73e1dbbd442ce to your computer and use it in GitHub Desktop.
Sample Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OPPOSITE = {NORTH=SOUTH,EAST=WEST,SOUTH=NORTH,WEST=EAST,UP=DOWN,DOWN=UP,LEFT=RIGHT,RIGHT=LEFT,FORWARD=BACK,BACK=FORWARD} | |
ROTATE90CW = {NORTH=EAST,EAST=SOUTH,SOUTH=WEST,WEST=NORTH} | |
ROTATE90CCW = {NORTH=WEST,WEST=SOUTH,SOUTH=EAST,EAST=NORTH} | |
particleOn=0 | |
function vec3(x,y,z) | |
return {x=x,y=y,z=z} | |
end | |
function sleep(ticks) | |
runtime.sleep(ticks) | |
end | |
function getLuaTicksTotal() | |
return runtime.getLuaTicksTotal() | |
end | |
function getAllowance() | |
return runtime.getAllowance() | |
end | |
function register(...) | |
local vararg = {...} | |
return events.register(table.unpack(vararg)) | |
end | |
function say(...) | |
local vararg = {...} | |
cursor.say(table.unpack(vararg)) | |
end | |
function msg(e,m) | |
cursor.msg(e,m) | |
end | |
function pushLoc() | |
cursor.pushLocation() | |
end | |
function popLoc() | |
cursor.popLocation() | |
end | |
function move(dir,i) | |
i = i or 1 | |
cursor.move(dir,i) | |
end | |
function place(blk) | |
cursor.place(blk) | |
end | |
function rotate(dir) | |
cursor.rotate(dir) | |
end | |
function getBlock() | |
return cursor.getBlock() | |
end | |
function getWorldPos() | |
return cursor.getWorldPosition() | |
end | |
function getWorldPosVec3() | |
return vec3(cursor.getWorldPosition()) | |
end | |
function setWorldPos(x,y,z) | |
cursor.setWorldPosition(x,y,z) | |
end | |
function setWorldPosVec3(p) | |
cursor.setWorldPosition(p.x,p.y,p.z) | |
end | |
function setPos(x,y,z) | |
cursor.setPosition(x,y,z) | |
end | |
function getPos() | |
return cursor.getPosition() | |
end | |
function getOwnerPos() | |
return cursor.getOwnerPosition() | |
end | |
function getOwnerWorldPos() | |
return cursor.getOwnerWorldPosition() | |
end | |
function getOwnerName() | |
return cursor.getOwnerName() | |
end | |
function setOrientation(facing) | |
cursor.setOrientation(facing) | |
end | |
function getOrientation() | |
return cursor.getOrientation() | |
end | |
function getSurface() | |
return cursor.getSurface() | |
end | |
function cut(sel) | |
return cursor.cut(sel) | |
end | |
function copy(sel) | |
return cursor.copy(sel) | |
end | |
function copyBlock() | |
sel = {} | |
select(sel) | |
return copy(sel) | |
end | |
function paste(snap) | |
return cursor.paste(snap) | |
end | |
function moveBy(dx,dy,dz) | |
cursor.moveBy(dx,dy,dz) | |
end | |
function cmd(txt) | |
return cursor.execute(txt) | |
end | |
function bolt() | |
local x,y,z = getWorldPos() | |
cmd("summon LightningBolt "..x.." "..(y+1).." "..z.."") | |
end | |
function particle(name) | |
name = name or "instantSpell" | |
local x,y,z = getWorldPos() | |
cmd("particle "..name.." "..x.." "..y.." "..z.." 0 1 0 0.1") | |
cmd("particle "..name.." "..x.." "..y.." "..z.." 1 1 0 0.1") | |
cmd("particle "..name.." "..x.." "..y.." "..z.." 0 1 1 0.1") | |
cmd("particle "..name.." "..x.." "..y.." "..z.." 1 0 0 0.1") | |
cmd("particle "..name.." "..x.." "..y.." "..z.." -1 0 0 0.1") | |
cmd("particle "..name.." "..x.." "..y.." "..z.." 0 0 1 0.1") | |
cmd("particle "..name.." "..x.." "..y.." "..z.." 0 0 -1 0.1") | |
end | |
function string.starts(str,start) | |
return string.sub(str,1,string.len(start))==start | |
end | |
function string.ends(str,endstr) | |
return endstr=='' or string.sub(str,-string.len(endstr))==endstr | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment