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

BobAI

Started by ComputerCraftFan11, 04 March 2012 - 06:06 AM
ComputerCraftFan11 #1
Posted 04 March 2012 - 07:06 AM
(Requires ModLoaderCC)

This mod adds a AI named bob. You can talk to him by saying his name, bob.
Code:

function ai()
local getName = "Bob's AI" --insert mods name into the quotes
getMod1 = "mod_" ..getName -- change 1 to your mods ID, it has to be from 1-5 (no 0 or past 5)
function commands()
  write("> ")
  getSentence = read()
  if getSentence == "Hi" then
   print("Bob: Hi")
   commands()
  end
  if getSentence == "How old are you?" then
   print("Bob: I don't know...")
   commands()
  end
  if getSentence == "Are you real?" then
   print("Bob: No")
   commands()
  end
  if getSentence == "What are you?" then
   print("Bob: Artificial Intelligence, or AI for short.")
   commands()
  end
  if getSentence == "Goodbye" then
   print("Bob: Bye.")
  end
  if getSentence == "Your stupid" then
   print("Bob: Your stupid.")
   commands()
  end
  if getSentence == "I'm deleting you" then
   print("Bob: Too late, I already did.")
   sleep(2)
   os.shutdown()
  end
end

if getSentence == "Bob" then
  print("Bob: Hello")
  commands()
end
modcount = modcount +1 -- this line is needed so modloader for computercraft can count your mods
end
ai()
Add more commands like this:

  if getSentence == "What you need to say" then
   print("Bob: What Bob says")
   commands() --loops back
  end
Uncreative_Name #2
Posted 04 March 2012 - 10:20 AM
This is not Artificial Intelligence, this is eight sentences that should you enter precisely will give read back to you a predetermined sentence.