|
| 10 Mar 2014 07:00 PM |
So I'm planning to have hundreds of blocks all with scripts that reference one module script, but in blog it says
"ModuleScripts will run at most one time — if two scripts require() the same ModuleScript Instance, that script will run once, and produce the same exact return value to both require()ers"
So does that mean that if I have 100 scripts all calling the same module script function at the same time, but with different variables, it will return 100 of the same numbers instead of them each being unique? |
|
|
| Report Abuse |
|
|
|
| 10 Mar 2014 07:42 PM |
On a related note
19:41:08.447 - Requested module experienced an error while loading 19:41:08.448 - Script 'Workspace.Dirt.Script', Line 2 19:41:08.448 - stack end
local Dirt = script.Parent local GrowingModule = require(Workspace.GrowingModule)
Game.Workspace.GrowTick.Changed:connect(function() print(GrowingModule.Grow(Dirt.Water,Dirt.Nutrients)) end) |
|
|
| Report Abuse |
|
|
|
| 10 Mar 2014 08:53 PM |
20:52:16.893 - Module code did not return exactly one value
??? |
|
|
| Report Abuse |
|
|
DataStore
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 8540 |
|
|
| 10 Mar 2014 09:26 PM |
@Cith, What's the ModuleScript returning?
|
|
|
| Report Abuse |
|
|
|
| 10 Mar 2014 09:29 PM |
I fixed a bit of the issue by adding
return module
at the end, this is how I have it: --
local Plant = {}
function Plant.Grow(Wlvl,Nlvl) local GrowChance = math.random(1,20/Wlvl) local GrowModify = GrowChance - Nlvl if GrowModify < 2 then return true end end
return module
-- And I'm accessing it through this: --
local Dirt = script.Parent local GrowingModule = require(Workspace.GrowingModule)
Game.Workspace.GrowTick.Changed:connect(function() print(GrowingModule.Grow(Dirt.Water,Dirt.Nutrients)) end)
-- And now I'm Getting 21:28:12.001 - Workspace.Dirt.Script:5: attempt to index upvalue 'GrowingModule' (a nil value) 21:28:12.001 - Script 'Workspace.Dirt.Script', Line 5 21:28:12.002 - stack end |
|
|
| Report Abuse |
|
|
DataStore
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 8540 |
|
|
| 10 Mar 2014 09:36 PM |
'module' is nil.
return Plant
|
|
|
| Report Abuse |
|
|
|
| 10 Mar 2014 09:47 PM |
| Oi it works great now! Thanks a ton |
|
|
| Report Abuse |
|
|