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: A possible `LibraryScript` object?

Previous Thread :: Next Thread 
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
28 Oct 2011 02:39 PM
This object would run after all CoreScripts/StarterScripts but before all LocalScripts and Scripts. It will be run on both the client- and server-side but would have a method that returns which side the object is run on (to make sure it doesn't use rather unusable things). Like Scripts and LocalScripts, its Source property would be a ProtectedString, and its LinkedSource will be read-only.

At the time of this post, this is a **non-approved suggestion**.

---

~blocco

---

So, what do you think?
Report Abuse
NilPirate is not online. NilPirate
Joined: 31 Jul 2010
Total Posts: 3077
28 Oct 2011 02:52 PM
Do want
Report Abuse
aboy5643a is not online. aboy5643a
Joined: 20 Nov 2010
Total Posts: 2785
28 Oct 2011 03:00 PM
@blocco

I liek. And while they're at messing with client/server crossing:

Local Workspace (like legit, non-glitchy LOCAL like the gui)
Server-Sided GUI (I NEED THIS NAO SO I DON'T HAVE TO USE MEMORY INTENSIVE REPLICATION)
Local Lighting

Discuss.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
28 Oct 2011 03:05 PM
http://wiki.roblox.com/index.php/User:NXTBoy/Lua_Issues#.28Lack_of.29_Modularity

---

Might be easiest to add a `ScriptLibraries` service, to contain all the `LibraryScript`s. After all, the libraries should all be in on place. From that, you just add to the Lua API:

`Script::require(libraryName)` - wait for a `LibraryScript`, `ScriptLibraries[libraryName]` to execute. Additionally, if the LibraryScript contains a script-level `return`, then `Script::require()` will return the object returned in the libraryscript. Could potentially take multiple parameters, and return multiple libraries.

`LibraryScript` would inherit from `Script`, allowing `LibraryScript`s to require other library scripts
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
28 Oct 2011 03:06 PM
Scrap that, I think my wiki implementation is better.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
28 Oct 2011 03:13 PM
I like NXTBoy's implementation suggestion for it. However, one thing must be addressed: What will happen if the LibraryScript takes too long to validate?
Report Abuse
Aaaboy97 is not online. Aaaboy97
Joined: 05 Apr 2009
Total Posts: 6612
28 Oct 2011 03:23 PM
if it takes too long to validate, it'll be like now where roblox rages at you in the output and then breaks your game
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
28 Oct 2011 03:24 PM
^

~+[CROOKITY BANDED SNAKES]+~
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
28 Oct 2011 03:31 PM
Then the things that require it never run. If it takes too long (read:forever) to load the libraries, then the library is written badly.

This is why it is more sensible to wait for libraries to load on a per-script basis, using `require` rather than to expect every library to finish executing before running any other scripts.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
28 Oct 2011 06:44 PM
How I think it should be done:

Registering a library: LibraryService:Register(string libraryName, function library)
Example:
game:GetService('LibraryService'):Register("thisisalibrary", function()
local t = {}
function t.hello()
print("Hello!!!!")
end
return t
end)

Loading a library that was previously registered: LibraryService:Load(libraryName)
Example:
local library = game:GetService('LibraryService'):Load("thisisalibrary")
library.hello() --> Hello!!!!



Libraries are functions and loading them is _EXACTLY_ the same thing as calling the function, except you can't specify arguments.
This allow libraries to register variables by adding fields in getfield(0). This allows them to declare internal variables. This also allows them to return a table that contains values (like math.huge) and functions (like string.gsub).

This would probably be the best way to implement libraries, trust me.

I have myself made some libraries for ROBLOX. I store a function in _G, that, when called initiates the library and returns a table to access the functions it contains.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
28 Oct 2011 06:50 PM
I want an object for it. Not a function. Because I want it run before everything else. :3
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
28 Oct 2011 06:52 PM
" It will be run on both the client- and server-side but would have a method that returns which side the object is run on (to make sure it doesn't use rather unusable things)."

I think that that's a really inelegant way to do it. Readonly property would be the way to do it, since that follows the conventions that Roblox uses.

Overall There's probably a better solution for client / server side. Most libraries would either have everything shared perfectly, or everything completely different between client and server part, and for the later having one giant if statement choosing over a method's return value or a property isn't very elegant.
Report Abuse
GoldenUrg is not online. GoldenUrg
Joined: 23 Aug 2009
Total Posts: 6428
28 Oct 2011 10:40 PM
Interestingly this is almost exactly what I have. And no very elegant.
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