Skip to content

Commit dabf76f

Browse files
authored
Allow workshop addons to pack rearm scripts (#1788)
from Facepunch/garrysmod#2139
1 parent 8436d8f commit dabf76f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
1111
### Changed
1212
- Updated Russian and English localization files (by @Satton2)
1313
- Updated the list of troublesome addons used by the addonchecker
14+
- Allow workshop addons to pack rearm scripts (Facepunch/garrysmod/pull/2139, by @figardo)
1415

1516
### Fixed
1617

gamemodes/terrortown/gamemode/server/sv_ent_replace.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,20 @@ end
120120
---
121121
-- Checks whether the given map is able to import @{Entity} based on the map's data
122122
-- @param string map
123-
-- @return[default=false] boolean
123+
-- @return[default=nil] string The rearm script's file path
124124
-- @realm server
125125
-- @internal
126126
function ents.TTT.CanImportEntities(map)
127127
local fname = "maps/" .. map .. "_ttt.txt"
128+
if file.Exists(fname, "GAME") then
129+
return fname
130+
end
128131

129-
return file.Exists(fname, "GAME")
132+
-- Allows workshop addons to pack rearm scripts
133+
fname = "data_static/" .. map .. "_ttt.txt"
134+
if file.Exists(fname, "GAME") then
135+
return fname
136+
end
130137
end
131138

132139
local classremap = {
@@ -142,7 +149,7 @@ local classremap = {
142149
-- @internal
143150
-- @realm server
144151
function ents.TTT.ImportEntities(map)
145-
local fname = "maps/" .. map .. "_ttt.txt"
152+
local fname = ents.TTT.CanImportEntities(map)
146153
local buf = file.Read(fname, "GAME")
147154
local lines = string.Explode("\n", buf)
148155

0 commit comments

Comments
 (0)