Posted 25 July 2017 - 07:18 AM
hello all i am writing a draconic reactor control program with computercraft and plethora. i am having an issue with one of the functions in my program. after scanning to find at which power output the reactor passes redstone level 8 on the code it blanks out and stops transmiting power. i was wondering if someone can help me rewrite this code and make it better.
function control()
storagechg.setAnalogOutput(storagechgsde,0)
if disabled["mainctl"] and not t.buttonList["active"]["active"] then
t:toggleButton("active")
end
local times = 0
oldfuel = fuel.getAnalogInput(fuelside)
powerlevel = 1
powerchng = true
while true do
term.clear()
term.setCursorPos(1,1)
if fuel.getAnalogInput(fuelside) > 14 then
shldpwr.setAnalogOutput(shldsde,7)
storagechg.setAnalogOutput(storagechgsde,15)
mainpwr.setAnalogOutput(mainpwrsde,0)
buttont("mainpwr","off")
if times == 1 then
local input = "reactor fuel low"
sleep(5)
http.post("http://server.jesusfreakserver.com/multicraft/mail.php?message="..textutils.urlEncode(input),"a")
times = 2
end
elseif temp.getAnalogInput(tempsd) > 10 or sat.getAnalogInput(satsd) < 3 then
mainpwr.setAnalogOutput(mainpwrsde,0)
buttont("mainpwr","off")
else
if oldfuel < fuel.getAnalogInput(fuelside) then
powerchng = true
end
buttont("mainpwr","on")
if powerchng == true then
for i = 1,15 do
term.setCursorPos(1,1)
print(i.." test powerlevel")
if temp.getAnalogInput(tempsd) > 8 then
powerchng = false
mainpwr.setAnalogOutput(mainpwrsde,i-1)
term.setCursorPos(1,1)
print(math.floor(i-1).." final output")
sleep()
break
--# it is right after this break that the program stops functioning i think or around this part. i have all of the program working in parallel with other parts such as a screen with progress bars and dialog buttons.
else
term.setCursorPos(1,1)
mainpwr.setAnalogOutput(mainpwrsde,i)
for i = 3,5 do
term.setCursorPos(1,i)
term.clearLine()
end
term.setCursorPos(1,3)
local fuelstate = oldfuel < fuel.getAnalogInput(fuelside)
print("has fuel change been detected" .. tostring(fuelstate) )
print("temp is " ..temp.getAnalogInput(tempsd) )
print("saturation is " ..sat.getAnalogInput(satsd) )
end
sleep(10)
end
end
end
end
end
Edited on 25 July 2017 - 11:20 PM