lagio2
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 4001 |
|
|
| 17 Jun 2017 09:26 AM |
so like
local mods = game.ServerStorage.WaveMods:GetChildren()
for i = 1, #mods do require(mods[i]) end
then could i just call said modules by doing mods[i]() |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2017 09:27 AM |
That's fine if modules only run code and don't return a relevant value.
If they do, you'll need to a variable to store the value that the modules returned |
|
|
| Report Abuse |
|
|
lagio2
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 4001 |
|
| |
|
|
| 17 Jun 2017 09:30 AM |
Although they need to return something, but the engine is really forgiving so it won't stop the script from working.
|
|
|
| Report Abuse |
|
|
|
| 17 Jun 2017 09:31 AM |
| They do, but you don't need to store the value of what they returned in your main script if it's just nil or some empty table. That's what I was trying to say. |
|
|
| Report Abuse |
|
|
lagio2
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 4001 |
|
|
| 17 Jun 2017 09:40 AM |
aight guys i just tested it and it does call an error
in the module i just left module as nil
so it says No method name passed in __namecall for Object so looks like i do have to do it manually |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2017 09:44 AM |
in the module you need to RETURN a value, so like "return nil" at the end of the script
requiring modules in a loop does work, I just tried it |
|
|
| Report Abuse |
|
|
lagio2
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 4001 |
|
| |
|
|
| 17 Jun 2017 09:50 AM |
in an arbitrary number of modules:
print("Hello World!") return nil
in the script requiring them:
local modules = LOCATION:GetChildren()
for _, m in pairs (modules) do require(m) end |
|
|
| Report Abuse |
|
|
lagio2
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 4001 |
|
|
| 17 Jun 2017 09:56 AM |
ohhhh i see what to do now
thanks lol im really new to modules |
|
|
| Report Abuse |
|
|