Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
-- TODO -- ADD TextBox check function (do not need anymore) -- ADD When Disabled TextBox Painted have another color -- ADD config saver and checker for correct data -- ADD PathFinder for help -- IN PROGRESS (~70%) -- ADD Color Points (mb 1-3 colors) -- ADD new algorithms for maze generator -- ADD Mode where Camera move with character -- ADD Braille draw mode (only draw, not playable) -- FIX HalfSymbol mode if you stand above exit it is erased -- ADD Kruskal algorithm local AGUI_VERSION = "0.5" local component = require("component") local success, gui repeat success, gui = pcall(require, "AGUI") if not success then print(gui) io.write("For the application need a library AGUI (https://pastebin.com/s4UFSFwn).\n") if not component.isAvailable("internet") then os.exit() end io.write("Do you want to install?[Y/n] ") if not ((io.read() or "n").."y"):match("^%s*[Yy]") then os.exit() end loadfile("/bin/wget.lua")("https://pastebin.com/raw/s4UFSFwn", "/lib/AGUI.lua", "-f") end until success if gui.Version ~= AGUI_VERSION then io.write("Recommended version of AGUI library ("..AGUI_VERSION..") does not match installed ("..(gui.Version or "unknown")..")\n") io.write("Do you want to continue?[Y/n] ") if not ((io.read() or "n").."y"):match("^%s*[Yy]") then os.exit() end end local gpu = component.gpu local event = require("event") local unicode = require("unicode") --------------SETTINGS---------------- local cfg = {} cfg.MapWidth = 159 --79 cfg.MapHeight = 97 --49 cfg.Algorithm = "recursive"--"hunt&kill" -- ("recursive"/"hunt&kill") local WallColor = 0x666666 local FloorColor = 0x000000 local PlayerColor = 0xffff00 local ExitColor = 0x00ff00 local PathColor = 0x0000ff local MarkerColor = 0xff0000 -- mb more colors local Qualities = {DoubleSpace = 0, HalfSymbol = 1, Braille = 2} -- not optimal for speed but more beautiful local Cells = {Empty = 0, Wall = 1, Exit = 2, Path = 3, Marker = 4} local offsetY = 1 cfg.Quality = Qualities.HalfSymbol -- cfg.Quality = Qualities.DoubleSpace cfg.AllowPathFinder = true cfg.AllowMarkers = true cfg.StartX = 2 cfg.StartY = 2 cfg.FinishX = -1 cfg.FinishY = -1 function InRange(value, left, right) return left <= value and value <= right end function UpdateScreenSettings() if cfg.Quality == Qualities.HalfSymbol then cfg.ScreenWidth = cfg.MapWidth cfg.ScreenHeight = math.floor((cfg.MapHeight + 1) / 2) + offsetY else cfg.ScreenWidth = cfg.MapWidth * 2 cfg.ScreenHeight = cfg.MapHeight + offsetY end end function ValidateConfig() local MaxScreenWidth, MaxScreenHeight MaxScreenWidth, MaxScreenHeight = gpu.maxResolution() UpdateScreenSettings() if not InRange(cfg.ScreenWidth, 1, MaxScreenWidth) then return "MapWidthError", "out of bounds" end if cfg.MapWidth < 5 then return "MapWidthError", "out of bounds" end if cfg.MapWidth % 2 == 0 then return "MapWidthError", "only odd value" end if not InRange(cfg.ScreenHeight, 1, MaxScreenHeight) then return "MapHeightError", "out of bounds" end if cfg.MapHeight < 5 then return "MapHeightError", "out of bounds" end if cfg.MapHeight % 2 == 0 then return "MapHeightError", "only odd value" end local x, y x, y = (cfg.StartX + cfg.MapWidth - 1) % cfg.MapWidth + 1, (cfg.StartY + cfg.MapHeight - 1) % cfg.MapHeight + 1 if x % 2 == 1 then return "StartXError", "only even point" end if y % 2 == 1 then return "StartYError", "only even point" end x, y = (cfg.FinishX + cfg.MapWidth - 1) % cfg.MapWidth + 1, (cfg.FinishY + cfg.MapHeight - 1) % cfg.MapHeight + 1 if not InRange(x, 1, cfg.MapWidth) then return "FinishXError", "out of bounds" end if x % 2 == 1 then return "FinishXError", "only even point" end if not InRange(y, 1, cfg.MapHeight) then return "FinishYError", "out of bounds" end if y % 2 == 1 then return "FinishYError", "only even point" end end --UpdateScreenSettings() local err, msg = ValidateConfig() if err ~= nil then print(err, msg) os.exit() end -------------------------------------- local map = {} local distMap = {} local markerMap = {} local size = 200 -- width map mas NEED CHANGE TO cfg.MapWidth local isRunning = false local quit = false local plx, ply, finX, finY local algorithms = {} local Draw = {} DIR={{x=0,y=-1},{x=-1,y=0},{x=1,y=0},{x=0,y=1}} ----------------------- -- DEPRECATED -- function centerText(x, y, w, text) -- gpu.set(x+math.floor(w/2-string.len(text)/2),y,text) -- end -- function messageBox(title,text,color) -- local x,y=(cfg.MapWidth-6)/((cfg.Quality and 2)or 1),(math.floor(cfg.MapHeight/2)-3)/((cfg.Quality and 2)or 1) -- local len1,len2=string.len(title),string.len(text) -- local len3=math.max(len1,len2)+2 -- gpu.setBackground(0xffffff) -- gpu.fill(x,y,len3,2+3," ") -- gpu.setForeground(color or 0xFF0000) -- centerText(x,y+1,len3,title) -- gpu.setForeground(0x000000) -- centerText(x,y+3,len3,text) -- gpu.setBackground(color or 0xFF0000) -- gpu.setForeground(0xffffff) -- gpu.fill(x,y+5,len3,3," ") -- centerText(x,y+6,len3,"OK") -- end ----------------------- function toXY(num) local y=math.floor((num-1)/size)+1 return num-(y-1)*size,y end function fromXY(x,y) return (y-1)*size+x end function clearMap() for x=1,cfg.MapWidth+10 do for y=1,cfg.MapHeight+10 do if (x%2==0)and(y%2==0) then map[fromXY(x, y)] = nil else map[fromXY(x, y)] = Cells.Wall end end end markerMap = {} -- markerMap[fromXY(2,2)] = true -- markerMap[fromXY(2,3)] = true end --DoubleSpace Draw[Qualities.DoubleSpace] = {} Draw[Qualities.DoubleSpace].Map = function() gpu.setBackground(WallColor) gpu.fill(1, 1 + offsetY, cfg.MapWidth * 2, cfg.MapHeight, " ") gpu.setBackground(FloorColor) for x=1,cfg.MapWidth do for y=1,cfg.MapHeight do if map[fromXY(x,y)] ~= Cells.Wall then gpu.set(x * 2 - 1, y + offsetY, " ") -- gpu.set(x * 2 - 1, y + offsetY, (distMap[fromXY(x, y)] < 10 and "0" or "")..tostring(distMap[fromXY(x, y)])) end end end end Draw[Qualities.DoubleSpace].Point = function(x, y, col) gpu.setBackground(col or (markerMap[fromXY(x, y)] and MarkerColor or FloorColor)) gpu.set(x * 2 - 1, y + offsetY, " ") gpu.setBackground(0x000000) -- gpu.setBackground(0xffff00) -- gpu.set(3,2 + offsetY," ") -- gpu.setBackground(0x00ff00) -- gpu.set((cfg.MapWidth-1)*2-1,cfg.MapHeight-1 + offsetY," ") -- gpu.setBackground(0x000000) end Draw[Qualities.DoubleSpace].Path = function(x, y) local point = Draw[Qualities.DoubleSpace].Point local b while distMap[fromXY(x, y)] ~= 0 do point(x, y, PathColor) b = true for dr = 1, 4 do if distMap[fromXY(x + DIR[dr].x, y + DIR[dr].y)] ~= nil and distMap[fromXY(x + DIR[dr].x, y + DIR[dr].y)] < distMap[fromXY(x, y)] then x, y = x + DIR[dr].x, y + DIR[dr].y b = false break end end if b then break end end end --HalfSymbol Draw[Qualities.HalfSymbol] = {} local PIX={[0]=" ",[1]="▀",[2]="▄",[3]="█"} Draw[Qualities.HalfSymbol].Map = function() gpu.setBackground(FloorColor) gpu.setForeground(WallColor) local s,tmp="none",0 for y=2,cfg.MapHeight+1,2 do -- s="" s = {} for x=1,cfg.MapWidth do tmp=0 if map[fromXY(x,y-1)] == Cells.Wall then tmp=tmp+1 end if (map[fromXY(x,y)] == Cells.Wall)and(y~=cfg.MapHeight+1) then tmp=tmp+2 end -- s=s..PIX[tmp] table.insert(s, PIX[tmp]) end -- if y==52 then -- print("1"..s.."1") -- end s = table.concat(s) gpu.set(1, math.floor(y / 2) + offsetY, s) end gpu.setForeground(0xffffff) gpu.setBackground(0x000000) end Draw[Qualities.HalfSymbol].Point = function(x, y, color, full) local TopColor, BottomColor if full then TopColor = color BottomColor = color else if y%2 == 0 then TopColor = map[fromXY(x, y - 1)] == Cells.Wall and WallColor or (markerMap[fromXY(x, y - 1)] and MarkerColor or FloorColor) BottomColor = color or (markerMap[fromXY(x, y)] and MarkerColor or FloorColor) else TopColor = color or (markerMap[fromXY(x, y)] and MarkerColor or FloorColor) BottomColor = map[fromXY(x, y + 1)] == Cells.Wall and WallColor or (markerMap[fromXY(x, y + 1)] and MarkerColor or FloorColor) end end gpu.setForeground(TopColor) gpu.setBackground(BottomColor) gpu.set(x, math.floor((y + 1) / 2) + offsetY, PIX[1]) gpu.setBackground(0x000000) gpu.setForeground(0xffffff) end Draw[Qualities.HalfSymbol].Path = function(x, y) local point = Draw[Qualities.HalfSymbol].Point local nY local fullDraw = false for dr = 1, 4 do if distMap[fromXY(x + DIR[dr].x, y + DIR[dr].y)] ~= nil and distMap[fromXY(x + DIR[dr].x, y + DIR[dr].y)] < distMap[fromXY(x, y)] then x, y = x + DIR[dr].x, y + DIR[dr].y break end end while distMap[fromXY(x, y)] ~= 0 do point(x, y, PathColor, fullDraw) fullDraw = false nY = nil for dr = 1, 4 do if distMap[fromXY(x + DIR[dr].x, y + DIR[dr].y)] ~= nil and distMap[fromXY(x + DIR[dr].x, y + DIR[dr].y)] < distMap[fromXY(x, y)] then x, nY = x + DIR[dr].x, y + DIR[dr].y break end end if nY == nil then break end if math.floor((nY + 1) / 2) == math.floor((y + 1) / 2) and nY ~= y then fullDraw = true end y = nY end end -- Draw[Qualities.HalfSymbol].Point = function(x, y, col) -- local tmp=0 -- if y%2==0 then -- if map[fromXY(x,y-1)]==false then -- gpu.setBackground(0x000000) -- else -- gpu.setBackground(0x666666) -- end -- gpu.setForeground(col or 0xffff00) -- tmp=2 -- elseif (x==cfg.MapWidth-1)and(y==cfg.MapHeight-2) then -- gpu.setBackground(0x00ff00) -- gpu.setForeground(col or 0xffff00) -- tmp=1 -- else -- if map[fromXY(x,y+1)]==false then -- gpu.setBackground(0x000000) -- else -- gpu.setBackground(0x666666) -- end -- gpu.setForeground(col or 0xffff00) -- tmp=1 -- end -- gpu.set(x, math.floor((y-1)/2) + 1 + offsetY, PIX[tmp]) -- end --[[ function drawMap() if cfg.Quality then gpu.setBackground(0x000000) gpu.setForeground(0x666666) local s,tmp="none",0 for y=2,cfg.MapHeight+1,2 do -- s="" s = {} for x=1,cfg.MapWidth do tmp=0 if map[fromXY(x,y-1)] then tmp=tmp+1 end if (map[fromXY(x,y)])and(y~=cfg.MapHeight+1) then tmp=tmp+2 end -- s=s..PIX[tmp] table.insert(s, PIX[tmp]) end -- if y==52 then -- print("1"..s.."1") -- end s = table.concat(s) gpu.set(1, math.floor(y / 2) + offsetY, s) end gpu.setForeground(0xffffff) else gpu.setBackground(0x666666) gpu.fill(1, 1 + offsetY, cfg.MapWidth * 2, cfg.MapHeight, " ") gpu.setBackground(0x000000) for x=1,cfg.MapWidth do for y=1,cfg.MapHeight do if not map[fromXY(x,y)] then gpu.set(x * 2 - 1, y + offsetY, " ") end end end end gpu.setBackground(0x000000) end --]] algorithms["recursive"] = function() local stack={} local stklen,step=1,0 local posx, posy = math.random(1, math.floor(cfg.MapWidth / 2)) * 2,math.random(1, math.floor(cfg.MapHeight / 2)) * 2 stack[1]={x=posx,y=posy} while stklen>0 do -- step=(step+1)%1000 -- os.sleep(0) map[fromXY(stack[stklen].x,stack[stklen].y)] = Cells.Empty -- drawMap() local bool,tmp=true,true while bool do tmp=false local rnd=math.random(0,3) if (map[fromXY(stack[stklen].x-2,stack[stklen].y)]==nil)and(stack[stklen].x-1~=1) then tmp=true if rnd==0 then map[fromXY(stack[stklen].x-1,stack[stklen].y)] = Cells.Empty stklen=stklen+1 stack[stklen]={x=stack[stklen-1].x-2,y=stack[stklen-1].y} break end end if (map[fromXY(stack[stklen].x+2,stack[stklen].y)]==nil)and(stack[stklen].x+1~=cfg.MapWidth) then tmp=true if rnd==1 then map[fromXY(stack[stklen].x+1,stack[stklen].y)] = Cells.Empty stklen=stklen+1 stack[stklen]={x=stack[stklen-1].x+2,y=stack[stklen-1].y} break end end if (map[fromXY(stack[stklen].x,stack[stklen].y-2)]==nil)and(stack[stklen].y-1~=1) then tmp=true if rnd==2 then map[fromXY(stack[stklen].x,stack[stklen].y-1)] = Cells.Empty stklen=stklen+1 stack[stklen]={x=stack[stklen-1].x,y=stack[stklen-1].y-2} break end end if (map[fromXY(stack[stklen].x,stack[stklen].y+2)]==nil)and(stack[stklen].y+1~=cfg.MapHeight) then tmp=true if rnd==3 then map[fromXY(stack[stklen].x,stack[stklen].y+1)] = Cells.Empty stklen=stklen+1 stack[stklen]={x=stack[stklen-1].x,y=stack[stklen-1].y+2} break end end bool=tmp end if not tmp then stklen=stklen-1 end end end algorithms["hunt&kill"] = function() local function testField() for j=2,cfg.MapHeight,2 do for i=2,cfg.MapWidth,2 do if map[fromXY(i,j)]==nil then for dr=1,4 do if map[fromXY(i+DIR[dr].x*2,j+DIR[dr].y*2)] == Cells.Empty then map[fromXY(i,j)] = Cells.Empty map[fromXY(i+DIR[dr].x,j+DIR[dr].y)] = Cells.Empty return i,j end end end end end return false end local isRunning,tmp=true,true local posx,posy,rnd=math.random(1,math.floor(cfg.MapWidth/2))*2,math.random(1,math.floor(cfg.MapHeight/2))*2,0 while isRunning do tmp=true map[fromXY(posx, posy)] = Cells.Empty while tmp do tmp=false rnd=math.random(1,4) for dr=1,4 do if (map[fromXY(posx+DIR[dr].x*2,posy+DIR[dr].y*2)]==nil)and(posx+DIR[dr].x~=1)and(posx+DIR[dr].x~=cfg.MapWidth)and(posy+DIR[dr].y~=1)and(posy+DIR[dr].y~=cfg.MapHeight) then tmp=true if rnd==dr then map[fromXY(posx+DIR[dr].x,posy+DIR[dr].y)] = Cells.Empty map[fromXY(posx+DIR[dr].x*2,posy+DIR[dr].y*2)] = Cells.Empty posx,posy=posx+DIR[dr].x*2,posy+DIR[dr].y*2 break end end end end -- Draw[cfg.Quality].Map();os.sleep(0) posx,posy=testField() if posx==false then isRunning=false end end end -- function drawPoint(x,y,col) -- local tmp=0 -- if y%2==0 then -- if map[fromXY(x,y-1)]==false then -- gpu.setBackground(0x000000) -- else -- gpu.setBackground(0x666666) -- end -- gpu.setForeground(col or 0xffff00) -- tmp=2 -- elseif (x==cfg.MapWidth-1)and(y==cfg.MapHeight-2) then -- gpu.setBackground(0x00ff00) -- gpu.setForeground(col or 0xffff00) -- tmp=1 -- else -- if map[fromXY(x,y+1)]==false then -- gpu.setBackground(0x000000) -- else -- gpu.setBackground(0x666666) -- end -- gpu.setForeground(col or 0xffff00) -- tmp=1 -- end -- gpu.set(x, math.floor((y-1)/2) + 1 + offsetY, PIX[tmp]) -- end function onKeyDown(_, _, ch1, ch2) if ch1 == 112 and cfg.AllowPathFinder then -- isRunning=false Draw[cfg.Quality].Path(plx, ply) end if ch1 == 32 and cfg.AllowMarkers then markerMap[fromXY(plx, ply)] = not markerMap[fromXY(plx, ply)] end if ch1==0 then -- print(ch2) if ch2==203 then lP=true elseif ch2==200 then uP=true elseif ch2==205 then rP=true elseif ch2==208 then dP=true end end end function onKeyUp(_,_,ch1,ch2) if ch1==0 then if ch2==203 then lP=false elseif ch2==200 then uP=false elseif ch2==205 then rP=false elseif ch2==208 then dP=false end end end function FindPath() local queue = {fromXY(finX, finY)} local queueFront = 1 local x, y, cell, nextCell, dist distMap = {} distMap[ queue[1] ] = 0 while queue[queueFront] ~= nil do cell = queue[queueFront] queueFront = queueFront + 1 x, y = toXY(cell) dist = distMap[cell] + 1 for dr = 1, 4 do if InRange(x + DIR[dr].x, 1, cfg.MapWidth) and InRange(y + DIR[dr].y, 1, cfg.MapHeight) then nextCell = fromXY(x + DIR[dr].x, y + DIR[dr].y) if distMap[nextCell] == nil and map[nextCell] ~= Cells.Wall then distMap[nextCell] = dist table.insert(queue, nextCell) end end end end end function GameInit() clearMap() plx, ply = (cfg.StartX + cfg.MapWidth - 1) % cfg.MapWidth + 1, (cfg.StartY + cfg.MapHeight - 1) % cfg.MapHeight + 1 finX, finY = (cfg.FinishX + cfg.MapWidth - 1) % cfg.MapWidth + 1, (cfg.FinishY + cfg.MapHeight - 1) % cfg.MapHeight + 1 algorithms[cfg.Algorithm]() -- if cfg.Algorithm == "recursive" then -- generateMaze(cfg.StartX, cfg.StartY) -- elseif cfg.Algorithm == "hunt&kill" then -- generateMaze2() -- end FindPath() --os.sleep(2) -- drawMap() Draw[cfg.Quality].Map() -- Draw[cfg.Quality].Path(2, 2) Draw[cfg.Quality].Point(plx, ply, PlayerColor) Draw[cfg.Quality].Point(finX, finY, ExitColor) -- if cfg.Quality == Qualities.HalfSymbol then -- drawPoint(2,2) -- drawPoint(cfg.MapWidth-1,cfg.MapHeight-1,0x00ff00) -- else -- gpu.setBackground(0xffff00) -- gpu.set(3,2 + offsetY," ") -- gpu.setBackground(0x00ff00) -- gpu.set((cfg.MapWidth-1)*2-1,cfg.MapHeight-1 + offsetY," ") -- gpu.setBackground(0x000000) -- end lP, rP, uP, dP = false, false, false, false -- event.listen("key_down",onKeyDown) event.listen("key_up",onKeyUp) isRunning = true end function GameHandle() -- while isRunning do local plxb,plyb=plx,ply if (lP)and(map[fromXY(plx-1,ply)] ~= Cells.Wall) then--left plx=plx-1 elseif (uP)and(map[fromXY(plx,ply-1)] ~= Cells.Wall) then--up ply=ply-1 elseif (rP)and(map[fromXY(plx+1,ply)] ~= Cells.Wall) then--right plx=plx+1 elseif (dP)and(map[fromXY(plx,ply+1)] ~= Cells.Wall) then--down ply=ply+1 end if (plx~=plxb)or(ply~=plyb) then Draw[cfg.Quality].Point(plxb, plyb) Draw[cfg.Quality].Point(plx, ply, PlayerColor) -- if cfg.Quality then -- drawPoint(plxb,plyb,0x000000) -- drawPoint(plx,ply) -- else -- gpu.setBackground(0x000000) -- gpu.set(plxb*2-1,plyb + offsetY," ") -- gpu.setBackground(0xffff00) -- gpu.set(plx*2-1,ply + offsetY," ") -- end if (plx == finX) and (ply == finY) then isRunning = false --messageBox("congratulation","You Win!") gui.backend.MessageBox:Create("congratulation", "You Win!"):Modify{ButtonHandle = function() GameForm.Elements["Exit"]:OnElementClick() end}:Init():Paint() end end os.sleep(0.1) -- end end -- event.ignore("key_down",onKeyDown) -- event.ignore("key_up",onKeyUp) -- map=nil -- gpu.setBackground(0x000000) -- gpu.setForeground(0xffffff) --event.pull("key_down") -------------------- GUI -------------------- gui.Init() GameForm = gui.backend.Form:Create(cfg.ScreenWidth, cfg.ScreenHeight, { Exit = gui.backend.Button:Create(1, 1, 8, 1, "[Return]", function() event.ignore("key_down",onKeyDown) event.ignore("key_up",onKeyUp) isRunning = false GameForm:Disable(true) MainForm:Enable():Paint() end), algo = gui.backend.Text:Create(10, 1, nil, cfg.Algorithm), } ):Init() SettingsForm = gui.backend.Form:Create(32, 15, { gui.backend.Text:Create(1, 1, 32, "Settings"), gui.backend.Text:Create(1, 3, 7, "Width"), MapWidth = gui.backend.TextBox:Create(1, 4, 7, cfg.MapWidth .. "", "0123456789"), MapWidthError = gui.backend.Text:Create(1, 5, nil, ""):Modify{TextColor = 0xff0000}, gui.backend.Text:Create(9, 3, 7, "Height"), MapHeight = gui.backend.TextBox:Create(9, 4, 7, cfg.MapHeight .. "", "0123456789"), MapHeightError = gui.backend.Text:Create(1, 5, nil, ""):Modify{TextColor = 0xff0000}, -- Quality = gui.backend.CheckBox:Create(1, 6, 20, "Super Quality", cfg.Quality == Qualities.HalfSymbol), gui.backend.Text:Create(1, 6, nil, "Graphic Mode"), Quality = gui.backend.RadioGroup:Create( { [Qualities.DoubleSpace] = gui.backend.RadioButton:Create(1, 7, 15, "DoubleSpace"), [Qualities.HalfSymbol] = gui.backend.RadioButton:Create(1, 8, 15, "Half Symbol"), }, cfg.Quality), gui.backend.Text:Create(1, 10, nil, "Algorithm"), Algorithm = gui.backend.RadioGroup:Create( { ["recursive"] = gui.backend.RadioButton:Create(1, 11, 15, "Recursive"), ["hunt&kill"] = gui.backend.RadioButton:Create(1, 12, 15, "Hunt&Kill"), }, cfg.Algorithm), gui.backend.Text:Create(18, 3, 15, "Start Position"), StartX = gui.backend.TextBox:Create(18, 4, 7, cfg.StartX .. "", "0123456789"), StartXError = gui.backend.Text:Create(18, 5, nil, ""):Modify{TextColor = 0xff0000}, StartY = gui.backend.TextBox:Create(26, 4, 7, cfg.StartY .. "", "0123456789"), StartYError = gui.backend.Text:Create(18, 5, nil, ""):Modify{TextColor = 0xff0000}, gui.backend.Text:Create(18, 6, 15, "Finish Position"), FinishX = gui.backend.TextBox:Create(18, 7, 7, cfg.FinishX .. "", "0123456789"), FinishXError = gui.backend.Text:Create(18, 8, nil, ""):Modify{TextColor = 0xff0000}, FinishY = gui.backend.TextBox:Create(26, 7, 7, cfg.FinishY .. "", "0123456789"), FinishYError = gui.backend.Text:Create(18, 8, nil, ""):Modify{TextColor = 0xff0000}, gui.backend.Text:Create(18, 9, nil, "Another"), AllowMarkers = gui.backend.CheckBox:Create(18, 10, 15, "Markers", cfg.AllowMarkers), AllowPathFinder = gui.backend.CheckBox:Create(18, 11, 15, "PathFinder", cfg.AllowPathFinder), gui.backend.Button:Create(1, 13, 32, 3, "Back", function() cfg.MapWidth = SettingsForm.Elements["MapWidth"].Text + 0 cfg.MapHeight = SettingsForm.Elements["MapHeight"].Text + 0 cfg.StartX = SettingsForm.Elements["StartX"].Text + 0 cfg.StartY = SettingsForm.Elements["StartY"].Text + 0 cfg.FinishX = SettingsForm.Elements["FinishX"].Text + 0 cfg.FinishY = SettingsForm.Elements["FinishY"].Text + 0 cfg.Quality = SettingsForm.Elements["Quality"].Checked cfg.Algorithm = SettingsForm.Elements["Algorithm"].Checked cfg.AllowPathFinder = SettingsForm.Elements["AllowPathFinder"].Checked cfg.AllowMarkers = SettingsForm.Elements["AllowMarkers"].Checked -- UpdateScreenSettings() SettingsForm.Elements["MapWidthError"]:Modify{Text = ""}:Paint() SettingsForm.Elements["MapWidth"]:Modify{TextColor = 0xffffff}:Paint() SettingsForm.Elements["MapHeightError"]:Modify{Text = ""}:Paint() SettingsForm.Elements["MapHeight"]:Modify{TextColor = 0xffffff}:Paint() SettingsForm.Elements["StartXError"]:Modify{Text = ""}:Paint() SettingsForm.Elements["StartX"]:Modify{TextColor = 0xffffff}:Paint() SettingsForm.Elements["StartYError"]:Modify{Text = ""}:Paint() SettingsForm.Elements["StartY"]:Modify{TextColor = 0xffffff}:Paint() SettingsForm.Elements["FinishXError"]:Modify{Text = ""}:Paint() SettingsForm.Elements["FinishX"]:Modify{TextColor = 0xffffff}:Paint() SettingsForm.Elements["FinishYError"]:Modify{Text = ""}:Paint() SettingsForm.Elements["FinishY"]:Modify{TextColor = 0xffffff}:Paint() local err, msg = ValidateConfig() if err ~= nil then SettingsForm.Elements[err]:Modify{Text = msg}:Paint() SettingsForm.Elements[unicode.sub(err, 1, -6)]:Modify{TextColor = 0xff0000}:Paint() return false end GameForm.Width = cfg.ScreenWidth GameForm.Height = cfg.ScreenHeight GameForm.Elements["algo"].Text = cfg.Algorithm SettingsForm:Disable(true) MainForm:Enable():Paint() end), } ):Init() MainForm = gui.backend.Form:Create(20, 11, { gui.backend.Button:Create(1, 1, 20, 3, "Start", function() MainForm:Disable(true) GameForm:Enable():Paint() GameInit() end), gui.backend.Button:Create(1, 5, 20, 3, "Settings", function() MainForm:Disable(true) SettingsForm:Enable():Paint() end), gui.backend.Button:Create(1, 9, 20, 3, "Exit", function() quit = true end), } ) MainForm:Init():Enable():Paint() quit = false pcall(function() while not quit do if isRunning then GameHandle() else event.pull() end end end) gui.Destroy() event.ignore("key_down",onKeyDown) event.ignore("key_up",onKeyUp) gpu.setBackground(0x000000) gpu.setForeground(0xffffff)
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
anydesk forensics
55 min ago | 0.80 KB
OoTMM rando seed 7/28
4 hours ago | 93.67 KB
Untitled
5 hours ago | 5.87 KB
EARNING-BTC ENGINE
CSS | 6 hours ago | 0.38 KB
Secret Guide
6 hours ago | 0.39 KB
Step 7 Enumeration
12 hours ago | 19.79 KB
Disable Drag and Drop Image Improved Plugin i...
PHP | 1 day ago | 1.31 KB
z66is_archive.zip.txt
1 day ago | 1.53 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!