Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function API(ins, cord1, cord2, length, height)
- if ins == true then
- ins = {os.pullEvent("monitor_touch")}
- end
- if ins[3] >= cord1 and ins[3] <= cord1 + length - 1 then
- if ins[4] >= cord2 and ins[4] <= cord2 + height - 1 then
- return true
- else
- return false
- end
- end
- end
- local function timetouch(timeout, mon)
- local timer = os.startTimer(timeout)
- while true do
- local event = {os.pullEvent()}
- if (event[1] == "timer") and (event[2] == timer) then
- if mon == nil then
- local mon = "timeout"
- end
- return {"timeout", mon, 1000, 1000}
- elseif (event[1] == "monitor_touch") and (event[2] == mon) then
- return {event[1], event[2], event[3], event[4]}
- end
- end
- end
- local function button(mon, ins, cord1, cord2, text)
- if ins[2] == mon then
- if ins ~= nil then
- local m = peripheral.wrap(mon)
- local x = API(ins, cord1, cord2, string.len(text), 1)
- m.setCursorPos(cord1, cord2)
- m.write(text)
- return x
- end
- end
- end
- return {
- API=API,
- timetouch=timetouch,
- button=button
- }
Add Comment
Please, Sign In to add comment