kd2bwzgen

pockemufix

Jun 8th, 2017
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. name = "Pockemu V1.1"
  4. args = { ... }
  5. program = table.concat(args, " ")
  6. if program == "" then
  7.   error("Usage: pockemu <program name>")
  8. end
  9. local function inAlphabet(k)
  10.   local alphabet = "abcdefghijklmnopqrstuvwxyz"
  11.   for i=1,#alphabet do
  12.     if k==keys[alphabet:sub(i,i)] then return true end
  13.   end
  14.   return false
  15. end
  16. local function anykey(msg)
  17.   print(msg and msg or "Press any key to continue...")
  18.   local tEvent = { os.pullEvent("key") }
  19.   if inAlphabet(tEvent[2]) then os.pullEvent("char") end
  20. end
  21. pakpromptcalled = false
  22. local function run(cmd)
  23.   oldTerm = term.redirect(term.native())
  24.   shell.run("pockemu "..cmd)
  25.   term.redirect(oldTerm)
  26.   term.setCursorPos(1,1)
  27.   term.clear()
  28. end
  29. x, y = term.getSize()
  30. term.clear()
  31. windowWidth = 26
  32. windowHeight = y
  33. windowBox = window.create(term.current(), 1, 1, windowWidth, windowHeight, true)
  34. _G.pocket = {}
  35. _G.pockemu = {}
  36. _G.pockemu.anykey = anykey
  37. _G.pockemu.run = run
  38. term.setBackgroundColour(colours.white)
  39. for x1 = windowWidth + 1, x do
  40.   for y1 = 1, y do
  41.     term.setCursorPos(x1, y1)
  42.     write(" ")
  43.   end
  44. end
  45. term.setTextColour(colours.black)
  46. term.setCursorPos(x/2 + (windowWidth + 1) / 2 - #name / 2, y/2)
  47. print(name)
  48. term.setBackgroundColour(colours.black)
  49. term.setTextColour(colours.white)
  50. oldTerm = term.redirect(windowBox)
  51. shell.run(program)
  52. term.redirect(oldTerm)
  53. term.clear()
  54. term.setCursorPos(1,1)
  55. windowBox = nil
  56. _G.pocket = nil
  57. _G.pockemu = nil
Advertisement
Add Comment
Please, Sign In to add comment