Advertisement
Klazam33

Inventory Manipulation Test

May 4th, 2021 (edited)
1,249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. os.loadAPI("kapi")
  2.  
  3. --Table of options
  4. option = {"insert", "remove"}
  5.  
  6. --Variables
  7. l = #option
  8. n = 1 --For Option Table
  9.  
  10. while true do
  11.  
  12.  kapi.menu("Please select a option from the following:")
  13.  for i = 1, l, 1 do
  14.   if n == i then
  15.    print(">" .. option[i] .. "<")
  16.   else
  17.    print(" " .. option[i])
  18.   end
  19.  end
  20.  
  21.  keypress = kapi.keyread()
  22.  if keypress == keys.up then --Up Arrow
  23.   if n == 1 then
  24.    n = l
  25.   else
  26.    n = n - 1
  27.   end
  28.  elseif keypress == keys.down then --Down Arrow
  29.   if n == l then
  30.    n = 1
  31.   else
  32.    n = n + 1
  33.   end
  34.  elseif keypress == keys.enter then --Enter key
  35.   if option[n] == "insert" then
  36.       if turtle.detect() == true then
  37.                 turtle.select(2)
  38.                 turtle.drop()
  39.             else
  40.                 print("Can't place inventory here!")
  41.         end
  42.    elseif option[n] == "remove" then
  43.       if turtle.detect() == true then
  44.                 turtle.select(2)
  45.                 turtle.suck(1)
  46.             else
  47.                 print("Can't remove inventory here!")
  48.         end            
  49.     end
  50.   end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement