Unwanted Lua Error Spam in Tiramisu

ERROR: GAMEMODE:‘HUDPaint’ Failed: [@lua\includes\extensions\string.lua:34] bad argument #1 to ‘string_gmatch’ (string expected, got nil)

is spammed whenever a player joins the server and is spammed until the player hits esc or opens the console.

This is line 34 to the end of the function


 for startPosition,endPosition in string_gmatch( str, "()" .. separator.."()" ) do
        ret[index] = string_sub( str, lastPosition, startPosition-1)
        index = index + 1
         
        -- Keep track of the position
        lastPosition = endPosition
    end
     
    -- Add last part by using the position we stored
    ret[index] = string_sub( str, lastPosition)
    return ret
end


There’s also an error when opening the spawn menu:

ERROR: GAMEMODE:‘OnSpawnMenuOpen’ Failed: [gamemodes\sandbox\gamemode\spawnmenu\spawnmenu.lua:91] attempt to call field ‘SpawnMenuOpen’ (a nil value)

This error only occurs when the player presses q and open the spawn menu.

Any way that this could possibly be fixed?

Where is the variable str defined?

Not much of a lua guy, but I can’t see where it is.

Here’s lines 1-45 of the file


function string.ToTable ( str )
	local tbl = {}
	
	for i = 1, string.len( str ) do
		tbl* = string.sub( str, i, i )
	end
	
	return tbl
end

/*---------------------------------------------------------
   Name: explode(seperator ,string)
   Desc: Takes a string and turns it into a table
   Usage: string.explode( " ", "Seperate this string")
---------------------------------------------------------*/
local totable = string.ToTable
local string_sub = string.sub
local string_gsub = string.gsub
local string_gmatch = string.gmatch
function string.Explode(separator, str, withpattern)
    if (separator == "") then return totable( str ) end
     
    local ret = {}
    local index,lastPosition = 1,1
     
    -- Escape all magic characters in separator
    if not withpattern then separator = string_gsub( separator, "[%-%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%1" ) end
     
    -- Find the parts
    for startPosition,endPosition in string_gmatch( str, "()" .. separator.."()" ) do
        ret[index] = string_sub( str, lastPosition, startPosition-1)
        index = index + 1
         
        -- Keep track of the position
        lastPosition = endPosition
    end
     
    -- Add last part by using the position we stored
    ret[index] = string_sub( str, lastPosition)
    return ret
end