Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --DexPI by dexman545 (kev12east)
- --FS API
- --This will read/write a table of "text" to "file"
- --to use do text = "<text to be written>"
- function fWrite(f)
- local file = fs.open(f, "w")
- dbs = textutils.serialize(text)
- file.write(dbs)
- file.close()
- end
- function fRead(f)
- local file = fs.open(f, "r")
- text = textutils.unserialize(file.readAll())
- return text
- end
- --Returns list of peripherals matching pname conected with networking cables
- function listPer(pname)
- local pers = peripheral.getNames()
- local perList = {}
- for i,v in pairs(pers) do
- if string.find(v, pname) then
- table.insert(perList, v)
- end
- end
- return perList
- end
- --finds a monitor next to the computer
- function getMon()
- for i,s in ipairs(redstone.getSides()) do
- mon = peripheral.wrap(s)
- if mon then break end
- end
- end
- --clears text, sets cursor position to x, y
- function clear(x, y)
- term.clear()
- term.setCursorPos(x,y)
- end
- --gets computers location via a GPS tower
- function getLoc()
- x, y, z = gps.locate(2, true)
- return x, y, z
- end
- --turtle movement without fuel
- function forward(t, s)
- for i = 1, t do
- if turtle.getFuelLevel() < 10 then
- turtle.select(s)
- turtle.refuel()
- turtle.forward()
- else turtle.forward()
- if turtle.forward() == true then
- return true
- else return false
- end
- end
- end
- end
- --Dials a Stargate from Lanteacraft or SGCraft
- function dial(addr, t, side)
- sg.connect(addr)
- clear(1,1)
- repeat
- print("Gate is dialling...")
- sleep(1)
- clear(1,1)
- until not sg.isDialing()
- if side == nil then
- for i = t, 1, -1 do
- print("Closing gate in ".. i .." seconds")
- sleep(1)
- clear(1,1)
- end
- print("Stargate disconnecting from ".. addr)
- sg.disconnect()
- sleep(1)
- clear(1,1)
- else rs.setOutput(side, true)
- for i = t, 1, -1 do
- print("Closing gate in ".. i .." seconds")
- sleep(1)
- clear(1,1)
- end
- print("Stargate disconnecting from ".. addr)
- sg.disconnect()
- rs.setOutput(side, false)
- sleep(1)
- clear(1,1)
- end
- end
- --run to functions in parallel
- function sync(func1, func2)
- parallel.waitForAll(func1, func2)
- end
- --monitor API by gunpowder1234321 and dexman545
- function setSide(side)
- mon = peripheral.wrap(tostring(side))
- end
- function mClear(x,y)
- mon.clear()
- mon.setCursorPos(tonumber(x),(y))
- end
- function mPrint(String)
- local l, h = mon.getSize()
- local mX,mY = mon.getCursorPos()
- mon.write(tostring(String))
- mon.setCursorPos(1,mY+1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement