Posted 20 December 2012 - 09:06 AM
EDIT* Help I run this and get:
startup:32: attempt to compare number with string expected, got number.
Can Anyone help me out?
I started this code yesterday was unsure if it would fully work. I plan to place a couple of computer/dispenser machines around spawn to sell melons. Basically it would work like a soda machine, only instead of costing money you could just enter your name. I know that anyone with the passcode could fake their name, but whatever. I'm not too strict on whether the name is legit or not. I just need special attention around the line where I run the redpulse and the line where I change the amount entered into a usable number.
For my Pastebin people: http://pastebin.com/kdSV2Gf5
startup:32: attempt to compare number with string expected, got number.
Can Anyone help me out?
I started this code yesterday was unsure if it would fully work. I plan to place a couple of computer/dispenser machines around spawn to sell melons. Basically it would work like a soda machine, only instead of costing money you could just enter your name. I know that anyone with the passcode could fake their name, but whatever. I'm not too strict on whether the name is legit or not. I just need special attention around the line where I run the redpulse and the line where I change the amount entered into a usable number.
For my Pastebin people: http://pastebin.com/kdSV2Gf5
--Code that dispenses melons while logging names and numbers for later reading
os.pullEvent = os.pullEventRaw
textutils.slowPrint("MelonDispenser 5000")
textutils.slowPrint("Made by FangCo. ")
textutils.slowPrint("Please Enter Your Name.")
name = read()
if name == "admin" then
print("Admin Recognized!")
print("Please Enter Your Passcode!")
passcode = read("*")
if passcode == "danrocks" then
print("Access Granted!")
sleep(3)
term.clear()
term.setCursorPos(1,1)
else
print("Incorrect Passcode!")
sleep(3)
os.reboot()
end
else
term.clear()
term.setCursorPos(1,1)
print("Welcome "..name.."! ")
textutils.slowPrint("Please Enter Your Passcode!")
pass = read("*")
if pass == "cake" then
print("Passcode Correct "..name.."!")
print("Please Enter Desired Amount (below 32)")
amount = io.read()
amount = tonumber(amount)
max = 32
min = 1
if amount > max then
print("Sorry Number too High! Try Again!")
sleep(3)
os.reboot()
elseif amount < min then
print("Sorry Number Too Low!")
sleep(3)
os.reboot()
else
print("Ok! Depositing "..amount.." to the right!")
shell.run("redpulse", "right", ""..amount.."", ".5")
print("Have a Nice Day!")
log = fs.open("logbook", "a")
log = fs.writeLine(" "..name.." entered the passcode and received "..amount.." melons!")
sleep(4)
os.reboot()
end
else
print("Sorry Incorrect Passcode!")
sleep(4)
os.reboot()
end
end