Add other mods
This commit is contained in:
13
Lua For Barotrauma/Binary/Lua/DefaultLib/Utils/String.lua
Normal file
13
Lua For Barotrauma/Binary/Lua/DefaultLib/Utils/String.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
string.startsWith = function(str, start)
|
||||
if type(str) ~= "string" then error(string.format("bad argument #1 to 'startsWith' (string expected, got %s)", type(str)), 2) end
|
||||
if type(start) ~= "string" then error(string.format("bad argument #2 to 'startsWith' (string expected, got %s)", type(start)), 2) end
|
||||
|
||||
return string.sub(str, 1, string.len(start)) == start
|
||||
end
|
||||
|
||||
string.endsWith = function(str, ending)
|
||||
if type(str) ~= "string" then error(string.format("bad argument #1 to 'endsWith' (string expected, got %s)", type(str)), 2) end
|
||||
if type(ending) ~= "string" then error(string.format("bad argument #2 to 'endsWith' (string expected, got %s)", type(ending)), 2) end
|
||||
|
||||
return ending == "" or string.sub(str, -string.len(ending)) == ending
|
||||
end
|
||||
Reference in New Issue
Block a user