ked2000
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 1059 |
|
|
| 23 Jul 2015 10:42 PM |
I am trying to navigate through my project with my function GetLib(string ...). GetLib() is designed to take a string path from the tuple, find the ModuleScript, and create a copy of it.
After the first iteration, the script seems to stop(not error) when require() is called.
Directory Map:
-ModuleScript "MainModule" --Folder "Lib" ---ModuleScript "Log" ---Folder "UI" ----ModuleScript "UI"
Source:
function GetLib(...) local result = {}; for i, path in next, {...} do
-- ModuleScript Aux gets the module script from string "path"
local module = Aux.GetPath(path, script:WaitForChild("Lib"), '.'); if (path:match("[^%.%s]+$"):lower() == module.Name:lower()) then local imported = require(module); -- Make a copy local copy = {}; -- Format functions if (type(imported) == "table") then for name, data in next, imported do if (type(data) == "function") then copy[name] = function(self, ...) return data(self, C, ...); end else copy[name] = data; end end elseif (type(imported) == "function") then copy = function(...) return imported(C, ...); end end result[#result+1] = copy; end end
return unpack(result); end
Logger, UI = GetLib("Log", 'UI.UI');
Logger is retrieved successfully but on the second iteration where path = "UI.UI", the script waits for require(module) but require(module) never returns ModuleScript "UI".
Why is this happening? |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 10:46 PM |
First can you explain to me what your doing?
Where exactly are you calling it? Unless you indent its really hard to follow. |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 10:47 PM |
| not indent but show me where you are calling it, very confusing which script is which to btw |
|
|
| Report Abuse |
|
|
ked2000
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 1059 |
|
|
| 23 Jul 2015 10:53 PM |
@darkemosoul
I am calling it here:
Logger, UI = GetLib("Log", 'UI.UI'); |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 10:58 PM |
-- Format functions if (type(imported) == "table") then
Check that section, you never
return imported |
|
|
| Report Abuse |
|
|
ked2000
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 1059 |
|
|
| 23 Jul 2015 10:59 PM |
| That is intentional, I return "copy" at the end instead. |
|
|
| Report Abuse |
|
|
ked2000
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 1059 |
|
|
| 23 Jul 2015 11:00 PM |
| I mean, add it to the result table. |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 11:02 PM |
| But then why are you using unpack()? Is the module returning an array of functions? |
|
|
| Report Abuse |
|
|
iiEssence
|
  |
| Joined: 18 Jun 2014 |
| Total Posts: 3467 |
|
|
| 23 Jul 2015 11:03 PM |
Does the module UI return?
I don't need a siggy |
|
|
| Report Abuse |
|
|
ked2000
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 1059 |
|
|
| 23 Jul 2015 11:05 PM |
The function returns every requested module to its respective variable.
Logger, UI = GetLib("Log", 'UI.UI');
The ModuleScript "Log" is now stored in the variable Logger, and the ModuleScript "UI" is now stored in the variable UI.
|
|
|
| Report Abuse |
|
|
ked2000
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 1059 |
|
|
| 23 Jul 2015 11:07 PM |
@iiEssence
UI returns a table. |
|
|
| Report Abuse |
|
|