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

AIHelp Deak program help

Started by Deimos, 26 November 2012 - 10:40 PM
Deimos #1
Posted 26 November 2012 - 11:40 PM
Hey Guys,
I have this little code here and I was wonder if I may get a litle help with it. Basicly Im trying to set up a little automated information desk with some of our most common questsions.

*All the print ( ) is because that is the only way I know how to make a new line/space :P/>/>
Spoilerlocal input

print ("Hi! How can I help you today?")
print ("please type what you need help with exactly as it is below")
print ( )
print ("I have been Griefed")
print ("How do I earn money?")
print ("How do I protect my house?")
print ("How do I make a town?")

input = read()

if input == "I have been Griefed" then
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ("OH NO!! that is no good at all, lets see if we can fix that for you. Please stand by the missing items/blocks looking directly where they were and submit a ticket /ticket new I have been griefed and I am missing {item/blocks you are missing}")
elseif input == "How do I earn money?" then
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ("You earn money from having a job. We have many jobs avable simple type /jobs browse to view them. When you have found a job for you type /job join {job name}")
elseif input == "How do I protect my house?" then
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ("You can protect your house by joining a town or making a town. To join a town you must be invited by the mayor or assistant. To make a town please type How do I make a town")
elseif input == "How do I make a town?" then
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ("towns are a great way to protect your items and your house. They are also great for your friends too. To make a town you must be 20 chunks away, to see if you are 20 chunks away have a look at the live server map on the website. When you are 20 chunks away type /t new {town Name}")
elseif input == "I have been Griefed" then
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ("OH NO!! that is no good at all, lets see if we can fix that for you. Please stand by the missing items/blocks looking directly where they were and submit a ticket /ticket new I have been griefed and I am missing {item/blocks you are missing}")
elseif input == "How do I earn money?" then
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ("You earn money from having a job. We have many jobs avable simple type /jobs browse to view them. When you have found a job for you type /job join {job name}")
elseif input == "how do I protect my house?" then
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ("You can protect your house by joining a town or making a town. To join a town you must be invited by the mayor or assistant. To make a town please type How do I make a town")
elseif input == "how do I make a town?" then
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ( )
print ("towns are a great way to protect your items and your house. They are also great for your friends too. To make a town you must be 20 chunks away, to see if you are 20 chunks away have a look at the live server map on the website. When you are 20 chunks away type /t new {town Name}")


end
print ( )
print ( )
print ("Is there anything else I can help you with?")
print ("Yes/No")

input = read()

if input == "Yes" then
print ( )
print ("Want can I help you with?")
elseif input == "No" then
print ( )
print ("Thank you for visting the Kiosk")
end

print ("Goodbye!")

Im having a little trouble with printcenter. There are a few things namely

print ("Hi! How can I help you today?")
print ("please type what you need help with exactly as it is below")

If I do


printcenter ("Hi! How can I help you today?")
printcenter ("please type what you need help with exactly as it is below")

I get a error "attempt to call nil" on the computer

I am also wondering if there is away to have it loop back when it gets back to


if input == "Yes" then
   print ( )
   print ("Want can I help you with?")
elseif input == "No" then
   print ( )
   print ("Thank you for visting the Kiosk")

I would like it to loop back to

print ("I have been Griefed")
print ("How do I earn money?")
print ("How do I protect my house?")
print ("How do I make a town?")
If they answer yes, and I would like it to close the GUI if they answer no. Is there anyway to do this?

Thanks in advance for you help guys, I am a great noob when it comes to LUA XD
KaoS #2
Posted 27 November 2012 - 01:39 AM
hey man, I'm feeling friendly (and bored :D/> ) so I think I want to take a look and see if I can improve this. be right back with a prototype
KaoS #3
Posted 27 November 2012 - 02:14 AM
Ok, done. I used one of my menu functions here in the code, don't worry you don't have to download it because it is included in the code, if you want to use it in future feel free…. anyways here is your code that is tested and works fine. a few minor grammar issues in your responses were also ironed out. enjoy :)/>
Deimos #4
Posted 27 November 2012 - 10:29 AM
wow thanks so much dude.

If I wanted to add more options would I just change the 4 to 5 and add in the response?

local resp=newmenu({"I have been Griefed","How do I earn money?","How do I protect my house?","How do I make a town?"},1,4)

Also is there away that I can make the computer only run this and nothing else? These are at my spawn so I dont want people stopping the program at all
KaoS #5
Posted 27 November 2012 - 10:33 AM
no problem. here to help. sounds like you have a pretty cool server going. enjoy