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

Help with simple AI

Started by blueflames7, 26 November 2012 - 05:22 AM
blueflames7 #1
Posted 26 November 2012 - 06:22 AM
I'm not actually using ComputerCraft right now, but I'm doing it in the Lua live demo. I have some code that needs de-bugging. You can run it and see what errors you get in CC.

print ("Hi! I'm AlienAI Alpha 1.1! How was your day?")
print ("Good/Bad")
.yeild
io.read()
if "Good" then
   print ("Mine was great also!")
   end
if "Bad" then
   print ("Aww! I hope it gets better!")
   end
print ("Do you like music?")
print ("Yes/No")
.yield
if "Yes" then
   print ("Me too!")
   end
if "No" then
   print ("Hmm. Never heard of someone who doesn't like music...")
   end
print ("Oh well then. Goodbye!")
Kingdaro #2
Posted 26 November 2012 - 06:47 AM
You're using ".yelid" in place of "read()". I honestly have no idea where you got that from, but no matter. Fixies away!


local input

print ("Hi! I'm AlienAI Alpha 1.1! How was your day?")
print ("Good/Bad")

input = read()

if input == "Good" then
   print ("Mine was great also!")
elseif input == "Bad" then
   print ("Aww! I hope it gets better!")
end

print ("Do you like music?")
print ("Yes/No")

input = read()

if input == "Yes" then
   print ("Me too!")
elseif input == "No" then
   print ("Hmm. Never heard of someone who doesn't like music...")
end

print ("Oh well then. Goodbye!")

One would store user input into a variable using read(), and then you would check that input against other strings and act accordingly.
blueflames7 #3
Posted 26 November 2012 - 02:19 PM
I'm not very good with Lua, for now I'm just gonna focus on perfecting my password lock. I wanna make multiple accounts with a register account feature.