Klazam33

Inventory Manipulation Test

May 4th, 2021 (edited)
1,049
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×