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

Help! greater than (Diamond machine)

Started by MonkeyDew, 27 July 2012 - 02:52 PM
MonkeyDew #1
Posted 27 July 2012 - 04:52 PM
I dont know how to fix this, please help!

Code: Name of code: collect
——————————————————————————————-
print("How many diamonds do you wish to collect?")
x = io.read()
x = tonumber(x)
if x => 65 then # i think this is the problem i dont want it to be == though

Print("Collecting "..x.." diamonds for you!")
rs.setOutput("back", true)
sleep(x) # this works with what setup i have (Using timers and stuff)
rs.setOutput("back", false)
print("Thank you for using this program")
sleep(2)
shell.run("startup")

else

print("You can only take a maximum of 64 diamonds out at once!")
sleep(2)
shell.run("collect")
end
———————————————————————————————
Thanks for helping! That is, if you do help me…
Lasere123456 #2
Posted 27 July 2012 - 05:04 PM

write("How many diamonds do you wish to collect?: ")
x = io.read()
x = tonumber(x)
if x => 65 then 
Print("Collecting "..x.." diamonds for you!")
rs.setOutput("back", true)
sleep(x) 
rs.setOutput("back", false)
print("Thank you for using this program")
sleep(2)
shell.run("startup")
else
print("You can only take a maximum of 64 diamonds out at once!")
sleep(2)
shell.run("collect")
end

did not test it, but i think this would work
sjonky #3
Posted 27 July 2012 - 05:05 PM

print("How many diamonds do you wish to collect?")
x = io.read()
x = tonumber(x)
if x >= 65 then # Guessing your using it the wrong way	
    Print("Collecting "..x.." diamonds for you!")
	rs.setOutput("back", true)
	sleep(x) 
	rs.setOutput("back", false)
	print("Thank you for using this program")
	sleep(2)
	shell.run("startup")

else

	print("You can only take a maximum of 64 diamonds out at once!")
	sleep(2)
	shell.run("collect")
end

Lasere123456 #4
Posted 27 July 2012 - 05:09 PM

print("How many diamonds do you wish to collect?")
x = io.read()
x = tonumber(x)
if x >= 65 then # Guessing your using it the wrong way	
	Print("Collecting "..x.." diamonds for you!")
	rs.setOutput("back", true)
	sleep(x)
	rs.setOutput("back", false)
	print("Thank you for using this program")
	sleep(2)
	shell.run("startup")

else

	print("You can only take a maximum of 64 diamonds out at once!")
	sleep(2)
	shell.run("collect")
end


am i bind or did you just copy/paste his code into a code area?
sjonky #5
Posted 27 July 2012 - 05:10 PM
I changed

if x => 65 then

to

if x >= 65 then
MonkeyDew #6
Posted 27 July 2012 - 05:14 PM
Thank you!
You have fixed the problem
Lasere123456 #7
Posted 27 July 2012 - 05:15 PM
I changed

if x => 65 then

to

if x >= 65 then

i knew i was blind :)/>/>
BigSHinyToys #8
Posted 27 July 2012 - 05:22 PM
couple of small problems comments are made using – not # btw
Spoiler

print("How many diamonds do you wish to collect?")
x = io.read()
x = tonumber(x)
if x < 64 then -- i think this is the problem i dont want it to be == though
    print("Collecting "..x.." diamonds for you!") -- print not Print
    rs.setOutput("back", true)
    sleep(x) -- this works with what setup i have (Using timers and stuff)
    rs.setOutput("back", false)
    print("Thank you for using this program")
    sleep(2)
    os.reboot() -- or you will cause stack over flow
else
    print("You can only take a maximum of 64 diamonds out at once!")
    sleep(2)
    shell.run("collect")
   
end