Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local blib = {scene = {}}
- function blib.newScene()
- blib.scene = {}
- end
- function blib.addButton(tx,x,y,px,py,cob,cot,callback)
- if x=="c" then
- x = txc - (#tx+px*2)/2
- end
- table.insert(blib.scene,{x,y,px,py,tx,cob,cot,callback})
- end
- function blib.saveScene()
- return deepcopy(blib.scene)
- end
- function blib.loadScene(newScene)
- blib.scene = newScene
- end
- function blib.deployScene()
- local bcheck = {}
- for k,v in ipairs(blib.scene) do
- term.setBackgroundColor(v[6])
- term.setTextColor(v[7])
- for i=1,v[4]*2+1 do
- term.setCursorPos(v[1],v[2]+i-1)
- term.write(string.rep(" ",#v[5]+(v[3]*2)))
- end
- term.setCursorPos(v[1]+v[3],v[2]+v[4])
- term.write(v[5])
- table.insert(bcheck, {v[1],v[2],v[1]+#v[5]+v[3]*2-1,v[2]+v[4]*2,k})
- end
- while true do
- local e,p1,p2,p3 = os.pullEvent()
- local success = false
- if e=="mouse_click" then
- local b,x,y = p1,p2,p3
- --local bufferdebug = x..";"..y..": "
- for k,v in ipairs(bcheck) do
- --bufferdebug = bufferdebug.."("..math.floor(v[1])..","..math.floor(v[2]).."-"..math.floor(v[3])..","..math.floor(v[4])..") "
- if x >= math.floor(v[1]) and x <= math.floor(v[3]) then
- if y >= math.floor(v[2]) and y <= math.floor(v[4]) then
- blib.scene[v[5]][8]()
- success = true
- break
- end
- end
- end
- --term.setCursorPos(1,ty)
- --term.write(bufferdebug)
- end
- if success then break end
- end
- end
- _G.blib = blib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement