Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im watching a youtube video to learn Lua, what I dont understand is why he used tinput instead of input in the following code:

print("Welcome to the game")
input = ""

inv = {"coin", "sword", "armor"}

while imput ~= "exit" do
  print("What do you want to do?")
  input = io.read()
  
  if input == "inspect" then
    print("Youre in a cave. There is an exit.")
  elseif input == "exit" then
    print("You left the cave.")
  elseif input == "inv" then
    for i,v in pairs(inv) do
      print(i,v)
    end
  else
    print("You didnt write a valid command...")
  end
end

input = ""
while input ~= "follow path" do
  print("What do you want to do?")
  input = io.read()
  
  if input == "inspect" then
    print("There is a cave behind you. Youre on a cliff. There is a pathway ahead.")
  elseif input == "follow path" then
    print("You follow the path")
    print("A troll appears wielding an axe")
    print("What do you want to do? (run away, attack)")
    tinput = io.read
    if tinput == "attack" then
      print("You smack with your sword and it falls dead")
    elseif tinput == "run away" then
      etc etc etc..
Whats the diference?
Posted
Updated 1-Mar-15 3:34am
v2

Is is just another variable (that collects further input from the user via io.read).
Please note, the following line
Quote:
while imput ~= "exit" do
doesn't look correct ( I suppose the variable name should be input. Is it a typo?).
 
Share this answer
 
Still a little bit confused but thanks, I tought it was something else.
And yes, its input not imput, my fault!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900