Jump to content

local


qaisjp

Recommended Posts

What is the real difference between the following two things.

This:

  
helloText = "Hello World" 
  

and

  
local helloText = "Hello World" 
  

Yes I am talking about "local" - What is it exactly? How does it change when you type/dont type it? Please help :P

Link to comment

For example you can create global variables in 1 lua file and use it within the resource folder, while local variables are more faster then global ones and are most common used.

You can read more: http://lua-users.org/wiki/ScopeTutorial

Also if I'm not wrong you can use local variables within the whole script or inside the function.Ones inside function are used only in that function while the ones that aren't in function can be used within the whole code.

Link to comment

Aha, so is this also why I see

  
local function jaja() 
end 
  

sometimes?

So this function is only accessible and visible to the file :D?

So I can keep one function called changeText in multiple files (different) and they will only run the one in the file :D?

THANKS :D

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...