Skip to content

Commit

Permalink
Loader patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mullets-Gavin committed Dec 19, 2020
1 parent ce5ab31 commit dcddb24
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
3 changes: 1 addition & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<h1>Library Examples</h3>

![examples](https://img.shields.io/badge/examples-1-blueviolet)
![examples](https://img.shields.io/badge/examples-2-blueviolet)
</div>

## About
Expand All @@ -10,7 +10,6 @@ Examples were created to demonstrate each library provided with Loader. Unlike t
Examples included:
- Loader
- DataSync
- Interface

## Examples
### Loader Example
Expand Down
8 changes: 4 additions & 4 deletions examples/datasync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ Some useful things to know:
--]]

--// loader
local Loader = require(game:GetService('ReplicatedStorage'):WaitForChild('Loader'))
local require = require(game:GetService('ReplicatedStorage'):WaitForChild('Loader'))

--// variables
local Cache = {} -- the main DataStore cache table

-- import the modules
local Manager = Loader('Manager')
local DataSync = Loader('DataSync')
local Manager = require('Manager')
local DataSync = require('DataSync')

-- import the services
local Players = Loader['Players']
local Players = game:GetService('Players')

-- create a DataStore
local Store = DataSync.GetStore('PlayerData',{ -- first parameter is the key of the store
Expand Down
39 changes: 30 additions & 9 deletions examples/loader.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
-- initialize Loader
local Loader = require(game:GetService('ReplicatedStorage'):WaitForChild('Loader'))
local require = require(game:GetService('ReplicatedStorage'):WaitForChild('Loader'))

local Cache = {} -- keep track of the modules
local List = {'Manager','Roblox','DataSync','Interface','Network'} -- lets set up a list of modules to require

local function Boot() -- a simple function to load the modules
for index,module in pairs(List) do -- start up a loop
Cache[module] = require(module) -- require the module
end

return Cache
end

-- Built in options, similar to Rusts' "Option" enum, though this compares types
-- Option is created on the global 'shared' by Loader
-- Lua should implement its own Option, would make this so much easier.
shared.Option:Set('result1','string') -- type: string
shared.Option:Set('result2',23876) -- type: number
shared.Option:Set('result3','string') -- type: string
local Get = Boot() -- get the modules & boot em
for index,module in pairs(Get) do
print(module._Name) -- every module has a _Name
end

print(shared.Option.result1:Match(shared.Option.result2)) --> false
print(shared.Option.result1:Match(shared.Option.result3)) --> true
--[=[
create a new module, run this in the command bar:
local New = Instance.new('ModuleScript')
New.Name = 'WackyModule'
New.Source = 'return {}'
New.Parent = game:GetService('ReplicatedStorage')
]=]

local Name = 'WackyModule'
local Find = game:GetService('ReplicatedStorage'):FindFirstChild(Name)

local RequireByInstance = require(Find) -- require it by instance
local RequireByString = require(Name) -- require that same module

print(RequireByInstance == RequireByString) --> true, because their the same require table
2 changes: 1 addition & 1 deletion src/Manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Manager._Connections = {}
Manager._Timers = {}
Manager._Bouncers = {}
Manager._LastIteration = nil
Manager._Name = script.Name
Manager._Name = string.upper(script.Name)

local Compression = {}
Compression.Dictionary = {}
Expand Down
1 change: 1 addition & 0 deletions src/Roblox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
]=]

local Roblox = {}
Roblox._Name = string.upper(script.Name)
Roblox._ThumbnailCache = {}
Roblox._SetCoreTypes = {
['PromptFriendRequest'] = 'PromptSendFriendRequest';
Expand Down

0 comments on commit dcddb24

Please sign in to comment.