Skip to content

Commit 9b40e09

Browse files
committed
Add game.modelExists
1 parent 9ce9c59 commit 9b40e09

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lua/starfall/libs_sh/game.lua

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ game_library.getRealTickInterval = engine.AbsoluteFrameTime
9898
-- @return number Ticks
9999
game_library.getTickCount = engine.TickCount
100100

101+
--- Checks if a model exists in the game files
102+
-- @param string path Filepath in game folder
103+
-- @return boolean? True if exists, false if not, nil if error
104+
function game_library.modelExists(path)
105+
checkluatype (path, TYPE_STRING)
106+
path = SF.NormalizePath(path)
107+
if string.find(path, "models/", 1, true)~=1 then return false end
108+
return file.Exists(path, "GAME")
109+
end
110+
101111
--- Returns AmmoData for given id
102112
-- @param number id See https://wiki.facepunch.com/gmod/Default_Ammo_Types
103113
-- @return table AmmoData, see https://wiki.facepunch.com/gmod/Structures/AmmoData

0 commit comments

Comments
 (0)