|
| 13 May 2015 12:58 AM |
I'd like to open up a discussion to thouroughly give your ideas and thoughts on Module Scripts.
Some ideas to write about: What have you done with them, how do you use them in your games/testing, module script security, connection between client and server. |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 01:23 AM |
I guess I'll start...
I use Modules to grant me secure acess with HttpService by nuking the environment and keeping my code hidden from clients.
I've also used Modules like regular scripts, you call on them and they respond quite well. |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 01:41 AM |
| I personally have no real idea what they do or what they're for. I shall be monitoring this thread in hopes to learn. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 13 May 2015 01:44 AM |
Normally just use modules as a replacement to the Global Table.
Le ~ _G |
|
|
| Report Abuse |
|
|
udayk8139
|
  |
| Joined: 25 Aug 2013 |
| Total Posts: 622 |
|
| |
|
|
| 13 May 2015 02:01 AM |
| I use them for a Special Round System in my game. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 13 May 2015 02:26 AM |
| I use ModuleScripts for Valkyrie |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 11:29 AM |
Alright
The goal of this thread is to expand module understanding and debate what is possible inside a module |
|
|
| Report Abuse |
|
|
FlyScript
|
  |
| Joined: 05 Aug 2010 |
| Total Posts: 2884 |
|
|
| 13 May 2015 11:56 AM |
I made a couple of cool APIs:
Explosion API: http://www.roblox.com/Custom-Explosion-API-item?id=233652523
Asset/PreLoading API: http://www.roblox.com/Asset-Pre-Loading-API-item?id=242932455 |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 12:29 PM |
I tend to create little frameworks for projects with ModuleScripts. I've also done a few wrappers, this being the only actual released one: http://www.roblox.com/--item?id=240640028
I use them with everything now though.. It just feels nicer to have a separate script storing all the important things, while there's another one dependant on it. |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 13 May 2015 12:32 PM |
| Only a ModuleScript may contain Paragon. |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 12:52 PM |
I don't.
"I like to program" - Bosswalrus |
|
|
| Report Abuse |
|
|
LucasLua
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 7386 |
|
|
| 13 May 2015 12:57 PM |
| Earlier today I tested a few things with ModuleScripts. I found out that the ModuleScript keeps its own environment rather than taking on the environment of the script that required it. I also found out that (rather obviously) a ModuleScript will run from the same side as the requiring script. So if you required a ModuleScript that is sitting in Workspace from a LocalScript in a Backpack somewhere, the ModuleScript will have access to the mouse and LocalPlayer. |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 01:00 PM |
I'm using a ModuleScript for my Framework I'm developing as well.
I really like ModuleScripts as they can just clean up your code, make you code easier and tons more. |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 01:01 PM |
"ModuleScript keeps its own environment rather than taking on the environment of the script that required it" Yeah, that's why I often return functions in my modules. Then I can do getfenv(2) and get the location of the script that requires it. |
|
|
| Report Abuse |
|
|
FlyScript
|
  |
| Joined: 05 Aug 2010 |
| Total Posts: 2884 |
|
|
| 13 May 2015 04:33 PM |
If you send it things in its arguments such as a player's mouse, etc, it can handle them. it just takes a localscript to grab 'em.
e.g:
--ModuleScript code:
keyHandler = {}
keyHandler.HandleNewPlayer = function(player, mouse) print(player.Name.." being handled") mouse.KeyDown:connect(function(k) k=string.lower(k) if k == "a" then --etc end end) player.leaderstats.Points.Changed:connect(function() player.PlayerGui.Ding:Play() end) end
return keyHandler
--Local script: wait(1) plr = game.Players.LocalPlayer m = plr:GetMouse handler = require(game.ServerScriptStorage.HandlerModuleScript)
handler.HandleNewPlayer(plr, m) |
|
|
| Report Abuse |
|
|
FlyScript
|
  |
| Joined: 05 Aug 2010 |
| Total Posts: 2884 |
|
| |
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 13 May 2015 04:42 PM |
-- module --
local mouse = game.Players.LocalPlayer:GetMouse()
local thing = function() mouse.KeyDown:connect(function(key) print("Using the mouse for input is depreciated, instead use UserInputService") end) end
return thing
-- --
-- local script --
require(module)()
-- --
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
FlyScript
|
  |
| Joined: 05 Aug 2010 |
| Total Posts: 2884 |
|
|
| 13 May 2015 04:48 PM |
| UserInputService gives me the creeps. That and the new playerscripts make me feel icky. |
|
|
| Report Abuse |
|
|