Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Label API - (c) monster010 -- v1.1
- local labels = {}
- local monitor
- function construct(moni)
- monitor = moni
- end
- function getLabels()
- return labels
- end
- function clear()
- labels = {}
- end
- function add(name, label, x, y, slabel, cltext, clstext, clfill, clsfill)
- if not slabel then slabel = false end
- if not cltext then cltext = colors.white end
- if not clstext then clstext = colors.white end
- if not clfill then clfill = colors.black end
- if not clsfill then clsfill = colors.black end
- labels[name] = {}
- labels[name]["txt"] = label
- labels[name]["x"] = x
- labels[name]["y"] = y
- labels[name]["stxt"] = slabel
- labels[name]["cl"] = cltext
- labels[name]["cls"] = clstext
- labels[name]["bfill"] = clfill
- labels[name]["bsfill"] = clsfill
- end
- function set(name, key, val)
- labels[name][key] = val
- end
- function screen()
- for name, lData in pairs(labels) do
- fill(name, lData)
- end
- end
- function fill(name, data)
- monitor.setBackgroundColor(data["bfill"])
- monitor.setTextColor(data["cl"])
- monitor.setCursorPos(data["x"], data["y"])
- monitor.write(data["txt"])
- if data["stxt"] then
- monitor.setBackgroundColor(data["bsfill"])
- monitor.setTextColor(data["cls"])
- monitor.setCursorPos(data["x"] + 1 + string.len(data["txt"]), data["y"])
- monitor.write(data["stxt"])
- end
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- end
Advertisement
Add Comment
Please, Sign In to add comment