-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a1282a
commit c92b25b
Showing
13 changed files
with
366 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# [Documentation](https://libs.luau.lol/chest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--!native | ||
|
||
-- callbacks | ||
-- utility for handling callbacks | ||
|
||
local cross = require("libs/cross") | ||
|
||
local callbacks = {} | ||
|
||
function callbacks.SPAWN<A...>(callbacks: { { (A...) -> () } }, ...: A...) | ||
for _, callback_info in callbacks do | ||
cross.spawn(callback_info[1], ...) | ||
end | ||
end | ||
|
||
function callbacks.CONNECTION<A...>( | ||
callbacks: { { (A...) -> () } }, | ||
callback: (A...) -> () | ||
): () -> () | ||
local info = table.freeze({ callback }) | ||
table.insert(callbacks, info) | ||
|
||
return function() | ||
local index = table.find(callbacks, info) | ||
|
||
if index then | ||
if index ~= 1 then | ||
local len = #callbacks | ||
callbacks[index] = callbacks[len] | ||
callbacks[len] = nil | ||
else | ||
callbacks[1] = nil | ||
end | ||
end | ||
end | ||
end | ||
|
||
return table.freeze(callbacks) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
-- base gem | ||
-- class that the other gems inherit from as both classes share | ||
-- the exact same methods for dealing w datastore versioning | ||
|
||
-- NOTE: do when DataStore:GetVersionAtTimeAsync() is added | ||
-- https://devforum.roblox.com/t/upcoming-changes-to-data-stores-versioning/3042258 | ||
|
||
local t = require("../types") | ||
|
||
local basegem_proto = {} :: t.BaseGemPrototype | ||
(basegem_proto :: any).__index = basegem_proto | ||
|
||
basegem_proto.revert = function(gem: t.BaseGem, time: number, auto_migrate: boolean?): (boolean, string?) | ||
local gem: t.GlobalGem | t.Gem = gem :: any | ||
local chest = gem.chest | ||
|
||
error("[CHEST] method not implemented, waiting for DataStore:GetVersionAtTimeAsync() to be added") | ||
end :: any | ||
|
||
basegem_proto.datastore_version = function(gem: t.BaseGem, time: number): (boolean, string?) | ||
local gem: t.GlobalGem | t.Gem = gem :: any | ||
local chest = gem.chest | ||
|
||
error("[CHEST] method not implemented, waiting for DataStore:GetVersionAtTimeAsync() to be added") | ||
end :: any | ||
|
||
return table.freeze(basegem_proto) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--!native | ||
|
||
-- get keyinfo | ||
-- function for getting the keyinfo for a gem | ||
|
||
local t = require("../types") | ||
|
||
local ERR_CANNOT_FIND_GEM = "[CHEST] cannot %s gem %s because it doesnt exist in chest %s" | ||
|
||
local function GET_KEYINFO(local_gem: t.Gem, error_action: string): t.KeyInfo | ||
local chest = local_gem.chest | ||
local name = local_gem.name | ||
local keyinfo = chest.local_keys[name] | ||
|
||
if keyinfo then | ||
return keyinfo :: any | ||
else | ||
error(string.format(ERR_CANNOT_FIND_GEM, error_action, name, chest.name), 2) | ||
end | ||
end | ||
|
||
return GET_KEYINFO |
File renamed without changes.
Oops, something went wrong.