JustDoesGames

TileCodes

Apr 28th, 2019
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1.  
  2. --[[ TileCodes ]]--
  3. --[[ Created by Just Does Games ]]--
  4. --[[ Version 1.0 ]]--
  5.  
  6. --[[ VARIABLES ]]--
  7.  
  8. local selected = 0
  9.  
  10. --[[ VARIABLES ]]--
  11.  
  12.  
  13. --[[ FUNCTION ]]--
  14.  
  15. function clr() term.clear() end
  16. function cp(x,y) term.setCursorPos(x,y) end
  17. --function sb(col) term.setBackgroundColor(colors[col]) end
  18. function st(col) term.setTextColor(colors[col]) end
  19.  
  20. function update()
  21.     clr() cp(1,1)
  22.     print(selected)
  23.  
  24.     if selected == 0 then
  25.         st("gray")
  26.     else
  27.         st("white")
  28.     end
  29.  
  30.     print("-") st("white")
  31.     print("")
  32.     print(string.char(selected))
  33.     print("")
  34.  
  35.     if selected == 255 then
  36.         st("gray")
  37.     else
  38.         st("white")
  39.     end
  40.  
  41.     print("+") st("white")
  42. end
  43.  
  44. --[[ FUNCTION ]]--
  45.  
  46.  
  47. --[[ MAIN ]]--
  48.  
  49. function main()
  50.     local running = true
  51.     while running do
  52.         update()
  53.         a,i = os.pullEvent("key")
  54.         if i == keys.w or i == keys.up then
  55.             if selected ~= 0 then
  56.                 selected = selected - 1
  57.             end
  58.         elseif i == keys.s or i == keys.down then
  59.             if selected ~= 255 then
  60.                 selected = selected + 1
  61.             end
  62.         elseif i == keys.q or i == keys.enter then
  63.             running = false
  64.         end
  65.     end
  66. end
  67.  
  68. main()
  69. print("Final Number: "..selected)
  70. print("Display: "..string.char(selected))
  71. print("Code: string.char("..selected..")")
  72.  
  73. --[[ MAIN ]]--
Advertisement
Add Comment
Please, Sign In to add comment