Advertisement
4RAJ

Graphical Joystick

Jul 25th, 2023 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.86 KB | Gaming | 0 0
  1. function BlitScreen(mode, sticker, speed, w, a, s, d)
  2.     term.clear()
  3.    
  4.     if mode == "base" then
  5.         print(string.format("            ##            ", symbol_w, symbol_w))    
  6.         print(string.format("           #  #           ", symbol_w, symbol_w))
  7.         print(string.format("  speed   #    #    mode  ", symbol_w, symbol_w))
  8.         print(string.format("  >>Tab  # suth #   >> E  ", symbol_w, symbol_w))
  9.         print(string.format("    %d     ##  ##    %s  ", speed, mode))
  10.         print(string.format("           #  #           ", symbol_w, symbol_w))
  11.         print("   #        ##        #   ")
  12.         print(string.format("  # #                # #  ", symbol_a, symbol_a, symbol_d, symbol_d))
  13.         print(string.format(" #  ####          ####  # ", symbol_a, symbol_a, symbol_a, symbol_a, symbol_a, symbol_d, symbol_d, symbol_d, symbol_d, symbol_d))
  14.         print(string.format("# east  #        #  west #", symbol_a, symbol_a, symbol_d, symbol_d))
  15.         print(string.format(" #  ####          ####  # ", symbol_a, symbol_a, symbol_a, symbol_a, symbol_a, symbol_d, symbol_d, symbol_d, symbol_d, symbol_d))
  16.         print("  # #                # #  ")
  17.         print("   #        ##        #   ")
  18.         print("           #  #           ")
  19.         print("          ##  ##          ")
  20.         print("         # nrth #         ")
  21.         print("          #    #          ")
  22.         print("           #  #           ")
  23.         print("            ##            ")
  24.     elseif mode == "head" then
  25.         print("            ##            ")
  26.         print("           #  #           ")
  27.         print("  speed   #    #    mode  ")
  28.         print("  >>Tab  #  up  #   >> E  ")
  29.         print(string.format("    %d     ##  ##    %s  ", speed, mode))
  30.         print("           #  #           ")
  31.         print("            ##            ")
  32.         print("   ####            ####   ")
  33.         print("  #    #  <left   #    #  ")
  34.         print(" #  ##  #        #  ##  # ")
  35.         print("  #  #    right>    #  #  ")
  36.         print("   #                  #   ")
  37.         print("            ##            ")
  38.         print("           #  #           ")
  39.         print(" sticker  ##  ##  falling ")
  40.         print("  >> Q   # down # >>SHIFT ")
  41.         print(string.format("   %s    #    #    %s   ", sticker, fall and " ON" or "OFF"))
  42.         print("           #  #           ")
  43.         print("            ##            ")
  44.     end
  45. end
  46.  
  47. local w = false
  48. local a = false
  49. local s = false
  50. local d = false
  51.  
  52. local mode = "base"
  53. local speed = 1
  54. local sticker = "OFF"
  55. local fall = false
  56.  
  57. BlitScreen(mode, sticker, speed, w, a, s, d)
  58.  
  59. while true do
  60.     local event, key, isHeld = os.pullEvent("key")
  61.  
  62.     if key == keys.e then
  63.         if mode == "base" then
  64.             mode = "head"
  65.         else
  66.             mode = "base"
  67.         end
  68.     end
  69.    
  70.     if mode == "head" then
  71.         if key == keys.q then
  72.             if sticker == "OFF" then
  73.                 sticker = "ON "
  74.             else
  75.                 sticker = "OFF"
  76.             end
  77.         end
  78.     end
  79.    
  80.     if key == keys.tab then
  81.         if speed == 1 then
  82.             speed = 2
  83.         else
  84.             speed = 1
  85.         end
  86.     end
  87.    
  88.     if key == keys.shift then
  89.         if fall == false then
  90.             fall = true
  91.         else
  92.             fall = false
  93.         end
  94.     end
  95.    
  96.     if (key == keys.w) and isHeld then
  97.         w = true
  98.     else
  99.         w = false
  100.     end
  101.    
  102.     if (key == keys.a) and isHeld then
  103.         a = true
  104.     else
  105.         a = false
  106.     end
  107.  
  108.     if (key == keys.s) and isHeld then
  109.         s = true
  110.     else
  111.         s = false
  112.     end
  113.  
  114.     if (key == keys.d) and isHeld then
  115.         d = true
  116.     else
  117.         d = false
  118.     end
  119.    
  120.     BlitScreen(mode, sticker, speed, w, a, s, d)
  121.     local w = false
  122.     local a = false
  123.     local s = false
  124.     local d = false
  125.    
  126.     os.sleep(0.5)
  127. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement