Jump to content




How can I detect user text input?

help game

3 replies to this topic

#1 Azhf

  • Members
  • 180 posts
  • LocationMurrika

Posted 20 April 2013 - 06:09 PM

So I am working on YouFindYourselfInARoom(a game on newgrounds) in CC, and I need to know how to detect certain text inputs written by the user such as "Look". Is this possible? If not, then I can believe I won't be able to make YFYIAR on CC :(

#2 BigSHinyToys

  • Members
  • 1,001 posts

Posted 20 April 2013 - 06:13 PM

local test = "bla"
local input = read()
if test == input then
print("same")
else
print("diffrent")
end

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 20 April 2013 - 06:18 PM

string.find will solve your problems.

local input = string.lower(read())
if input:find('look') then
  -- the input they have typed contains look
end


#4 Azhf

  • Members
  • 180 posts
  • LocationMurrika

Posted 20 April 2013 - 08:08 PM

Thanks guys. :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users