|
| 10 Dec 2013 02:31 PM |
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? |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 10 Dec 2013 02:42 PM |
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) |
|
|
| Report Abuse |
|
|
|
| 10 Dec 2013 02:45 PM |
| Thanks, I really appreciate it. |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 10 Dec 2013 05:18 PM |
| 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. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 11 Dec 2013 05:29 PM |
| Is there a way to have a multi-lined function in a table without using semicolons? |
|
|
| Report Abuse |
|
|
| |
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 11 Dec 2013 07:05 PM |
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 |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2013 09:36 PM |
"require'd"
The English language just died. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2013 09:57 PM |
@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. |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 11 Dec 2013 11:38 PM |
| 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. |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2014 06:29 PM |
I think this is incorrect grammar: "I require'd a module"
It should be, "I made a script require a module." |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 21 Nov 2014 07:03 PM |
I required a module would work fine.
|
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
5ZR
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2218 |
|
| |
|
|
| 08 Dec 2015 04:44 PM |
| Necro bump because I can't seem to understand modules at all.... |
|
|
| Report Abuse |
|
|
| |
|