Posted 01 March 2013 - 07:24 PM
So I've never really played with LUA before, but I've coded in C and C++ and am somewhat familiar with similar languages. However, when I run the program I've created, it doesn't change outputs to the monitors (to On, or Off), and doesn't actually create output to the bundled cables nor print the toggle in the main screen.
Any ideas? I'm working out different thoughts as I edit this post multiple times.
Program in full (named power)
Any ideas? I'm working out different thoughts as I edit this post multiple times.
Program in full (named power)
local function runPower (tempTable)
do
local z = 1 --Default monitor position
local stringTable = {"Quarry Pow: ", "General Pow: ", "Hellfire Gen: ", "Recycler: ", "Biomass Prod: ", "Biofuel Prod: ", "Refinery: ", "Fuel Power: ", "Biofuel Gen: "}
mon = peripheral.wrap("left")
mon.clear()
for z=1,9 do
mon.setCursorPos(1,z)
mon.write(stringTable[z])
mon.write(tempTable[z])
end
end
end
do
--Initialization
--In order, Quarry, General Power, Lava Power, Recycler, Biomass production, Biofuel Production, Refinery, Combustion Engines, Biofuel Power,
local toggleTable = {"Off", "Off", "Off", "Off", "Off", "Off", "Off", "Off", "Off"}
local outputTable = {1, 2, 4, 2048, 32768, 16, 16384, 512, 32}
local textTable = {"Quarry set to ", "General power set to ", "Recycler power set to ", "Biofuel power set to ", "Biofuel production set to ", "Hellfire power set to ", "Biomass production set to ", "Refinery set to ", "Combustion engines set to "}
local exitvar = false --Set to 1 to exit loop
local outputs = 0 --Default output cable status all off
local command = 100 --Allows selections
redstone.setBundledOutput("back", outputs) --Init outputs to 0
print(command)
print(quarrypw)
end
do
term.clear()
textutils.slowPrint("Power v0.2")
print("Hit Enter to continue")
io.read()
end
while true do
if exitvar == true then break end --- Exit loop if exitvar set to true
print("Enter command to toggle:")
print("0 = Exit")
print("1 = Quarry Power")
print("2 = General Power")
print("3 = Recycler Power")
print("4 = Biofuel Power")
print("5 = Biofuel Production")
print("6 = Lava Power")
print("7 = Biomass Production")
print("8 = Fuel Refinery")
print("9 = Combustion Power")
command = tonumber(read())
--debug
if command == 0 then
exitvar = true
end
if command > 0 then
if boolTable[command] == "On" then
boolTable[command] = "Off"
write(textTable[command])
write(toggleTable[command])
outputs = outputs - outputTable[command]
end
if boolTable[command]=="Off" then
boolTable[command] = "On"
write(textTable[command])
write(toggleTable[command])
outputs = outputs + outputTable[command]
end
redstone.setBundledOutput("back", outputs)
runPower(boolTable) --Set outputs to cable and run monitor output
end
end
do
term.clear()
print("Exiting... press any key to continue")
io.read()
term.clear()
end