LUA question about visibility
Posted: Sat May 18, 2019 8:46 am
Hello,
Well, I didn't see a presentation forum, so "Hello" to everybody.
I am new to Lua, so I have been reading the manual reference but I don't get some concepts. I come from C++ and SFML, with the feeling by now it is a more rigid language (although I have never dominated it). Seeing how Love2D is like, I think it will be better for my goals.
Don't hesitate to show me another Lua books, reference guides or forums if the question doesn't fit here, and fit better there. Ah! Also I am not native english speaker, so I am sorry about my english.
So, my question... I am building an application to write chemistry equations by clicking on a periodic table. The question is about visibility. I have the next code:
There, in periodic_table I have the next code:
And the question is that in main I can do the next:
Why I can change "element.WIDTH", if it was a local object of "periodic table" inside the "load" function? I think I could not access to element because it is not in the scope, but I can do it and it has effect on the "element" object. "WIDTH" is an existent key of "element".
Really I am not interested in change "element" but I want to learn what is happening. In C++ I worked with several books wich defined the language in great detail, but I have other feelings with Lua.
Well, I didn't see a presentation forum, so "Hello" to everybody.
I am new to Lua, so I have been reading the manual reference but I don't get some concepts. I come from C++ and SFML, with the feeling by now it is a more rigid language (although I have never dominated it). Seeing how Love2D is like, I think it will be better for my goals.
Don't hesitate to show me another Lua books, reference guides or forums if the question doesn't fit here, and fit better there. Ah! Also I am not native english speaker, so I am sorry about my english.
So, my question... I am building an application to write chemistry equations by clicking on a periodic table. The question is about visibility. I have the next code:
Code: Select all
local periodic_table
function love.load()
periodic_table = require 'periodic_table'
love.window.setMode(1500, 900)
periodic_table:load()
end
Code: Select all
periodic_table = {}
function periodic_table:load()
local element = require("element")
-- lots of code more
end
Code: Select all
function love.draw()
periodic_table:draw()
element.WIDTH = 5
end
Really I am not interested in change "element" but I want to learn what is happening. In C++ I worked with several books wich defined the language in great detail, but I have other feelings with Lua.