All pastes #901062 Raw Edit

Someone

public text v1 · immutable
·published 2008-02-12 11:19 UTC
rendered paste body
/*---------------------------------------------*\
       EXPERIMENTAL SWITCH STATEMENT :D
\*---------------------------------------------*/
/* required table design
local t = {
    {
        ["condition"] = "a",
        ["code"] = "Msg( "AYY" )"
    },
    {
        ["condition"] = "b",
        ["code"] = "Msg( "NEWFAGS" )
    }
}
*/

Msg("--> (SWITCH INSTALLED) <--\n")
        
function switch( arg, tab )

    for i = 1, #tab do
        if( arg == tab[i]["condition"] ) then
            RunString( tab[i]["code"] )
        end
    end

end

local t = { 
    { 
        condition = "a",
        code = "MsgN( \"AYY\" )"
    },
    {
        condition = "b",
        code = "MsgN( \"NEWFAGS\" )"
    }
}

function lol(...)
    switch( "b", t )
end
concommand.Add("call_switch", lol)