Skip to content

Commit

Permalink
Clockwork 0.95.1
Browse files Browse the repository at this point in the history
* Added command aliases, which can be used to shorten longer commands
while still keeping the original commands present.
* *Contributed by Mr. Meow.*
* Fixed chatbox to display commands properly after one letter is typed.
* *Contributed by NightAngel.*
* Added SpawnPointESP which includes info_player_start point entities,
made minor optimization to staticESP.
* *Contributed by NightAngel.*
* Fixed errors occuring with manage_plugins system menu.
* *Contributed by NightAngel.*
* Fixed DisplayTyping plugin not drawing properly due to a minor mistake
and optimized it further.
* *Contributed by NightAngel.*
  • Loading branch information
Skiastra committed Jan 16, 2016
1 parent 21674d4 commit 87edd33
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 133 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,20 @@ Changelog
---------
The following changes have been made for each official Clockwork build.

0.95.1
-------

* Added command aliases, which can be used to shorten longer commands while still keeping the original commands present.
* *Contributed by Mr. Meow.*
* Fixed chatbox to display commands properly after one letter is typed.
* *Contributed by NightAngel.*
* Added SpawnPointESP which includes info_player_start point entities, made minor optimization to staticESP.
* *Contributed by NightAngel.*
* Fixed errors occuring with manage_plugins system menu.
* *Contributed by NightAngel.*
* Fixed DisplayTyping plugin not drawing properly due to a minor mistake and optimized it further.
* *Contributed by NightAngel.*

0.95
-------

