Smeers
|
  |
| Joined: 14 Feb 2013 |
| Total Posts: 797 |
|
|
| 20 Jul 2016 10:49 AM |
Since I'm fairly new to modulescripts, I wanted to know how to run functions (and possibly events?) that are in the script the module was called from.
Would I return the functions in a table, like this?
--script local tableofFunctions = { Function1 = function(arg1,arg2) print('hi',arg1,arg2) end -- Functions here } local module = require(script.Parent.Module) module.FunctionName(tableofFunctions)
-- module return { FunctionName = function(tableofFunctions) tableofFunctions.Function1(arg1,arg2) end }
--------
Or would I do something else?
any help is appreciated. |
|
|
| Report Abuse |
|
|
Smeers
|
  |
| Joined: 14 Feb 2013 |
| Total Posts: 797 |
|
| |
|
|
| 20 Jul 2016 11:05 AM |
| I'd suggest giving it the environment of the calling script, but since multiple scripts could call it, things would become both confusing and buggy. |
|
|
| Report Abuse |
|
|
Smeers
|
  |
| Joined: 14 Feb 2013 |
| Total Posts: 797 |
|
|
| 20 Jul 2016 11:07 AM |
I'm basically looking for a similar effect to Epix's plugin format.
Let me try that again:
--script local tableofFunctions = { Function1 = function(arg1,arg2) print('hi',arg1,arg2) end -- Functions here } local module = require(script.Parent.Module) module(tableofFunctions)
-- module return function(tableofFunctions) tableofFunctions.Function1(arg1,arg2) end
---------------
or similar. |
|
|
| Report Abuse |
|
|
Smeers
|
  |
| Joined: 14 Feb 2013 |
| Total Posts: 797 |
|
|
| 20 Jul 2016 11:08 AM |
| In short, I want the module to have access to functions and events that the script that it is called from would run. |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 11:17 AM |
| How many different scripts will be requiring it? |
|
|
| Report Abuse |
|
|
Smeers
|
  |
| Joined: 14 Feb 2013 |
| Total Posts: 797 |
|
| |
|
|
| 20 Jul 2016 11:47 AM |
| That's not what a modulescript is for |
|
|
| Report Abuse |
|
|
Smeers
|
  |
| Joined: 14 Feb 2013 |
| Total Posts: 797 |
|
|
| 20 Jul 2016 11:54 AM |
| Both, I've seen it done before, so I can preform the task that is obviously possible. |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 12:16 PM |
http://wiki.roblox.com/index.php?title=Absolute_beginner%27s_guide_to_scripting Come back in 5 years |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 06:08 PM |
| Will you be requiring this at the top of your script, if so this is REALLY easy. |
|
|
| Report Abuse |
|
|