generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: What is the purpose of module scripts?

Previous Thread :: Next Thread 
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Aug 2016 10:40 PM

I have never really used them so I don't know.

Would enjoy learning what they are used for, thank you.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
30 Aug 2016 10:42 PM
being modular

and modularity is good!1!111


Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
30 Aug 2016 10:48 PM
Librarysssseies
Report Abuse
NewbControl114 is not online. NewbControl114
Joined: 09 May 2009
Total Posts: 10303
30 Aug 2016 10:56 PM
From what I understand, You can write a function from a modular script and use it in any script when you call the modularscript
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
30 Aug 2016 11:44 PM
module scripts are handy ways of storing functions,tables,metatables

it can store a lot of things

and if you make all of your variables global

and return the

getfenv()

you can use this to set the environment of your script to match the one in the Module Script, allowing you to use all the functions, tables, or data you stored inside of it

for k,v in pairs(require(moduleScript)) do
getfenv()[k] = v
end
Report Abuse
Crimsonal is not online. Crimsonal
Joined: 23 Apr 2011
Total Posts: 1795
31 Aug 2016 12:50 AM
Prevent you from having to rewrite functions, variables, in multiple scripts I'm assuming.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 12:51 AM
what daily said would be an awful idea.
Return a table and do that if you really want to.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 12:59 AM
no mine is not a bad idea because if you return getfenv() and then set the fenv, all of your module script's functions and variables will be automatically declared into your script
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 01:00 AM
And so will the "script" variable and now you've ruined everything.
You can just as easily put the functions in a table and return the table, then put all things in the table in the environment.

You're not good at this.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
31 Aug 2016 01:02 AM
dailyblarg is not smart111
:D


Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:03 AM
you can put them all in the environment with messy code such as this
local bla,bla,bla,bla,bla = ms.bla,ms.bla,ms.bla,ms.bla

and it is much easier to just get and set everything in one go
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 01:04 AM
Wrong, you wouldn't be putting it in the environment if you did that.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:06 AM
you can still simply just do

if k ~= "script" then

end

and there you go now all of it is replaced
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 01:09 AM
Or, you can just put them in a table like a normal person would.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:11 AM
that is a waste of code though

what if you store about 50 functions of frameworks inside that module script

it would make more sense to make an autoupdating and self-inserting code to add those functions onto there instead of having to manually declare all of the 50 functions in every script
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 01:12 AM
"that is a waste of code though"
You're really, really stupid. 'waste of code' lmfao

"what if you store about 50 functions of frameworks inside that module script"
Yet again, you're stupid. '50 functions of frameworks' you're so ignorant when it comes to programming it hurts.

"it would make more sense to make an autoupdating and self-inserting code to add those functions onto there instead of having to manually declare all of the 50 functions in every script"
How is that relevant to anything I said stupid?
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:16 AM
because you said that we should waste our time filling tables with loads of things to return rather than getting everything we need to return and loading it again
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 01:17 AM
Yet again you don't understand anything. Here I'll spell it out for your dumb self:

local module = {}
function module.Func1()
..
end
function module.Func2()
..
end
return module
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:18 AM
you can still use the getfenv() method to recieve all of the returned values though which is what i was enforcing
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 01:20 AM
-.- nope how the hell does "getfenv" give you any return values...
why are you so clueless and speak as if you know what you're talking abuot
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:21 AM
because, idiot

for k,v in pairs(require(module)) do
getfenv()[k] = getfenv()[k] or v
end

this will just store any of the items in your module script in this script
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 01:23 AM
You're not getting the return values doing that, require gives you the return value.
How dumb can you be? You're almost as bad as remasteredblox
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:24 AM
"You're not getting the return values doing that, require gives you the return value"
i used require to get the returned values tho..

????
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Aug 2016 01:26 AM
Exactly moron.
This is what you said though
"you can still use the getfenv() method to recieve all of the returned values"
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
31 Aug 2016 01:26 AM
return{
Func1=function(self,args)
print(args)
end,
}

#1 way fam


"me caveman rawr" - Me
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image