Advertisement
guitarplayer616

jumble

May 28th, 2015
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.01 KB | None | 0 0
  1. function input()
  2.   local handle = fs.open(shell.resolve("startup"),"w")
  3.   handle.write('local w,h = term.getSize() term.setTextColor(colors.yellow) term.clear() term.setCursorPos(1,1)')
  4. 'print(\"CraftOS 1.6\")
  5. term.write(\">  \")
  6. local on = nil
  7. local x,y = nil, nil
  8. local curPos = nil
  9. local str = \"\"
  10.  
  11. function inscribe(string,a,b,textcol,backcol)
  12.  if a and b then
  13.    term.setCursorPos(a,b)
  14.  end
  15.  if textcol then
  16.    term.setTextColor(textcol)
  17.  end
  18.  if backcol then
  19.    term.setBackgroundColor(backcol)
  20.  end
  21.  write(string)
  22. end
  23.  
  24. function blink(x,y)
  25.  x,y = nil,nil
  26.  if not on then
  27.    x,y = term.getCursorPos()
  28.    inscribe(\"_\",x-1,y,colors.white)
  29.    write(string.rep(\" \",w-x))
  30.    term.setCursorPos(x,y)
  31.    on = true
  32.  elseif on then
  33.    x,y = term.getCursorPos()
  34.    inscribe(\" \",x-1,y,colors.white)
  35.    write(string.rep(\" \",w-x))
  36.    term.setCursorPos(x,y)
  37.    on = nil
  38.  end
  39.  os.startTimer(.4)
  40. end
  41.  
  42. function scribe(string,textcol,backcol)
  43.  x,y = term.getCursorPos()
  44.  inscribe(string,x-1,y,textcol,backcol)
  45.  term.setCursorPos(x+1,y)
  46. end
  47.  
  48. function delete()
  49.  x,y = term.getCursorPos()
  50.  inscribe(\"  \",x-2,y)
  51.  term.setCursorPos(x-1,y)
  52. end
  53.  
  54. os.startTimer(.4)
  55.  
  56. while true do
  57.  local e = {os.pullEventRaw()}
  58.  if e[1] == \"timer\" and e[2] then
  59.    blink()
  60.  end
  61.  if e[1] == \"terminate\" then
  62.    inscribe(\"Terminated \n\",_,_,colors.red)
  63.    inscribe(\"Goodbye \n\",_,_,colors.yellow)
  64.    blink()
  65.    sleep(1)
  66.    term.clear()
  67.    os.shutdown()
  68.  end
  69.  if e[1] == \"char\" then
  70.    scribe(e[2])
  71.    if e[2] then
  72.      str = str..tostring(e[2])
  73.    end
  74.  end
  75.  curPosX,curPosY = term.getCursorPos()
  76.  if (e[1] == \"key\" and e[2] == 14) and (curPosX > 4 or curPosY < 2)  then
  77.    delete()
  78.    str = table.concat{str:sub(1,str:len()-1),\"\",str:sub(str:len()+1)}
  79.  end
  80.  if e[1] == \"key\" and e[2] == 28 then
  81.    x,y = term.getCursorPos()
  82.    inscribe(\" \",x-1,y)
  83.    print(nil)
  84.    shell.run(str)
  85.    term.setTextColor(colors.yellow)
  86.    write(\">  \")
  87.    term.setTextColor(colors.white)
  88.    str = \"\"
  89.  end
  90.  if e[1] == \"key\" and e[2] == 56 then
  91.    shell.run(\"pastebin run XAktVaSD\")
  92.  end
  93. end')
  94.   handle.close()
  95. end
  96.  
  97. handle.write('local w,h = term.getSize() term.setTextColor(colors.yellow) term.clear() term.setCursorPos(1,1) print(\"CraftOS 1.6\") term.write(\">  \") local on = nil local x,y = nil, nil local curPos = nil local str = \"\"  function inscribe(string,a,b,textcol,backcol) if a and b then term.setCursorPos(a,b) end if textcol then term.setTextColor(textcol) end if backcol then term.setBackgroundColor(backcol) end write(string) end function blink(x,y) x,y = nil,nil if not on then x,y = term.getCursorPos() inscribe(\"_\",x-1,y,colors.white) write(string.rep(\" \",w-x)) term.setCursorPos(x,y) on = true elseif on then x,y = term.getCursorPos() inscribe(\" \",x-1,y,colors.white) write(string.rep(\" \",w-x)) term.setCursorPos(x,y) on = nil end os.startTimer(.4) end function scribe(string,textcol,backcol) x,y = term.getCursorPos() inscribe(string,x1,y,textcol,backcol) term.setCursorPos(x+1,y) end  function delete() x,y = term.getCursorPos() inscribe(\"  \",x-2,y) term.setCursorPos(x-1,y) end os.startTimer(.4) while true do local e = {os.pullEventRaw()} if e[1] == \"timer\" and e[2] then blink() end if e[1] == \"terminate\" then inscribe(\"Terminated \n\",_,_,colors.red) inscribe(\"Goodbye \n\",_,_,colors.yellow) blink() sleep(1) term.clear() os.shutdown() end if e[1] == \"char\" then scribe(e[2]) if e[2] then str = str..tostring(e[2]) end end curPosX,curPosY = term.getCursorPos() if (e[1] == \"key\" and e[2] == 14) and (curPosX > 4 or curPosY < 2)  then delete() str = table.concat{str:sub(1,str:len()-1),\"\",str:sub(str:len()+1)} end if e[1] == \"key\" and e[2] == 28 then x,y = term.getCursorPos() inscribe(\" \",x-1,y) print(nil) shell.run(str) term.setTextColor(colors.yellow) write(\">  \") term.setTextColor(colors.white) str = \"\" end if e[1] == \"key\" and e[2] == 56 then shell.run(\"pastebin run XAktVaSD\") end end')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement