7 posts
Posted 19 February 2013 - 03:26 AM
Title: [Question][Lua] Need help with openCCsensors
Need a simple example program wich can count items in inventory and compare with variable and if true - redstone signal. Just cant find any of openCCtutorials or videos with simple code and functions…
BTW: Sorry for my English, thanks in advance.
730 posts
Location
London, UK
Posted 19 February 2013 - 08:59 AM
os.loadAPI("ocs/apis/sensor")
local invent = sensor.wrap("left")
local target = "1,0,0"
local signalAt = 10
local outputSide = "back"
while true do
local details = invent.getTargetDetails(target)
local count = 0
for key, slot in pairs(details.Slots) do
count = count + slot.Size
end
rs.setOutput(outputSide, count >= signalAt)
sleep(2)
end
Every 2 seconds this will check the chest at "targetAt", and if there's the same amount (or more) of "signalAt", it'll output a redstone signal on "outputSide"
7 posts
Posted 19 February 2013 - 10:09 AM
os.loadAPI("ocs/apis/sensor")
local invent = sensor.wrap("left")
local target = "1,0,0"
local signalAt = 10
local outputSide = "back"
while true do
local details = invent.getTargetDetails(target)
local count = 0
for key, slot in pairs(details.Slots) do
count = count + slot.Size
end
rs.setOutput(outputSide, count >= signalAt)
sleep(2)
end
Every 2 seconds this will check the chest at "targetAt", and if there's the same amount (or more) of "signalAt", it'll output a redstone signal on "outputSide"
Tnx a lot!
730 posts
Location
London, UK
Posted 19 February 2013 - 12:03 PM
No worries