This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
b0b349's profile picture

Simple Program Help

Started by b0b349, 26 July 2012 - 06:26 AM
b0b349 #1
Posted 26 July 2012 - 08:26 AM
So i was trying to make basically an automatic smelter, but I needed the redstone to repeat a certain number of times so i whipped together this along with the rest of the class. When i run it it gets to the point where the redstone turns on, then it freezes. Please Help!

local r = 1
function repeatt(par1)
repeat
rs.setOutput("bottom",true)
sleep(1)
rs.setOutput("bottom",false)
r = r+1
until r == par1
end

function main()
term.clear()
term.setCursorPos(1,1)
print("how many items are you smelting?")
time = read()
full = time*5
complete = full+10
term.clear()
term.setCursorPos(1,1)
write("You Smelting time will be approx ")
write(complete)
write(" seconds.")
repeatt(time)
sleep(complete)
repeatt(time)
shell.run("menu")
end
main()
BigSHinyToys #2
Posted 26 July 2012 - 08:52 AM
Found the bugs
this works
Spoiler

local r = 0
function repeatt(par1)
r = 0 -- to reset the counter
repeat
rs.setOutput("bottom",true)
sleep(1)
rs.setOutput("bottom",false)
sleep(1) -- to make it stay off for one second
r = r+1
until r == par1
end
function main()
term.clear()
term.setCursorPos(1,1)
print("how many items are you smelting?")
sTime = tonumber(read()) -- converts the string into a number
full = sTime*5
complete = full+10
term.clear()
term.setCursorPos(1,1)
write("You Smelting time will be approx ")
write(complete)
write(" seconds.")
repeatt(sTime)
sleep(complete)
repeatt(sTime)
shell.run("menu")
end
main()
brett122798 #3
Posted 26 July 2012 - 08:53 AM
Found the bugs
this works
Spoiler

local r = 0
function repeatt(par1)
r = 0 -- to reset the counter
repeat
rs.setOutput("bottom",true)
sleep(1)
rs.setOutput("bottom",false)
sleep(1) -- to make it stay off for one second
r = r+1
until r == par1
end
function main()
term.clear()
term.setCursorPos(1,1)
print("how many items are you smelting?")
sTime = tonumber(read()) -- converts the string into a number
full = sTime*5
complete = full+10
term.clear()
term.setCursorPos(1,1)
write("You Smelting time will be approx ")
write(complete)
write(" seconds.")
repeatt(sTime)
sleep(complete)
repeatt(sTime)
shell.run("menu")
end
main()
Hah, earlier I was looking at the code and was pretty confused on what would be wrong but now it makes much more sense.
b0b349 #4
Posted 26 July 2012 - 08:54 AM
Found the bugs
this works
Spoiler

local r = 0
function repeatt(par1)
r = 0 -- to reset the counter
repeat
rs.setOutput("bottom",true)
sleep(1)
rs.setOutput("bottom",false)
sleep(1) -- to make it stay off for one second
r = r+1
until r == par1
end
function main()
term.clear()
term.setCursorPos(1,1)
print("how many items are you smelting?")
sTime = tonumber(read()) -- converts the string into a number
full = sTime*5
complete = full+10
term.clear()
term.setCursorPos(1,1)
write("You Smelting time will be approx ")
write(complete)
write(" seconds.")
repeatt(sTime)
sleep(complete)
repeatt(sTime)
shell.run("menu")
end
main()
thank you very much, i sat down for I don't know how long trying to figure this out.
BigSHinyToys #5
Posted 26 July 2012 - 08:59 AM
glad to have been of assistance
I guess I'm good at finding bugs because most of my own code is full of them lol XD