Expand Down
2 changes: 1 addition & 1 deletion Clockwork/garrysmod/gamemodes/clockwork/clockwork.txt
Expand Up @@ -5,7 +5,7 @@
"settings"
{
}
"version" "0.95"
"version" "0.95.1"
"author" "Cloud Sixteen"
"description" "A roleplaying framework developed by Cloud Sixteen for the people."
"workshopid" "474315121"
Expand Down
Expand Up @@ -13,6 +13,7 @@ COMMAND.tip = "Send a radio message out to other characters.";
COMMAND.text = "<string Text>";
COMMAND.flags = bit.bor(CMD_DEFAULT, CMD_DEATHCODE, CMD_FALLENOVER);
COMMAND.arguments = 1;
COMMAND.alias = {"R"};
-- Called when the command has been run.
function COMMAND:OnRun(player, arguments)
Expand Down
Expand Up @@ -165,7 +165,7 @@ function Clockwork.chatBox:IsTypingCommand()
local prefix = Clockwork.config:Get("command_prefix"):Get();
if (string.find(currentText, prefix) == 1) then
return true;
return true;
end;
return false;
Expand Down Expand Up @@ -738,12 +738,32 @@ function Clockwork.chatBox:Paint()
local prefix = Clockwork.config:Get("command_prefix"):Get();
if (command and command != "") then
for k, v in pairs(Clockwork.command:GetAll()) do
if (string.utf8sub(k, 1, string.utf8len(command)) == string.lower(command)
for k, v in pairs(Clockwork.command:GetAlias()) do
local commandLen = string.utf8len(command);
if (commandLen == 0) then
commandLen = 1;
end;
if (string.utf8sub(k, 1, commandLen) == string.lower(command)
and (!splitTable[2] or string.lower(command) == k)) then
if (Clockwork.player:HasFlags(Clockwork.Client, v.access)) then
commands[#commands + 1] = v;
end;
local cmdTable = Clockwork.command:FindByAlias(v);
if (Clockwork.player:HasFlags(Clockwork.Client, cmdTable.access)) then
local bShouldAdd = true;
-- It can so happen that multiple alias for the same command begin with the same string.
-- We don't want to display the same command multiple times, so we check for that.
for k, v in pairs(commands) do
if (v == cmdTable) then
bShouldAdd = false;
end;
end;
if (bShouldAdd) then
commands[#commands + 1] = cmdTable;
end;
end;
end;
if (#commands == 8) then
Expand Down
Expand Up @@ -18,6 +18,7 @@ local hook = hook;
Clockwork.command = Clockwork.kernel:NewLibrary("Command");
Clockwork.command.stored = Clockwork.command.stored or {};
local hidden = {};
local alias = {};
CMD_KNOCKEDOUT = 2;
CMD_FALLENOVER = 4;
Expand Down Expand Up @@ -89,6 +90,16 @@ function Clockwork.command:Register(data, name)
end;
end;
-- We do that so the Command Interpreter can find the command
-- if it's original, non-aliased name has been used.
alias[uniqueID] = uniqueID;
if (data.alias and type(data.alias) == "table") then
for k, v in pairs(data.alias) do
alias[string.lower(tostring(v))] = uniqueID;
end;
end;
self.stored[uniqueID] = data;
self.stored[uniqueID].name = realName;
self.stored[uniqueID].text = data.text or "<none>";
Expand All @@ -108,12 +119,29 @@ function Clockwork.command:FindByID(identifier)
return self.stored[string.lower(string.gsub(identifier, "%s", ""))];
end;
--[[
@codebase Shared
@details Returns command's table by alias or unique id.
@param ID Identifier of the command to find. Can be alias or original command name.
--]]
function Clockwork.command:FindByAlias(id)
return self.stored[alias[id]] or nil;
end;
--[[
@codebase Shared
@details Returns table of all comamnd alias indexed by alias' names.
--]]
function Clockwork.command:GetAlias()
return alias;
end;
if (SERVER) then
function Clockwork.command:ConsoleCommand(player, command, arguments)
if (player:HasInitialized()) then
if (arguments and arguments[1]) then
local realCommand = string.lower(arguments[1]);
local commandTable = self.stored[realCommand];
local commandTable = self:FindByAlias(realCommand);
local commandPrefix = Clockwork.config:Get("command_prefix"):Get();
if (commandTable) then
Expand Down Expand Up @@ -188,10 +216,10 @@ if (SERVER) then
end;
end;
elseif (!Clockwork.player:GetDeathCode(player, true)) then
Clockwork.player:Notify(player, "This is not a valid command!");
Clockwork.player:Notify(player, "This is not a valid command or alias!");
end;
elseif (!Clockwork.player:GetDeathCode(player, true)) then
Clockwork.player:Notify(player, "This is not a valid command!");
Clockwork.player:Notify(player, "This is not a valid command or alias!");
end;
if (Clockwork.player:GetDeathCode(player)) then
Expand Down
Expand Up @@ -28,7 +28,7 @@ end;
Clockwork.ClockworkFolder = Clockwork.ClockworkFolder or GM.Folder;
Clockwork.SchemaFolder = Clockwork.SchemaFolder or GM.Folder;
Clockwork.KernelVersion = "0.95";
Clockwork.KernelVersion = "0.95.1";
Clockwork.KernelBuild = "beta"
Clockwork.DeveloperVersion = true;
Clockwork.Website = "http://kurozael.com";
Expand Down
15 changes: 13 additions & 2 deletions Clockwork/garrysmod/gamemodes/clockwork/framework/sv_kernel.lua

Large diffs are not rendered by default.

Expand Up @@ -36,7 +36,7 @@ if (CLIENT) then
local categories = {};
local mainPlugins = {};
for k, v in pairs(Clockwork.plugin.stored) do
for k, v in pairs(Clockwork.plugin:GetStored()) do
if (v != Schema) then
categories[v.author] = categories[v.author] or {};
categories[v.author][#categories[v.author] + 1] = v;
Expand Down Expand Up @@ -139,7 +139,7 @@ if (CLIENT) then
local systemTable = Clockwork.system:FindByID("Manage Plugins");
local unloaded = data;
for k, v in pairs(Clockwork.plugin.stored) do
for k, v in pairs(Clockwork.plugin:GetStored()) do
if (unloaded[v.folderName]) then
Clockwork.plugin:SetUnloaded(v.name, true);
else
Expand All @@ -166,7 +166,7 @@ if (CLIENT) then
end);
else
Clockwork.datastream:Hook("SystemPluginGet", function(player, data)
Clockwork.datastream:Start(player, "SystemPluginGet", Clockwork.plugin.unloaded);
Clockwork.datastream:Start(player, "SystemPluginGet", Clockwork.plugin:GetUnloaded());
end);
Clockwork.datastream:Hook("SystemPluginSet", function(player, data)
Expand Down

0 comments on commit 87edd33

Please sign in to comment.