Posted 22 March 2014 - 02:11 PM
I am having problems writing a program to manage 4 redstone energy cells at once. The goal here is to have each redstone energy (each powered by its own series of engines) be charged when it is NOT full and turn the engines off when it IS full. I have figured out how to communicate with the colored cables as well as a separate monitor (via wireless router) however, I cannot seem to get all 4 while loops running concurrently. Either they run one after the other or they will cycle on for a few ticks and then turn off.
Keep in mind: Everything I know about Lua i have either taught myself or have seen in tutorials. I am very new to the language.
Here is my setup:
Here is my code:
Keep in mind: Everything I know about Lua i have either taught myself or have seen in tutorials. I am very new to the language.
Here is my setup:
Spoiler
Spoiler
local gatereader1 = peripheral.wrap("right")
local gatereader2 = peripheral.wrap("front")
local gatereader3 = peripheral.wrap("left")
local gatereader4 = peripheral.wrap("back")
local sRedstoneOutSide = "bottom"
local data
local bfull
rednet.open("top")
term.clear()
term.setCursorPos(1,1)
term.write("eMonitor v2.2")
term.setCursorPos(1,2)
term.write("Status: Running")
term.setCursorPos(1,3)
term.write("Hold Ctrl+T to terminate")
while(true) do
data = gatereader1.get()
bFull = data["Full Energy"]
term.setCursorPos(1,5)
if(bFull) then
term.write("Module 1: FULL")
rednet.send(24, "1 is full")
redstone.setBundledOutput("bottom", 0)
else
term.write("Module 1: CHARGING")
rednet.send(24, "1 is NOT full")
redstone.setBundledOutput("bottom", 1)
end
sleep(2)
end
while(true) do
data = gatereader2.get()
bFull = data["Full Energy"]
term.setCursorPos(1,6)
if(bFull) then
term.write("Module 2: FULL")
rednet.send(24, "2 is full")
redstone.setBundledOutput("bottom", 0)
else
term.write("Module 2: CHARGING")
rednet.send(24, "2 is NOT full")
redstone.setBundledOutput("bottom", 2)
end
sleep(2)
end
while(true) do
data = gatereader3.get()
bFull = data["Full Energy"]
term.setCursorPos(1,7)
if(bFull) then
term.write("Module 3: FULL")
rednet.send(24, "3 is full")
redstone.setBundledOutput("bottom", 0)
else
term.write("Module 3: CHARGING")
rednet.send(24, "3 is NOT full")
redstone.setBundledOutput("bottom", 3)
end
sleep(2)
end
while(true) do
data = gatereader4.get()
bFull = data["Full Energy"]
term.setCursorPos(1,8)
if(bFull) then
term.write("Module 4: FULL")
rednet.send(24, "4 is full")
redstone.setBundledOutput("bottom", 0)
else
term.write("Module 4: CHARGING")
rednet.send(24, "4 is NOT full")
redstone.setBundledOutput("bottom", 4)
end
sleep(2)
end
Edited on 22 March 2014 - 04:35 PM