|
Is it simply something like
require(helloworld)
or
include(helloworld)
I got these from my php work, can you guys please tell me how this new update works? |
|
digpoeJoin Date: 2008-11-02 Post Count: 9092 |
To require a ModuleScript:
local data = require(workspace.ModuleScript) --where workspace.ModuleScript is your ModuleScript
How ModuleScripts work in a nutshell:
return (some value) --Best usage I've seen for ModuleScritps is APIs, so an example would be: return {foo=function() print("foo") end; bar=function() print("bar") end;}
ModuleScripts run once on the client and once on the Server. (That is, it's run once and every call to Require() in different Scripts of the same type return the same value) |
|
|
Thanks, I really appreciate it. |
|
MettaurSpJoin Date: 2010-03-20 Post Count: 3179 |
So basically they are like one possibly giant function you call with require? That will help a lot with a language I am working on. |
|
|
|
|
|
Is there a way to have a multi-lined function in a table without using semicolons? |
|
|
jode6543Join Date: 2009-06-16 Post Count: 5363 |
Interesting discovery: the require function seems to be cached somehow. I require'd a module (via command line), then edited it to return something else, but it still gives me the original value back from the call.
~Jode |
|
|
"require'd"
The English language just died. |
|
|
@jode From what I've gathered ModuleScripts are only executed once and then just return the same value anytime require is used.
~The alpaca of the acting world. |
|
MettaurSpJoin Date: 2010-03-20 Post Count: 3179 |
When I update their source in studio and use require on them before and after doing so, they can return different values. Not much use for that info with the Source property being locked. |
|
|
I think this is incorrect grammar: "I require'd a module"
It should be, "I made a script require a module." |
|
eLunateJoin Date: 2014-07-29 Post Count: 13268 |
I required a module would work fine.
|
|
|
eLunateJoin Date: 2014-07-29 Post Count: 13268 |
Yeah :/ |
|
|
2_GBJoin Date: 2012-09-29 Post Count: 1166 |
Necro bump because I can't seem to understand modules at all.... |
|
|