Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- monster010 API - (c) monster010 -- v1.1
- local monSide = ""
- local softLabel = ""
- local monitor
- function construct(monSid, label)
- softLabel = label
- monSide = monSid
- end
- function getMonitor()
- return monitor
- end
- function clearMonitor()
- monitor.clear()
- end
- function round(num, idp, pointless)
- if not pointless then pointless = false end
- local mult = 10^(idp or 0)
- local erg = math.floor(num * mult + 0.5) / mult
- if pointless then
- erg = string.sub(erg, 1)
- end
- return erg
- end
- function startUp()
- term.clear()
- term.setCursorPos(1,1)
- write("##### "..softLabel.." #####\n")
- write("Copyright (c) monster010\n")
- write("-------------------------\n")
- write("Initialisiere Software...\n")
- if peripheral.isPresent(monSide) and peripheral.getType(monSide) == "monitor" then
- monitor = peripheral.wrap(monSide)
- monitor.setTextScale(1)
- monitor.setTextColor(colors.white)
- monitor.setBackgroundColor(colors.black)
- else
- term.setTextColor(colors.red)
- print("Monitor "..monSide.." nicht gefunden!")
- term.setTextColor(colors.white)
- return
- end
- monitor.clear()
- monitor.setCursorPos(1,1)
- end
- function startUpDone()
- for i = 1, 20 do
- write(".")
- sleep(0.1)
- end
- write("\n")
- for i = 1, 11 do
- write(".")
- sleep(0.3)
- end
- write(" done\n")
- sleep(3)
- term.clear()
- term.setCursorPos(1,1)
- end
- function heading()
- w, h = monitor.getSize()
- monitor.setCursorPos((w - string.len(softLabel)) / 2 + 1, 1)
- monitor.write(softLabel)
- monitor.setCursorPos(1,2)
- end
- function label(x, y, text)
- monitor.setCursorPos(x, y)
- monitor.write(text)
- monitor.setCursorPos(1,2)
- end
- function saveFile(path, content, serial)
- if not serial then serial = false end
- local file = fs.open(path, "w")
- if serial then
- content = textutils.serialize(content)
- end
- file.write(content)
- file.close()
- end
- function loadFile(path, unserialize)
- local data
- if not unserialize then unserialize = false end
- if fs.exists(path) then
- local file = fs.open(path, "r")
- if unserialize then
- data = textutils.unserialize(file.readAll())
- else
- data = file.readAll()
- end
- file.close()
- end
- return data
- end
- function toboolean(str)
- if str == "true" then
- return true
- else
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment