Whats the difference: including libraries

What would be the difference between these lines of code:

require(“lib_particle_candy”)

local Particles = require(“lib_particle_candy”)

Don’t they mean the same thing?

Thanks!

Tom [import]uid: 55068 topic_id: 11030 reply_id: 311030[/import]

The short answer is both require’s mean the same thing, but the effect of the require depends on the target of the require.

require will load(if needed) and execute a Lua file and will remember what the result of that Lua file was (what did it return), and provide that on subsequent calls to require.

Now, a Lua file can do whatever it wants. If it can return a value, set a global, both, or neither.

In the most compatible case where a library sets a global named identically to the library and also returns it as a value then the 2 statements above are equivalent. [import]uid: 846 topic_id: 11030 reply_id: 40145[/import]