Skip to content

Commit

Permalink
Build 107
Browse files Browse the repository at this point in the history
Custom is still a TODO; Don't use until I announce it ;p
  • Loading branch information
Sezei committed Jan 15, 2024
1 parent d2ac149 commit a41cb82
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 354 deletions.
17 changes: 10 additions & 7 deletions Client/Main.luau
Expand Up @@ -396,18 +396,21 @@ local function CreateNotification(text:string, options:{[any?]: any?}?)
["BackgroundColor"] = Color3.fromRGB(45, 45, 45);
["TextColor"] = Color3.fromRGB(255, 127, 0);
});
options.Sound = options.Sound or 'rbxassetid://5974456365';
elseif string.lower(options.Type) == "error" then
Cardboard:UpdateAsset(UID, {
["BackgroundColor"] = Color3.fromRGB(45, 45, 45);
["TextColor"] = Color3.fromRGB(255, 60, 60);
});
options.Sound = options.Sound or 'rbxassetid://5974456449';
elseif string.lower(options.Type) == "critical" then
Cardboard:UpdateAsset(UID, {
["BackgroundColor"] = Color3.fromRGB(255, 60, 60);
["TextColor"] = Color3.fromRGB(255, 255, 255);
});
Label.Font = Enum.Font.GothamBlack;
PushingDown = true;
options.Sound = options.Sound or 'rbxassetid://5974456264';
end
end
if options.TextColor and typeof(options.TextColor) == "Color3" then
Expand Down Expand Up @@ -671,7 +674,7 @@ local function UpdateNotification(Notification:TextButton|string, Changes:any)
Notification:TweenSize(UDim2.new(0, XSize, 0, 40), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.3, true);
end

