diff --git a/modules/pid/init.lua b/modules/pid/init.lua index 26d116df..c34a46e0 100644 --- a/modules/pid/init.lua +++ b/modules/pid/init.lua @@ -124,7 +124,7 @@ function PID:Debug(name: string, parent: Instance?) local folder = Instance.new("Folder") folder.Name = name - folder:AddTag("__pidebug__") + folder:AddTag("PIDDebug") local function Bind(attrName, propName) folder:SetAttribute(attrName, self[propName]) @@ -149,12 +149,32 @@ function PID:Debug(name: string, parent: Instance?) folder:SetAttribute("Output", self._min) local lastOutput = 0 - self.Calculate = function(...) - lastOutput = PID.Calculate(...) + self.Calculate = function(s, sp, pv, ...) + lastOutput = PID.Calculate(s, sp, pv, ...) folder:SetAttribute("Output", lastOutput) return lastOutput end + local delayThread: thread? = nil + folder:SetAttribute("ShowDebugger", false) + folder:GetAttributeChangedSignal("ShowDebugger"):Connect(function() + if delayThread then + task.cancel(delayThread) + end + + local showDebugger = folder:GetAttribute("ShowDebugger") + + if showDebugger then + delayThread = task.delay(0.1, function() + delayThread = nil + if folder:GetAttribute("ShowDebugger") then + folder:SetAttribute("ShowDebugger", false) + warn("Install the PID Debug plugin: https://create.roblox.com/store/asset/16279661108/PID-Debug") + end + end) + end + end) + folder.Parent = parent or workspace self._debug = folder end diff --git a/modules/pid/package.json b/modules/pid/package.json index 2588aea5..57790cf6 100644 --- a/modules/pid/package.json +++ b/modules/pid/package.json @@ -1,6 +1,6 @@ { "name": "@rbxutil/pid", - "version": "2.0.0", + "version": "2.1.0", "main": "init.lua", "repository": "github:Sleitnick/RbxUtil", "license": "MIT", diff --git a/modules/pid/wally.toml b/modules/pid/wally.toml index 000a6d6e..7c9d6260 100644 --- a/modules/pid/wally.toml +++ b/modules/pid/wally.toml @@ -1,7 +1,7 @@ [package] name = "sleitnick/pid" description = "PID Controller class" -version = "2.0.0" +version = "2.1.0" license = "MIT" authors = ["Stephen Leitnick"] registry = "https://github.com/UpliftGames/wally-index"