Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- You need to connect the computer to a stock ticker and a display link from Create before you start it
- -- Put this into startup.lua so it automatically starts when the computer starts (or the chunks are loaded)
- -- Format the number in a shorter format
- function format(num)
- if num >= 10 ^ 6 then
- return string.format("%.1fm", num / 10 ^ 6)
- elseif num >= 10 ^ 3 then
- return string.format("%.1fk", num / 10 ^ 3)
- else
- return tostring(num)
- end
- end
- local ticker = peripheral.find("Create_StockTicker")
- local link = peripheral.find("Create_DisplayLink")
- while true do
- -- Wait in the beginning so the surrounding chunks are loaded
- os.sleep(5)
- -- Get the stock of the network
- local stock = ticker.stock()
- local count = 0
- -- Count all items in the network
- -- If you want to do anything with the specific item types, this is the loop you need to change
- for _, entry in ipairs(stock) do
- count = count + entry.count
- end
- local writableCount = format(count)
- -- debug logging
- print(count)
- print(writableCount)
- -- Write to the display link
- link.clear()
- link.setCursorPos(1, 1)
- link.write(writableCount .. " Items")
- link.update()
- end
Advertisement
Add Comment
Please, Sign In to add comment