Skip to content

Commit e71f0b3

Browse files
authored
fix lua errors after autorefresh (#1793)
editing these files will cause errors from trying to use nil upvalues
1 parent 4729f81 commit e71f0b3

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
3737
- Fixed clientside door.GetAll() to return a more updated list of doors
3838
- Removed clientside TTT2PostDoorSetup hook
3939
- Changed crowbar unlocking behavior to match base TTT
40+
- Fixed lua errors after autorefresh (by @wgetJane)
4041

4142
## [v0.14.2b](https://github.com/TTT-2/TTT2/tree/v0.14.2b) (2025-02-02)
4243

lua/autorun/gs_crazyphysics.lua

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,13 @@ local tEntitiesToCheck = {
162162
"prop_ragdoll",
163163
}
164164

165-
local bTTT
166-
local tIdentifyEntities
167-
local corpseConfig
165+
local tIdentifyEntities = {
166+
prop_ragdoll = true,
167+
}
168+
local corpseConfig = CORPSE and CORPSE.cv
168169

169170
hook.Add("Initialize", "TTT2GSCrazyPhysics", function()
170-
-- Change check if your terrortown folder is named something different
171-
bTTT = engine.ActiveGamemode():lower() == "terrortown" and TTT2 and istable(CORPSE)
172-
if bTTT then
173-
-- Add entity classes you want identified
174-
tIdentifyEntities = {
175-
prop_ragdoll = true,
176-
}
177-
178-
corpseConfig = CORPSE.cv
179-
end
171+
corpseConfig = CORPSE.cv
180172
end)
181173

182174
util.AddNetworkString("GS_CrazyPhysics_Defuse")
@@ -407,7 +399,7 @@ hook.Add("Think", "GS_CrazyPhysics", function()
407399

408400
pEntity:Remove()
409401

410-
if bTTT and tIdentifyEntities[sClass] then
402+
if tIdentifyEntities[sClass] then
411403
IdentifyCorpse(pEntity)
412404
end
413405

lua/ttt2/libraries/bodysearch.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,10 @@ if SERVER then
115115
local mathRound = math.Round
116116
local mathFloor = math.floor
117117

118-
local cv_ttt2_confirm_killlist
118+
local cv_ttt2_confirm_killlist = CORPSE and CORPSE.cv.confirm_killlist
119119

120120
hook.Add("Initialize", "TTT2BodySearch", function()
121-
-- Change check if your terrortown folder is named something different
122-
if engine.ActiveGamemode():lower() == "terrortown" and TTT2 and istable(CORPSE) then
123-
cv_ttt2_confirm_killlist = CORPSE.cv.confirm_killlist
124-
end
121+
cv_ttt2_confirm_killlist = CORPSE.cv.confirm_killlist
125122
end)
126123

127124
util.AddNetworkString("ttt2_client_reports_corpse")

lua/ttt2/libraries/targetid.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ local materialDestructible = Material("vgui/ttt/tid/tid_destructible")
3737
local materialDNATargetID = Material("vgui/ttt/dnascanner/dna_hud")
3838
local materialFire = Material("vgui/ttt/tid/tid_onfire")
3939

40-
local cv_ttt_identify_body_woconfirm
40+
local cv_ttt_identify_body_woconfirm = CORPSE and CORPSE.cv.identify_body_woconfirm
4141

4242
hook.Add("Initialize", "TTT2TargetID", function()
43-
-- Change check if your terrortown folder is named something different
44-
if engine.ActiveGamemode():lower() == "terrortown" and TTT2 and istable(CORPSE) then
45-
cv_ttt_identify_body_woconfirm = CORPSE.cv.identify_body_woconfirm
46-
end
43+
cv_ttt_identify_body_woconfirm = CORPSE.cv.identify_body_woconfirm
4744
end)
4845

4946
---

0 commit comments

Comments
 (0)