|
| 06 Apr 2015 04:48 PM |
I open it up and it says
local module = {}
return module
someone told me I can use module scripts to retrieve data from scripts. How do I use it? |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:53 PM |
You use scripts and retrieve data from module scripts.
http://wiki.roblox.com/index.php?title=Module_scripts
Module scripts are tables that can hold variables and functions. It can be useful for making a Settings script and for making a function available across multiple scripts. ex. local module = { a = "hi" }
return module
To use a module script in a script (or localscript), you have to use the require() function. From there, you can use the data inside the modulescript. ex.
local myModule = require(game.Workspace.ModuleScript) --assuming that there's a modulescript in workspace
print(myModule.a) ---> output: hi |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 04:58 PM |
| Ahh, thank you. Very useful. |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 05:06 PM |
you don't have to type in the table
local module = {}
module.Print() = function(text) print(text) end
return module
local module = require(module)
module.Print("Hello!") |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
| |
|