Posted 28 November 2012 - 05:05 PM
the goal / setup
I'm trying to make a program to time beer / rum and have persistent data, my setup is 14 booze barrels each with a button (attached to the first 14 colours of bundled cable, to the back of the computer) and a red stone lamp ( same but to the bottom) and a indicator lamp on each side of the computer. I want to time each barrel when the button is pressed to the amount of time the user types in, with persistent data be twine logins / chunks unloading.
the problem
my program prints 12 and exits even tough it shouldn't exit or print anything like 12 or any variable that could contain 12. to replicate the error; just run the program, no special circumstances required.
the code
warning this is a work in progress, load doesn't work yet and i'm just programming barrel number one first because the blocks relating to a specific barrel should tessellate with only minor adjustments. sorry for probably posting a stupid error and being noobie, but I spent all of my free time for the past weak on finding this error I.e. > 10 Hours but instead of rage quitting and probably being noobie forever i'll ask for help and hopefully learn something. so please help a noob in need.
I'm trying to make a program to time beer / rum and have persistent data, my setup is 14 booze barrels each with a button (attached to the first 14 colours of bundled cable, to the back of the computer) and a red stone lamp ( same but to the bottom) and a indicator lamp on each side of the computer. I want to time each barrel when the button is pressed to the amount of time the user types in, with persistent data be twine logins / chunks unloading.
the problem
my program prints 12 and exits even tough it shouldn't exit or print anything like 12 or any variable that could contain 12. to replicate the error; just run the program, no special circumstances required.
the code
warning this is a work in progress, load doesn't work yet and i'm just programming barrel number one first because the blocks relating to a specific barrel should tessellate with only minor adjustments. sorry for probably posting a stupid error and being noobie, but I spent all of my free time for the past weak on finding this error I.e. > 10 Hours but instead of rage quitting and probably being noobie forever i'll ask for help and hopefully learn something. so please help a noob in need.
Spoiler
term.clear()
term.setCursorPos(1,1)
function addcol(col, side)
rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side),col))
end
function remcol(col, side)
rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side),col))
end
save = function()
print("save started")
while true do
sleep(0)
timerf = fs.open("timer", "w")
timerf.writeLine(tostring(tme))
timerf.write(tostring(qu))
timerf.close()
timef = fs.open("time", "w")
timef.writeLine(tostring(timeone))
timef.writeLine(tostring(timetwo))
timef.writeLine(tostring(timethree))
timef.writeLine(tostring(timefour))
timef.writeLine(tostring(timefive))
timef.writeLine(tostring(timesix))
timef.writeLine(tostring(timeseven))
timef.writeLine(tostring(timeeight))
timef.writeLine(tostring(timenine))
timef.writeLine(tostring(timeten))
timef.writeLine(tostring(timeelven))
timef.writeLine(tostring(timetwlve))
timef.writeLine(tostring(timetherteen))
timef.write(tostring(timefourteen))
timef.close()
timel = fs.open("time left", "w")
timel.writeLine(tostring(timeleftOne))
timel.writeLine(tostring(timeleftTwo))
timel.writeLine(tostring(timeleftThree))
timel.writeLine(tostring(timeleftFour))
timel.writeLine(tostring(timeleftFive))
timel.writeLine(tostring(timeleftSix))
timel.writeLine(tostring(timeleftSeven))
timel.writeLine(tostring(timeleftEight))
timel.writeLine(tostring(timeleftNine))
timel.writeLine(tostring(timeleftTen))
timel.writeLine(tostring(timeleftElven))
timel.writeLine(tostring(timeleftTwlve))
timel.writeLine(tostring(timeleftTherteen))
timel.writeLine(tostring(timeleftFourteen))
timel.close()
sleep(0.2)
end
end
timer = function()
print("timer started")
while true do
sleep(0)
for qu = 0, 60 do
sleep(1)
end
tme = tme + 1
end
end
main = function()
print("main started")
while true do
sleep(0)
if rs.testBundledInput ("back", 1) == true then
rs.setOutput("right", true)
rs.setOutput("left", true)
addcol(1, "bottom")
timeone = tme
term.clear()
term.setCursorPos(1,1)
print("you just put something in number One")
print("|-------------------------------------------|")
print("| |")
print("| what would you like to make? |")
print("| 1) Brew--------------------------0 minuts |")
print("| 2) Youngster-------------------120 minuts |")
print("| 3) Beer------------------------240 minuts |")
print("| 4) Ale-------------------------720 minuts |")
print("| 5) Dragonblood----------------1440 minuts |")
print("| 6) rum--------------------------60 minuts |")
print("| |")
print("|-------------------------------------------|")
timeleftOne = tonumber(read())
term.clear()
term.setCursorPos(1,1)
print("Still waiting for number One")
rs.setOutput("right", false)
rs.setOutput("left", false)
sleep(0)
end
One = tme - timeone
Two = tme - timetwo
Three = tme - timethree
Four = tme - timefour
Five = tme - timefive
Six = tme - timesix
Seven = tme - timeseven
Eight = tme - timeeight
Nine = tme - timenine
Ten = tme - timeten
Elven = tme - timeelven
Twlve = tme - timetwlve
Therteen = tme - timetherteen
Fourteen = tme - timefourteen
term.setCursorPos(1,1)
if One > tonumber(timeleftOne) or One == tonumber(timeleftOne) then
timeone = 0
print("One finshed or empty")
remcol(1, "bottom")
else print("Still waiting "..tostring(One).." minuts for one")
end
sleep(0.25)
term.clear()
end
end
parallel.waitForAll (timer, main, save)
Edited by