Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local arg = ...
- if not fs.exists("ButtonH") then shell.run("pastebin get LTDZZZEJ ButtonH") end
- local b = require("ButtonH").terminal
- local xs, ys = term.getSize()
- local win = window.create(term.current(), 1, 1, xs, ys)
- local oldTerm = term.redirect(win)
- local mainCode = function()
- local function printToDebug(...)
- local old = term.redirect(debugWindow)
- print(...)
- term.redirect(old)
- end
- --if arg then
- local mclick = {"timeout",0,-1,-1}
- local dclick = {"timeout",0,-1,-1}
- local pixelmap = {}
- local drawmap = {}
- local openmap
- local cCol = colors.black
- local cBac = colors.white
- local cSym = " "
- local sizeUpdate = function()
- xs, ys = term.getSize()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- end
- sizeUpdate()
- term.clear()
- local menuClick = function()
- while true do
- mclick = b.timetouch(1,{[2]=true,[3]=true})
- end
- end
- local drawClick = function()
- while true do
- dclick = b.timetouch(1,{[2]=true,[3]=true},true)
- end
- end
- local dfs = {3,7,11,4}
- local windowbug = 1
- local wincount = 0
- local yy = 2
- local draw = function()
- local drawBox = function()
- sizeUpdate()
- win.setVisible(false)
- if wincount >= windowbug then
- win.clear()
- wincount = 0
- end
- wincount = wincount + 1
- if dfs[3] < xs-8 then
- term.setTextColor(colors.green)
- if b.boxButton(1,dclick,dfs[1]+dfs[3]+2,dfs[2]-2,"green","black"," +",2,1) then
- dfs[3] = dfs[3] + 1
- end
- end
- if dfs[3] > 11 then
- term.setTextColor(colors.red)
- if b.boxButton(1,dclick,dfs[1]+dfs[3]+2,dfs[2]+2,"red","black"," -",2,1) then
- dfs[3] = dfs[3] - 1
- end
- end
- if dfs[4] < ys-13 then
- if b.boxButton(1,dclick,dfs[1]+2,dfs[4]*2+5,"green","black","+",2,1) then
- dfs[4] = dfs[4] + 0.5
- dfs[2] = dfs[2] + 0.5
- yy = yy + 1
- end
- end
- if dfs[4] > 4 then
- if b.boxButton(1,dclick,dfs[1]+8,dfs[4]*2+5,"red","black","-",2,1) then
- dfs[4] = dfs[4] - 0.5
- dfs[2] = dfs[2] - 0.5
- yy = yy - 1
- end
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.black)
- b.fill(nil,nil,nil,nil,"\127")
- b.frame(dfs[1],dfs[2],dfs[3],dfs[4],"lightGray","gray",false)
- for x=dfs[1], dfs[1]+dfs[3]-2 do
- for y=dfs[2]-dfs[4]+2, dfs[2]+dfs[4] do
- if b.API(dclick,x,y-1,1,1) then
- term.setTextColor(colors.white)
- if not pixelmap[x-dfs[1]+1] then pixelmap[x-dfs[1]+1] = {} end
- if not pixelmap[x-dfs[1]+1][y-dfs[2]+yy+1] then pixelmap[x-dfs[1]+1][y-dfs[2]+yy+1] = {} end
- pixelmap[x-dfs[1]+1][y-dfs[2]+yy+1] = {
- tcol = cCol,
- bcol = cBac,
- sym = cSym
- }
- if not drawmap[x] then drawmap[x] = {} end
- if not drawmap[x][y] then drawmap[x][y] = {} end
- drawmap[x][y] = {}
- drawmap[x][y] = {
- tcol = cCol,
- bcol = cBac,
- sym = cSym
- }
- end
- end
- end
- openmap = {}
- for k,v in pairs(drawmap) do
- for k2,v2 in pairs(v) do
- if k < dfs[1]+dfs[3]-1 then
- if k2 < dfs[2]+dfs[4]+1 then
- term.setCursorPos(k,k2-1)
- term.setBackgroundColor(v2.bcol)
- term.setTextColor(v2.tcol)
- term.write(v2.sym)
- if not openmap[k-dfs[1]+1] then openmap[k-dfs[1]+1] = {} end
- if not openmap[k-dfs[1]+1][k2-dfs[2]+yy+1] then openmap[k-dfs[1]+1][k2-dfs[2]+yy+1] = {} end
- openmap[k-dfs[1]+1][k2-dfs[2]+yy+1] = {
- tcol = v2.tcol,
- bcol = v2.bcol,
- sym = v2.sym
- }
- end
- end
- end
- end
- end
- local menu = function()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.gray)
- term.write((" "):rep(xs))
- term.setCursorPos(1,2)
- term.write((" "):rep(xs))
- term.setBackgroundColor(colors.black)
- win.setVisible(true)
- sleep(0.05)
- end
- while true do
- drawBox()
- menu()
- end
- end
- parallel.waitForAll(menuClick,drawClick,draw)
- --end
- end
- local ok,err = pcall(mainCode)
- term.redirect(oldTerm)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- if not ok then
- error(err,2)
- end
Add Comment
Please, Sign In to add comment