Posted 06 January 2013 - 03:54 AM
I'm using MiscPeripherals and Forestry to try and automatically charge my machines. I'm using a gate reader to see how low the power is in the storage unit, and a computer connected to that to tell the engines when to turn on.
This is my code so far:
What kind of a loop do I need to put that in to make it constantly update itself? I tried the infinite loop (while true do) but that didn't seem to work. I also don't really want it to print the messages every time it goes through the loop; only when it actually updates. Is there any way to make that not happen? Thanks in advance for your help; it's very much appreciated.
This is my code so far:
m = peripheral.wrap("left")
data = m.get()
--for i, j in pairs(data) do
-- print(tostring(i)..": "..tostring(j))
--end
if (data["No Energy"]) then
print ("Needs recharge...")
redstone.setOutput("back", true)
elseif (data["Full Energy"]) then
print ("Turning off engines...")
redstone.setOutput("back", false)
end
What kind of a loop do I need to put that in to make it constantly update itself? I tried the infinite loop (while true do) but that didn't seem to work. I also don't really want it to print the messages every time it goes through the loop; only when it actually updates. Is there any way to make that not happen? Thanks in advance for your help; it's very much appreciated.