Skip to content

Commit ac4dbfe

Browse files
authored
Merge pull request #5 from GameSpender/main
fix bad metatable asignment and incorrect integral clamp
2 parents 84a50ad + 1191d4c commit ac4dbfe

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • datapack/data/computercraft/lua/rom/modules/main/advanced_math

datapack/data/computercraft/lua/rom/modules/main/advanced_math/pid.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
local expect = require "cc.expect"
1717
local expect = expect.expect
18-
local metatable
18+
local pid_metatable
1919

2020
--- Performs a PID control step if the setpoint is a scalar (number) value
2121
--
@@ -197,7 +197,7 @@ function new(target, p, i, d, discrete)
197197
controller.prev_error = vector.new()
198198
end
199199
end
200-
return setmetatable(controller, metatable)
200+
return setmetatable(controller, pid_metatable)
201201
end
202202

203203
local function clampOutput(self, min, max)
@@ -225,7 +225,7 @@ local function limitIntegral(self, min, max)
225225
error("Invalid limits! Min must be less than max!")
226226
end
227227
self.integral_min = min
228-
self.integral = max
228+
self.integral_max = max
229229
end
230230

231231
--- A PID, with a scalar, vector, or quaternion setpoint, kP, kI, and kD, both as discrete and continuous.
@@ -291,10 +291,10 @@ local pid = {
291291
end
292292
}
293293

294-
metatable = {
294+
pid_metatable = {
295295
__name = "PID",
296296
__index = pid,
297297
__tostring = pid.tostring
298298
}
299299

300-
return {new = new}
300+
return {new = new}

0 commit comments

Comments
 (0)