local var1 = "potato" print("var1")
I know that makes no sense because I am printing a string but what if I wanted to print the variable called var1? Is that possible and if so how would I do it?
If you are trying to print what the variable is assigned to it's
print(var1)
But if you want the name of the variable you could put it in a table like this...
local variables = {var1 = "potato"}
And get the name of it like this...
for i,v in pairs(variables) do print(i) -- prints var1 end
You can print variables like this:
local var1 = "potato" print(var1)
potato
You could also combine strings.
local var1 = "potato" local var2 = var1 .. "E" print(var2 .. " or " .. var1 .. "?")
potatoE or potato?
it is possible, you were almost there. Print(argument) can also be used to print variables and the outcome of functions. this can be done in the way you would normally call the variable ie. without the quotation marks:
local var1 = "potato" print(potato)
likewise you could do the following stuff:
local a=10 local b=5 print(a-b) -- this would be the same as print(10-5) -- or print("5") -- note, the quotation marks are not neccesary here, since it is a number
quotation marks are actually used so that the software "knows": 'ohh, this is not a variable or a function that the user tries to call, but just some random text'
hope this helps!