G2A Many GEOs
SHARE
TWEET

warehouse monitor

kssr3951 Apr 4th, 2015 (edited) 192 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sys = {}
  2. local function m(no) return "monitor_" .. tostring(no) end
  3. sys[1] = { mons = { m(31), m(32), m(33), m(34), m(35), m(36), m(37), m(38), m(39), m(40) } }
  4. sys[2] = { mons = { m(48), m(49), m(50), m(51), m(52), m(53), m(54), m(55), m(46), m(47) } }
  5. sys[3] = { mons = { m(59), m(60), m(61), m(62), m(63), m(64), m(65), m(66), m(67), m(68) } }
  6. sys[4] = { mons = { m(69), m(70), m(71), m(72), m(73), m(74), m(75), m(76), m(77), m(78) } }
  7. local MDM_DIR = "bottom"
  8. local mdm = peripheral.wrap(MDM_DIR)
  9.  
  10. local data = {}
  11. data[1] = { sys = 1, col = 1, stack = 1, name = "Cobblestone", qty = 444 }
  12. data[2] = { sys = 1, col = 1, stack = 2, name = "IronIngot", qty = 32 }
  13. data[3] = { sys = 2, col = 4, stack = 3, name = "Redstone", qty = 288 }
  14. data[4] = { sys = 3, col = 10, stack = 5, name = "unknown-1", qty = 33 }
  15. data[5] = { sys = 4, col = 3, stack = 4, name = "unknown-2", qty = 55 }
  16.  
  17. local function initialize(mdm, sys)
  18.   print("initialize monitors")
  19.   for i, s in ipairs(sys) do
  20.     for j, v in ipairs(s.mons) do
  21.       if not mdm.isPresentRemote(v) then
  22.         print(string.format("  system%d - column%d : %s is not found.", i, j, v))
  23.       else
  24.         mdm.callRemote(v, "setTextScale", 0.5)
  25.         mdm.callRemote(v, "clear", 0.5)
  26.         local tmp = string.format("sys%2dcol%2d", i, j)
  27.         for k = 1, 10 do
  28.           mdm.callRemote(v, "setCursorPos", 1, k)
  29.           mdm.callRemote(v, "write", string.sub(tmp, k, k))
  30.         end
  31.       end
  32.     end
  33.   end
  34. end
  35.  
  36. local function dispData(mdm, sys, dat)
  37.   local monitor = sys[dat.sys].mons[dat.col]
  38.   local stack = (5 - dat.stack) * 2 + 1
  39.   local quantity = dat.qty
  40.   if not mdm.isPresentRemote(monitor) then
  41.     print(monitor .. " is not found.")
  42.   else
  43.     local tmp = string.format("sys%2dcol%2d", dat.sys, dat.col)
  44.     mdm.callRemote(monitor, "setCursorPos", 3, stack + 0)
  45.     mdm.callRemote(monitor, "clearLine")
  46.     mdm.callRemote(monitor, "write", "[" .. dat.stack .. "]" .. dat.name)
  47.     mdm.callRemote(monitor, "setCursorPos", 1, stack + 0)
  48.     mdm.callRemote(monitor, "write", string.sub(tmp, stack + 0, stack + 0))
  49.  
  50.  
  51.     mdm.callRemote(monitor, "setCursorPos", 5, stack + 1)
  52.     mdm.callRemote(monitor, "clearLine")
  53.     mdm.callRemote(monitor, "write",
  54.       string.format("%dst (%d)", math.floor(quantity/64), quantity)) -- アイテムごとの最大スタック数
  55.     mdm.callRemote(monitor, "setCursorPos", 1, stack + 1)
  56.     mdm.callRemote(monitor, "write", string.sub(tmp, stack + 1, stack + 1))
  57.   end
  58. end
  59.  
  60. initialize(mdm, sys)
  61. for i, dat in ipairs(data) do
  62.   dispData(mdm, sys, dat)
  63. end
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top