JesseM1024

vine_age_measure

Sep 24th, 2025
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | Gaming | 0 0
  1. --index--
  2. local target_block  = "back"
  3. local testing_method = 4  -- getBlockStates
  4. local text_scale = 0.5
  5. --index end--
  6.  
  7. local age_list = {}
  8. for i = 0, 24 do
  9.     age_list[i] = 0
  10. end
  11.  
  12. local monitor = peripheral.find("monitor")
  13. monitor.clear()
  14. monitor.setTextScale(text_scale)
  15.  
  16. local function printAgeList()
  17.     monitor.clear()
  18.     monitor.setCursorPos(1, 1)
  19.     monitor.setTextColor(colors.white)
  20.     monitor.write("Vine Age Counter")
  21.     local y = 2
  22.     for i = 0, 24 do
  23.         monitor.setCursorPos(1, y)
  24.         monitor.write(string.format("%2d : %d", i, age_list[i]))
  25.         y = y + 1
  26.     end
  27. end
  28.  
  29. local method_table = peripheral.getMethods(target_block)
  30.  
  31. if method_table ~= nil then
  32.     while true do
  33.         if redstone.getInput("front") then
  34.             local test_result = peripheral.call(target_block, method_table[testing_method])
  35.  
  36.             if type(test_result) == "table" and test_result["age"] then
  37.                 local age = test_result["age"]
  38.                 if age >= 0 and age <= 24 then
  39.                     age_list[age] = age_list[age] + 1
  40.                 end
  41.             end
  42.  
  43.             printAgeList()
  44.  
  45.             repeat sleep(0.1) until not redstone.getInput("front")
  46.         end
  47.         sleep(0.1)
  48.     end
  49. end
  50.  
Advertisement
Add Comment
Please, Sign In to add comment