local function CreateList(title:string, items:{any: string|number}?, options:{string: any?}?)
local function CreateList(title:string, items:{any: string|number}?, options:{string: boolean}?)
if not items then items = {} end;
if not options then options = {Searchbar = true; Minimizable = true;} end;
--TODO
Expand Down Expand Up @@ -717,7 +720,7 @@ local function CreateList(title:string, items:{any: string|number}?, options:{st
Searchbar:GetPropertyChangedSignal("Text"):Connect(function()
local SearchText = Searchbar.Text;
for _, button in (Container:GetChildren()) do
if button:IsA("TextButton") and button.Name ~= "TemplateButton" then
if button:IsA("TextButton") and button.Name ~= "TemplateButton" and button.Name ~= "TemplateRealButton" then
if string.find(string.lower(button.Label.Text), string.lower(SearchText)) then
button.Visible = true;
else
Expand Down Expand Up @@ -1336,8 +1339,8 @@ Commandbar.Input:GetPropertyChangedSignal("Text"):Connect(function()
else
MaskedText = MaskedText .. " <font color='#FFFFFF'>" .. arg .. "</font>";
end
elseif Type == "subcommand" then
-- This type is no longer supported.
elseif Type == "dependant" then
--TODO: Use custom for now
elseif Type == "custom" then
if CommandArgs[argnum].Validator then
local valid, err = pcall(CommandArgs[argnum].Validator, arg);
Expand Down Expand Up @@ -1518,7 +1521,7 @@ Commandbar.Input:GetPropertyChangedSignal("Text"):Connect(function()
end
else
-- Check if the last argument type is a string in order to highlight the rest of the args as a string rather than as a non-existent argument
if CommandArgs and CommandArgs[#CommandArgs] and (CommandArgs[#CommandArgs].Type == "string" or CommandArgs[#CommandArgs].Type == "rawinput") then
if CommandArgs and CommandArgs[#CommandArgs] and (string.lower(CommandArgs[#CommandArgs].Type) == "string" or string.lower(CommandArgs[#CommandArgs].Type) == "rawinput") then
MaskedText = MaskedText .. " <font color='#FFFFFF'>" .. arg .. "</font>";
else
MaskedText = MaskedText .. " <font color='#AAAAAA'>" .. arg .. "</font>";
Expand Down Expand Up @@ -1632,7 +1635,7 @@ RemoteEvent.OnClientEvent:Connect(function(...)
table.remove(Arguments, 1);

if EventName == "Notify" then
CreateNotification(Arguments[1], Arguments[2]);
CreateNotification(tostring(Arguments[1]), Arguments[2]);
elseif EventName == "UpdateNotification" then
UpdateNotification(Arguments[1], Arguments[2]);
elseif EventName == "ClearNotification" then
Expand Down Expand Up @@ -1676,7 +1679,7 @@ RemoteFunction.OnClientInvoke = function(...)
if FunctionName == "NotificationExists" then
return (not (not Cardboard:FindAsset(Arguments[1])));
elseif FunctionName == "Notify" then -- If used in a function, it usually means the server is awaiting for a response from the player due to the .Options; Return an UUID to the server.
local _, UID = CreateNotification(Arguments[1], Arguments[2]);
local _, UID = CreateNotification(tostring(Arguments[1]), Arguments[2]);
return UID;
elseif FunctionName == "Prompt" then
local _, UID = CreatePrompt(Arguments[1]);
Expand Down
2 changes: 1 addition & 1 deletion Functions/BaseEnvironment.luau
@@ -1,7 +1,7 @@
local env = {
-- Version info
NxEngine = {
BuildId = 103;
BuildId = 107;
};

-- In-game Data
Expand Down
12 changes: 9 additions & 3 deletions Functions/CommandSC.luau
@@ -1,4 +1,8 @@
return function (env, mod, v)
type SysLog = {
[number]:number|string;
}

return function (env:{Data:{Logs:{System:SysLog}};warn:(number|string,string?)->nil}, mod, v)
table.insert(env.Data.Logs.System, {os.time(), "CommandSC", "SC'ing "..v.Name});
if not (type(mod) == "table") then
env.warn(3,v.Name.." is not a valid command: Expected table, got "..typeof(mod));
Expand All @@ -16,7 +20,7 @@ return function (env, mod, v)

-- Sanity check the arguments;
if type(mod.Arguments)=='table' then
for argkey,argument in pairs(mod.Arguments) do
for argkey:string,argument in mod.Arguments do
if not (type(argument) == "table") then
env.warn(3,v.Name.." is not a valid command: Argument "..argkey.." is not a table");
return false;
Expand All @@ -43,7 +47,9 @@ return function (env, mod, v)
"players";
"safeplayers";
"color";
"slider";
"custom";
"slider"; -- Compatibility stuff
"dependant"; -- Added build 105 - still todo so use 'custom' for now
};
if not (table.find(matchingtypes, typeofcommand)) then
env.warn(v.Name.." might error: Argument "..argkey.." has an invalid type.");
Expand Down
45 changes: 36 additions & 9 deletions Functions/Datastore.luau
Expand Up @@ -100,11 +100,19 @@ local function error(debg,...)
end

--Module
function Module(name,env,...)
function Module(name,env,Vars,...)
Vars = Vars or {
nocache = false; -- Disable Cache
nosandbox = false; -- Disable sandboxing; Init only
};

if type(Vars.nocache)=='nil' then Vars.nocache = false end;
if type(Vars.nosandbox)== 'nil' then Vars.nosandbox = false end;

table.insert(env.Data.Logs.System, {os.time(), "Datastore", "Listening to category "..name});
if not api then api = env end;

if privateserver then -- Sandbox the datastore to the private server's owner ID.
if privateserver and not Vars.nosandbox then -- Sandbox the datastore to the private server's owner ID.
name = name.."_Prv"..privateserver;
end

Expand Down Expand Up @@ -134,6 +142,8 @@ function Module(name,env,...)
Task.Key = key
Task.Category = self
Task.Cancelled = false

Task.Cache = not Vars.nocache;

if type(data) == "table" then
data = "_tbl:"..httpSvc:JSONEncode(data);
Expand Down Expand Up @@ -195,6 +205,8 @@ function Module(name,env,...)
Task.Key = key
Task.Category = self
Task.Cancelled = false

Task.Cache = not Vars.nocache;

function Task:wait()
repeat
Expand Down Expand Up @@ -243,6 +255,8 @@ function Module(name,env,...)
Task.Key = key
Task.Category = self
Task.Cancelled = false

Task.Cache = not Vars.nocache;

function Task:wait()
repeat
Expand Down Expand Up @@ -310,6 +324,8 @@ function Module(name,env,...)
Task.Key = key
Task.Category = self
Task.Cancelled = false

Task.Cache = not Vars.nocache;

function Task:wait() repeat task.wait() until (self.Complete or self.Cancelled) end
function Task:Cancel() self.Cancelled = true; end
Expand Down Expand Up @@ -352,6 +368,8 @@ function Module(name,env,...)
Task.Key = key
Task.Category = self
Task.Cancelled = false

Task.Cache = not Vars.nocache;

function Task:wait() repeat task.wait() until (self.Complete or self.Cancelled) end
function Task:Cancel() self.Cancelled = true; end
Expand Down Expand Up @@ -422,11 +440,13 @@ task.spawn(function()
ok,err = pcall(function()
if (Task.Type == "Save") then
if not data then return end
if datacache[Task.Category.Name][Task.Key] == data then warn("Even Easier Datastore | " .. Task.Key.." - Unnecessary save request!"); return end;
if Task.Cache then
if datacache[Task.Category.Name][Task.Key] == data then warn("Even Easier Datastore | " .. Task.Key.." - Unnecessary save request!"); return end;
datacache[Task.Category.Name][Task.Key] = data;
end
if not disabled then
Task.Category.Store:SetAsync(Task.Key,data) -- Save in here too just in-case the API will go down. - It'll destroy the Sync tho.
end
datacache[Task.Category.Name][Task.Key] = data;
elseif (Task.Type == "Nullify") then
if not disabled then
Task.Category.Store:RemoveAsync(Task.Key)
Expand All @@ -436,18 +456,25 @@ task.spawn(function()
elseif (Task.Type == "Update") then
--Rather than making tons of requests to the datastore, we cumulate the modifier functions here
--and only request with the result
if datacache[Task.Category.Name][Task.Key] == data then warn("Even Easier Datastore | " .. Task.Key.." - Unnecessary update request!"); return end;
if Task.Cache then
if datacache[Task.Category.Name][Task.Key] == data then warn("Even Easier Datastore | " .. Task.Key.." - Unnecessary update request!"); return end;
datacache[Task.Category.Name][Task.Key] = data;
end
local function func(variant)
for _,f in pairs(data) do variant = f(variant) end
return variant
end
if not disabled then
Task.Category.Store:UpdateAsync(Task.Key,func)
end
datacache[Task.Category.Name][Task.Key] = data;
else
if datacache[Task.Category.Name][Task.Key] then
Task.Data = datacache[Task.Category.Name][Task.Key]
if Task.Cache and datacache[Task.Category.Name][Task.Key] then
local dat = datacache[Task.Category.Name][Task.Key];
if type(dat) == "string" and string.sub(dat,1,5) == "_tbl:" then
Task.Data = httpSvc:JSONDecode(string.sub(dat,6));
else
Task.Data = dat
end
else
local dat = Task.Category.Store:GetAsync(Task.Key)
if type(dat) == "string" and string.sub(dat,1,5) == "_tbl:" then
Expand Down Expand Up @@ -504,7 +531,7 @@ task.spawn(function()
end

--Also, we'll tell you so you know what's happening.
--print("Even Easier Datastore | Saving to key '" .. Task.Key .. "' failed with error: \"" .. err .. "\", retrying in " .. Task.NextTry .. " seconds")
print("Even Easier Datastore | Saving to key '" .. Task.Key .. "' failed with error: \"" .. err .. "\", retrying in " .. Task.NextTry .. " seconds")
Task.Data = data
end

Expand Down

0 comments on commit a41cb82

Please sign in to comment.