|
| 21 Oct 2015 03:29 PM |
| Whenever I change variables in a module, and require it with another script, that script will see and use the changes and not its original source. Is there a way to avoid this? |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2015 03:32 PM |
| Or is this that case where I should use linkedsource XD |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 21 Oct 2015 03:37 PM |
That's the point of module scripts. If you want to return the exact code that was written do something like this:
--ModuleScript local module = {}
local actual_module = {}
function module:Get() return actual_module end
--LocalScript local module = require(MODULE_PATH):Get()
|
|
|
| Report Abuse |
|
|
|
| 21 Oct 2015 03:37 PM |
| Store all your private variables for the module in a table, and your public ones in a separate table. Then simply use each accordingly. |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2015 03:41 PM |
Sorry but I have no clue ;l
What I want to do is have the whole system (with events and variables) stored in a module and have a normal script require the module. But when I first use it on one thing, then on a different thing it uses the settings from the latest use |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 21 Oct 2015 03:43 PM |
| So if you want every script to have it's own table read my other post. |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2015 03:52 PM |
| But the variables aren't in a table, actually everything in the real table in the module is a function that creates all event connections to the system user, the functions those connections fire are in the modulescript but not in a table. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 21 Oct 2015 03:53 PM |
UFAIL2: you forgot to make the module return something :3
Red Blossoms |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Oct 2015 04:16 PM |
ufail2 failed at his module script :(
i make u math.sqrt() |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 21 Oct 2015 05:30 PM |
UFAIL, your way doesn't seem to work ;l
I currently have a module for the private variables, require that and require with that table the system's module, but still whenever I adjust the table a new system user will see these adjustments as well.. |
|
|
| Report Abuse |
|
|
HRnSN
|
  |
| Joined: 22 Jun 2009 |
| Total Posts: 1276 |
|
|
| 21 Oct 2015 05:40 PM |
| Show us the code within the module script? |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2015 05:42 PM |
local module = {}
local ActualModule = { -- Table with vars }
function module:Get() return ActualModule end
return module |
|
|
| Report Abuse |
|
|
HRnSN
|
  |
| Joined: 22 Jun 2009 |
| Total Posts: 1276 |
|
|
| 21 Oct 2015 05:45 PM |
local Module = {}
function Module:Get()
local ActualModule = {
--Values or whatever
}
return ActualModule
end
return Module |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2015 06:00 PM |
Oooh, that's just it!
Thank you so much I feel stupid now, you saved my day ;3 |
|
|
| Report Abuse |
|
|
HRnSN
|
  |
| Joined: 22 Jun 2009 |
| Total Posts: 1276 |
|
| |
|