Posted 22 July 2012 - 04:37 AM
Hello everybody. This may seem like a strange title but it is NOT a sign that i'm crazy. I have been trying to create a shopkeeper program, but no matter what you enter it always makes you buy a shovel. I'm not sure whats wrong with it, I have tried several different ways of doing this but with no results I decided to post my original script online to see what others thought…(maybe you see something I miss?)
Anyways, code:
P.P.S Any efficiency tips also appreciated
Anyways, code:
shell.run("clear")
print("Shopkeeper> What would you like to do today?")
write("Shopper> ")
local BOR = read()
if BOR == "buy" or "Buy" then
print("Shopkeeper> What would you like to buy today?")
write("Shopper> ")
local BD = read()
if BD == "shovel" or "Shovel" then
rs.setOutput("right", true)
sleep(.5)
rs.setOutput("right", false)
print("Shopkeeper> Have a nice day!")
sleep(2)
os.shutdown()
elseif BD == "sword" or "Sword" then
rs.setOutput("left", true)
sleep(.5)
rs.setoutput("left", false)
print("Shopkeeper> Have a nice day!")
sleep(2)
os.shutdown()
end
elseif BOD == "repair" or "Repair" then
print("Shopkeeper> Please put your item in the repair bin")
rs.setOutput("top", true)
sleep(.5)
rs.setOutput("top", false)
print("Shopkeeper> Have a nice day!")
sleep(2)
os.shutdown()
else
print("Shopkeeper> That is not a service.")
sleep(2)
os.reboot()
end
P.S Please note that this code is in early stages and is not actually going to be used yet (pricing and other items not yet implemented)P.P.S Any efficiency tips also appreciated