This is my code:
local money = 100
local coffeepr = 5
local cookiepr = 3
rednet.open("back")
term.clear()
term.setCursorPos(1, 1)
sleep(.25)
print("What would you like to do?")
print("------------- ")
print("Buy ")
print("------------- ")
print("Check Balance ")
print("------------- ")
print("Help ")
term.setCursorPos(1, 9)
input=read()
if input == "Check Balance" then
print("You have ", money ," dollars")
sleep(3)
shell.run("credit")
elseif input == "Help" then
print("Automated Store Vendor by Grand_Panda!")
print("This system is very straight forward ")
print("when it comes to using and setting up.")
print("By typing 'edit credit' you can edit ")
print("the prices and the menu. Even this help ")
print("menu! If you are a customer then everything ")
print("is pretty much layed out for you! Just put ")
print("in your credit card-floppy disk- and select ")
print("your items!")
sleep(20)
shell.run("credit")
function Buy()
term.clear()
term.setCursorPos(1, 1)
print("What would you like to buy?")
print(" ")
print("Coffee...........$",coffeepr)
print("Cookie...........$",cookiepr)
print(" ")
print(" ")
print(" ")
print(" ")
print("Back ")
term.setCursorPos(1, 11)
input = read()
if input == "Coffee" then
rednet.send(40, "Coffee")
local file = fs.open("disk/creditc","r")
local contents = file:readAll()
rednet.send(40, contents)
redstone.setBundledOutput("back", colors.white)
money = money-coffeepr
print("You have purchased a Coffee!")
print("You now have ", money ," dollars")
sleep(2)
Buy()
elseif input == "Cookie" then
rednet.send(40, "Cookie")
money = money-cookiepr
print("You have purchased a Cookie!")
print("You now have ", money ," dollars")
sleep(2)
Buy()
elseif input == "Back" then
shell.run("credit")
else
print("Command not recognized!")
sleep(1)
Buy()
end
end
elseif input == "Buy" then
Buy()<--------------------------------------------------------RIGHT HERE!
end
I keep getting 'attempt to call nil' on line 75. I used to have it above the function buy, I thought this was the problem so I moved it below but it still doesn't work. If someone could please tell me what I am doing wrong that would be great.Thanks! :D/>