• Do not use Works in Progress as a way of avoiding the releases system! Works in Progress can be used for sharing early betas and for getting suggestions for improvement. Releases of finished content are not allowed in this forum! If you would like to submit a finished addon, click here for instructions on how to do so.

Are variables automatically initialized?

Status
Not open for further replies.

amperbee

thunderdome denizen
I mean, I can just do this:
Code:
internet = 123
Or I have to do this:
Code:
if internet == nil then
internet = 123
end

(By the way everytime I do
Code:
randomvariablename = 0
Lua halts the entire code because it prevents something about global variables and wants me to use local variables instead, but I need that variable for the entire code, what do I do now? I have the code here just in case)
 
Last edited:
(except the variable can only be used within the script it was initialized in, mind)

If I do "local whatever = 0" at the START of the entire lua file, it can be used everywhere in that file, right?

---------- Post added at 07:16 PM ---------- Previous post was at 06:43 PM ----------

I still don't know, all I want to do is initialize a variable that can be used for the entire file, not just for a block of code, but the entire file.
 
If you declare a variable outside a function in LUA_XXXX, (in other words, just plaster "local Ilikeplayingpyro = 3" at the top), everything inside LUA_XXXX can read it freely. That's all there is to it.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top