Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is NOT INTENDED FOR USE ON
- --PERSONAL COMPUTERS!
- --ignore this:
- --[[------
- CONFIG]]
- function config()
- --ignore this:
- game = {}
- gameDirr = {}
- --CONFIG:
- game[1] = "gamenamehere"
- game[2] = "ddas"
- game[3] = "d"
- game[4] = "a"
- gameDirr[1] = "examplefolder/examplegame"
- gameDirr[2] = ""
- gameDirr[3] = "worm"
- gameDirr[4] = ""
- masterpassword = "PLEASE change this"
- end
- ---------
- arcade = {}
- function arcade.int()
- config()
- insertCoin = paintutils.loadImage("recources/insertcoin")
- arcade.title()
- arcade.gameMenu()
- os.reboot()
- end
- function arcade.title()
- term.clear()
- paintutils.drawImage(insertCoin,21,1)
- term.setCursorPos(19,10)
- term.setBackgroundColor(colors.black)
- term.write("INSERT COIN!")
- term.setCursorPos(19,10)
- flash = true
- while true do
- flashTime = os.startTimer(2)
- timesFlashed = 0
- --^^this is is 30 we shutdown
- event,but,x,y= os.pullEvent()
- if event == "mouse_click"then
- if x==51 and y==19 then
- arcade.adminMenu()
- return -- if they fail
- else
- return
- end
- elseif event == "timer" and but == flashTime and flash == true then
- term.setCursorPos(19,10)
- term.write(" ")
- flash = false
- timesFlashed = timesFlashed +1
- elseif event =="timer" and but == flashTime and flash == false then
- term.setCursorPos(19,10)
- term.write("INSERT COIN!")
- flash = true
- timesFlashed = timesFlashed+1
- end
- if timesFlashed > 29 then
- os.shutdown()
- end
- end
- end
- function arcade.adminMenu()
- print("Admin menu. Enter password, enter to exit")
- local trypass = read()
- if trypass==masterpassword then
- shell.run("shell")
- error("An admin killed the program")
- end
- end
- function arcade.gameMenu()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(23,4)
- term.setTextColor(colors.red)
- print"MENU:"
- term.setTextColor(colors.white)
- term.setCursorPos((51-#game[1])/2,8)
- print(game[1])
- term.setCursorPos((51-#game[2])/2,9)
- print(game[2])
- term.setCursorPos((51-#game[3])/2,10)
- print(game[3])
- term.setCursorPos((51-#game[4])/2,11)
- print(game[4])
- local selected = 8
- local selectedGame =1
- while true do
- for i=8,11 do
- term.setCursorPos(((51-#game[i-7])/2)-1,i)
- term.write(" ")
- term.setCursorPos(((51-#game[i-7])/2)+#game[i-7],i)
- term.write(" ")
- end
- term.setCursorPos(((51-#game[selectedGame])/2)-1,selected)
- term.write(">")
- term.setCursorPos(((51-#game[selectedGame])/2)+#game[selectedGame],selected)
- term.write("<")
- local _,key=os.pullEvent("key")
- if key==200 and selectedGame>1 then
- selected = selected-1
- selectedGame = selectedGame-1
- elseif key == 208 and selectedGame<4 then
- selected=selected+1
- selectedGame=selectedGame+1
- elseif key == 28 then
- arcade.handleGame(gameDirr[selectedGame])
- os.reboot() -- to ensure a reboot
- end
- end
- end
- function arcade.handleGame(path)
- --finally, no more GUI coding
- --GUI coding requires SO MUCH MATHS :C
- --this should be a very simple function. I hope.
- --print"handlegame"
- --sleep(5)
- shell.run(path)
- --print"die"
- os.reboot()
- --we have this here incase more must be added
- end
- function arcade.handleAutoShutoff()
- gameCo = coroutine.create(arcade.int)
- os.startTimer(0.05)
- while true do
- --print"res"
- shutoffTimer = os.startTimer(60) --1 minute shutoff timer
- while true do
- events = {os.pullEvent()}
- if events[1] == "timer" then
- --print"tim"
- if events[2] == shutoffTimer then
- --print"ye"
- os.shutdown()
- end
- end
- if events[1] == evt or evt == nil then
- err, evt = coroutine.resume(gameCo, unpack(events))
- --print"Break"
- break
- end
- if coroutine.status == "dead" then
- os.reboot()
- end
- end
- end
- print("ded")
- print(err)
- print(evt)
- if err == "An admin killed the program" then else
- os.reboot() --cheapo way of restart thing :P
- end
- end
- arcade.handleAutoShutoff()
Advertisement
Add Comment
Please, Sign In to add comment