Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("bottom")
- function substringColonToSpace(inputString)
- local startPos = string.find(inputString, ":")
- if not startPos then
- return nil, "No colon found in the input string."
- end
- local endPos = string.find(inputString, " ", startPos)
- if not endPos then
- return nil, "No space found after the colon in the input string."
- end
- return string.sub(inputString, startPos + 1, endPos - 1)
- end
- function twoInputStrip(str)
- first, second = str:match("(%S+)%s+(%S+)")
- return first, second
- end
- function getAcceptedItems()
- rednet.send(0, "items please")
- id, items = rednet.receive()
- itemdb = {}
- for _, item in pairs(items) do
- temp, itemvalue = twoInputStrip(item)
- table.insert(itemdb, substringColonToSpace(item) .. " - $" .. itemvalue)
- end
- return itemdb
- end
- function getMonitorDirection()
- local peripherals = peripheral.getNames()
- for _, name in ipairs(peripherals) do
- if peripheral.getType(name) == "monitor" then
- return name
- end
- end
- return nil
- end
- function displayItems()
- direction = getMonitorDirection()
- if direction ~= nil then
- local monitor = peripheral.wrap(direction)
- monitor.clear()
- itemdb = getAcceptedItems()
- for i, item in pairs(itemdb) do
- monitor.setCursorPos(1, i)
- monitor.write(item)
- end
- end
- end
- displayItems()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement