Basically what asked in the title. Is it possible to define a variable name in Lua without defining a value just yet?
For example, would
local tick
work as a way to define, in a function, a local variable named "tick" as a "nil" value automatically?
Sorry for the dumb question
Yep, looks like you have the right idea. To test it you can do something like this:
x = 5 function f() print(x) -- uses global x local x print(x) -- uses local x end print(x) -- uses global x |
Notice how when the function first calls for x, it uses the global var when a locally defined var isn't found. Just something to keep in mind while you're coding :)
[Please log in to post a comment]