From 7b82e8c9574f6c9d8c6661d672ce19f3c21fb14e Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sat, 13 Feb 2021 14:28:26 +0100 Subject: [PATCH 1/7] Added logging to Observer --- plugins/observer.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/observer.lua b/plugins/observer.lua index 1bf79819..f40ee69f 100644 --- a/plugins/observer.lua +++ b/plugins/observer.lua @@ -79,6 +79,11 @@ if (CLIENT) then end end else + -- Log observer usage + function PLUGIN:OnPlayerObserve(client, state) + nut.log.add(client, (state and "observerEnter") or "observerExit") + end + function PLUGIN:PlayerNoClip(client, state) -- Observer mode is reserved for administrators. if (client:IsAdmin()) then @@ -95,6 +100,7 @@ else client:GodEnable() -- Don't allow npcs to target the player. client:SetNoTarget(true) + -- Run observer hook hook.Run("OnPlayerObserve", client, state) else if (client.nutObsData) then @@ -124,6 +130,7 @@ else client:GodDisable() -- Let npcs target the player again. client:SetNoTarget(false) + -- Run observer hook hook.Run("OnPlayerObserve", client, state) end end From 30014088fae908d718dc92c22a542f3baf9f51ce Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sat, 13 Feb 2021 14:29:12 +0100 Subject: [PATCH 2/7] Added log types for Observer --- plugins/logging.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/logging.lua b/plugins/logging.lua index 7722a240..8c6fd76c 100644 --- a/plugins/logging.lua +++ b/plugins/logging.lua @@ -104,6 +104,14 @@ if (SERVER) then local arg = {...} return (L("%s purchased the door", client:Name())) end) + + nut.log.addType("observerEnter", function(client, ...) + return string.format("%s has entered observer.", client:Name()) + end) + + nut.log.addType("observerExit", function(client, ...) + return string.format("%s has left observer.", client:Name()) + end) function PLUGIN:CharacterLoaded(id) local character = nut.char.loaded[id] From 54836f3f5a0bad420e56f952c07ba41661d762db Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sat, 13 Feb 2021 14:45:02 +0100 Subject: [PATCH 3/7] Cleaned some code --- entities/weapons/nut_hands.lua | 2 +- gamemode/core/derma/cl_dev_icon.lua | 8 ++++---- gamemode/core/libs/sh_chatbox.lua | 9 --------- gamemode/core/libs/thirdparty/cl_ikon.lua | 20 +++++++------------- gamemode/core/libs/thirdparty/sh_pon.lua | 2 +- plugins/area/sh_plugin.lua | 1 - plugins/doors/sh_commands.lua | 4 ++-- 7 files changed, 15 insertions(+), 31 deletions(-) diff --git a/entities/weapons/nut_hands.lua b/entities/weapons/nut_hands.lua index dd8d00da..232d0f5b 100644 --- a/entities/weapons/nut_hands.lua +++ b/entities/weapons/nut_hands.lua @@ -62,7 +62,7 @@ CARRY_FORCE_LEVEL = { -- gameplay purposes CARRY_WEIGHT_LIMIT = 100 --- I know some people will fuck around with new prop-throwing system. I'm preventing that shit without making it too non-sense +-- Prevent prop-throwing system abuse. THROW_VELOCITY_CAP = 150 PLAYER_PICKUP_RANGE = 200 diff --git a/gamemode/core/derma/cl_dev_icon.lua b/gamemode/core/derma/cl_dev_icon.lua index b4145d11..c4de1e64 100644 --- a/gamemode/core/derma/cl_dev_icon.lua +++ b/gamemode/core/derma/cl_dev_icon.lua @@ -243,7 +243,7 @@ function PANEL:Init() btn:DockMargin(5, 5, 5, 0) btn.DoClick = function() self:SetupEditor(true, i) - self:UpdateShits() + self:UpdateIcon() end end @@ -258,7 +258,7 @@ function PANEL:Init() self.mdl.OnEnter = function() ICON_INFO.modelName = self.mdl:GetValue() self:SetupEditor(true) - self:UpdateShits() + self:UpdateIcon() end self:AddText("Icon Size") @@ -396,10 +396,10 @@ function PANEL:Init() end self:SetupEditor() - self:UpdateShits(true) + self:UpdateIcon(true) end -function PANEL:UpdateShits() +function PANEL:UpdateIcon() fagLord = true self.camFOV:SetValue(ICON_INFO.FOV) local p = self.prev diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index a4180358..8eff1c63 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -81,15 +81,6 @@ function nut.chat.parse(client, message, noSend) local anonymous = false local chatType = "ic" - --[[ - -- fuckoff - -- Handle anonymous/unknown speaker chat. - if (message:sub(1, 1) == "?" and message:sub(2):find("%S")) then - anonymous = true - message = message:sub(2) - end - ]] - -- Loop through all chat classes and see if the message contains their prefix. for k, v in pairs(nut.chat.classes) do local isChosen = false diff --git a/gamemode/core/libs/thirdparty/cl_ikon.lua b/gamemode/core/libs/thirdparty/cl_ikon.lua index 1899d08e..ecf35475 100644 --- a/gamemode/core/libs/thirdparty/cl_ikon.lua +++ b/gamemode/core/libs/thirdparty/cl_ikon.lua @@ -44,7 +44,7 @@ ikon = ikon or {} ikon.dev = false -ikon.maxSize = 8 -- 8x8 (512^2) is max icon size. eitherwise, fuck off. +ikon.maxSize = 8 -- 8x8 (512^2) is max icon size. /* Initialize hooks and RT Screens. @@ -66,7 +66,6 @@ function ikon:init() */ OLD_HALOADD = OLD_HALOADD or halo.Add function halo.Add(...) - -- shut the fuck up if (ikon.rendering != true) then OLD_HALOADD(...) end @@ -74,7 +73,7 @@ function ikon:init() OLD_HALORENDER = OLD_HALORENDER or halo.Render function halo.Render(...) - -- shut the fuck up + if (ikon.rendering != true) then OLD_HALORENDER(...) end @@ -321,22 +320,17 @@ function ikon:renderIcon(name, w, h, mdl, camInfo, updateCache) file.Write("nsIcon/" .. schemaName .. "/" .. name .. ".png", capturedIcon) ikon.info = nil render.PopRenderTarget() - - -- lol blame your shit mate + if (updateCache) then - -- it's all your falut - -- you rendered wrong shit - -- if you know better solution, give me to it. - local noshit = tostring(os.time()) - file.Write(noshit .. ".png", capturedIcon) + local iconString = tostring(os.time()) + file.Write(iconString .. ".png", capturedIcon) timer.Simple(0, function() - local wtf = Material("../data/".. noshit ..".png") + local wtf = Material("../data/".. iconString ..".png") ikon.cache[name] = wtf - file.Delete(noshit .. ".png") + file.Delete(iconString .. ".png") end) - -- make small ass texture and put that thing in here? end ikon.requestList[name] = nil return true diff --git a/gamemode/core/libs/thirdparty/sh_pon.lua b/gamemode/core/libs/thirdparty/sh_pon.lua index fd09b31b..210ae5c6 100644 --- a/gamemode/core/libs/thirdparty/sh_pon.lua +++ b/gamemode/core/libs/thirdparty/sh_pon.lua @@ -95,7 +95,7 @@ do if predictedNumeric == nil then output[#output + 1] = '[' -- no array component else - output[#output + 1] = '~' -- array component came first so shit needs to happen + output[#output + 1] = '~' -- array component came first end for k, v in next, tbl, predictedNumeric do diff --git a/plugins/area/sh_plugin.lua b/plugins/area/sh_plugin.lua index 54c739aa..b6015b04 100644 --- a/plugins/area/sh_plugin.lua +++ b/plugins/area/sh_plugin.lua @@ -254,7 +254,6 @@ else end -- draw matrix string. - -- slow as fuck I guess? local function drawMatrixString(str, font, x, y, scale, angle, color) surface.SetFont(font) local tx, ty = surface.GetTextSize(str) diff --git a/plugins/doors/sh_commands.lua b/plugins/doors/sh_commands.lua index 955c1224..9227ca70 100644 --- a/plugins/doors/sh_commands.lua +++ b/plugins/doors/sh_commands.lua @@ -27,7 +27,7 @@ nut.command.add("doorsell", { -- Take their money and notify them. client:getChar():giveMoney(price) client:notifyLocalized("dSold", nut.currency.get(price)) - hook.Run("OnPlayerPurchaseDoor", client, entity, false, PLUGIN.callOnDoorChildren) -- i fucking hate this life + hook.Run("OnPlayerPurchaseDoor", client, entity, false, PLUGIN.callOnDoorChildren) nut.log.add(client, "selldoor") else -- Otherwise tell them they can not. @@ -79,7 +79,7 @@ nut.command.add("doorbuy", { client:getChar():takeMoney(price) client:notifyLocalized("dPurchased", nut.currency.get(price)) - hook.Run("OnPlayerPurchaseDoor", client, entity, true, PLUGIN.callOnDoorChildren) -- i fucking hate this life + hook.Run("OnPlayerPurchaseDoor", client, entity, true, PLUGIN.callOnDoorChildren) nut.log.add(client, "buydoor") else -- Otherwise tell them they can not. From 97681359f2a07a2cb26353b2a6baacd2089f61c9 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sat, 13 Feb 2021 15:05:31 +0100 Subject: [PATCH 4/7] Removed unneeded micro-optimizations --- gamemode/core/libs/cl_markup.lua | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/gamemode/core/libs/cl_markup.lua b/gamemode/core/libs/cl_markup.lua index 650ce429..8063ba00 100644 --- a/gamemode/core/libs/cl_markup.lua +++ b/gamemode/core/libs/cl_markup.lua @@ -1,15 +1,4 @@ -local string = string -local table = table -local surface = surface -local tostring = tostring -local pairs = pairs -local setmetatable = setmetatable -local math = math -local Material = Material -local tonumber = tonumber -local file = file - -module("nut.markup") +module("nut.markup", package.seeall) --[[--------------------------------------------------------- Name: Constants used for text alignment. From f82908263c4a0ec3de52a8bd5ff0d52c810ed3a9 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sat, 13 Feb 2021 15:14:11 +0100 Subject: [PATCH 5/7] Micro-optimizations --- gamemode/core/hooks/sh_hooks.lua | 6 +----- plugins/notices/cl_notice.lua | 9 ++++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gamemode/core/hooks/sh_hooks.lua b/gamemode/core/hooks/sh_hooks.lua index cb788ec8..2bf4e404 100644 --- a/gamemode/core/hooks/sh_hooks.lua +++ b/gamemode/core/hooks/sh_hooks.lua @@ -221,11 +221,7 @@ function GM:CalcMainActivity(client, velocity) local animClass = nut.anim.getModelClass(client:GetModel()) if (animClass ~= "player") then - local eyeAngles = client.EyeAngles(client) - local yaw = vectorAngle(velocity)[2] - local normalized = normalizeAngle(yaw - eyeAngles[2]) - - client.SetPoseParameter(client, "move_yaw", normalized) + client:SetPoseParameter("move_yaw", normalizeAngle(vectorAngle(velocity)[2] - client:EyeAngles()[2])) end if ( diff --git a/plugins/notices/cl_notice.lua b/plugins/notices/cl_notice.lua index 50280465..6fe7acd3 100644 --- a/plugins/notices/cl_notice.lua +++ b/plugins/notices/cl_notice.lua @@ -3,9 +3,11 @@ nut.notices = nut.notices or {} -- Move all notices to their proper positions. local function OrganizeNotices() + local scrW = ScrW() + for k, v in ipairs(nut.notices) do v:MoveTo( - ScrW() - (v:GetWide() + 4), + scrW - (v:GetWide() + 4), (k - 1) * (v:GetTall() + 4) + 4, 0.15, (k / #nut.notices) * 0.25 @@ -17,10 +19,11 @@ end function nut.util.notify(message) local notice = vgui.Create("nutNotice") local i = table.insert(nut.notices, notice) + local scrW = ScrW() -- Set up information for the notice. notice:SetText(message) - notice:SetPos(ScrW(), (i - 1) * (notice:GetTall() + 4) + 4) + notice:SetPos(scrW, (i - 1) * (notice:GetTall() + 4) + 4) notice:SizeToContentsX() notice:SetWide(notice:GetWide() + 16) notice.start = CurTime() + 0.25 @@ -44,7 +47,7 @@ function nut.util.notify(message) for k, v in ipairs(nut.notices) do if (v == notice) then -- Move the notice off the screen. - notice:MoveTo(ScrW(), notice.y, 0.15, 0.1, nil, function() + notice:MoveTo(scrW, notice.y, 0.15, 0.1, nil, function() notice:Remove() end) From deffb19e81bd71425042658e1871f4c7fa16db17 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sun, 14 Feb 2021 11:43:02 +0200 Subject: [PATCH 6/7] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 49eab3d7..3a8e8d04 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ NutScript 1.2 is the continuation of the original NutScript framework to provide For a few years 1.1-beta was the name of the newest and most updated version of Nutscript. We are now confident to rename it to 1.2, as the modern stable release of Nutscript. Nutscript 1.2 is actively worked on by community developers, and will see numerous new updates and features added. +## 1.2 vs 1.2-wip +the default 1.2 branch will always be the stable release. If you wish to test new releases before they are integrated into the stable branch, you can opt for 1.2-wip. Be aware that 1.2-wip may have bugs and issues. + ## Documentation Check out the Nutscript wiki at https://nutscript.miraheze.org/wiki/Main_Page From ca648b3682cb6a3bc1bd373020a0fc55fbf23a63 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sun, 14 Feb 2021 12:08:57 +0100 Subject: [PATCH 7/7] Fixed invalid database calling --- gamemode/core/libs/sh_character.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gamemode/core/libs/sh_character.lua b/gamemode/core/libs/sh_character.lua index 7bb19ec8..d8c78b02 100644 --- a/gamemode/core/libs/sh_character.lua +++ b/gamemode/core/libs/sh_character.lua @@ -8,6 +8,10 @@ nut.util.include("character/cl_networking.lua") nut.util.include("character/sv_character.lua") if (SERVER) then + if (not nut.db) then + include("sv_database.lua") + end + -- Fetches all the character names and stores -- them into a table so they only have to be fetched once if (#nut.char.names < 1) then