Skip to content

Commit

Permalink
lua: rename localized() global function to text.localize()
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Dec 2, 2023
1 parent ee777d6 commit 2e0846f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Misc/qs_pak/scripts/edicts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ function edicts.isclass(edict, ...)
end


local localize <const> = text.localize

local vec3origin <const> = vec3.new()
local vec3one <const> = vec3.new(1, 1, 1)
local vec3minusone <const> = vec3.new(-1, -1, -1)
Expand Down Expand Up @@ -180,7 +182,7 @@ local function localizednetname(edict)
local name = edict.netname

if name and name ~= '' then
name = localized(name)
name = localize(name)

if name:find('the ') == 1 then
name = name:sub(5)
Expand Down
16 changes: 14 additions & 2 deletions Quake/ls_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ static int LS_global_dprint(lua_State* state)
return 0;
}

static int LS_global_localized(lua_State* state)
static int LS_global_text_localize(lua_State* state)
{
const char* key = luaL_checkstring(state, 1);
const char* value = LOC_GetString(key);
Expand Down Expand Up @@ -1056,7 +1056,6 @@ static void LS_InitGlobalFunctions(lua_State* state)
// Helper functions
{ "printmemstats", LS_global_printmemstats },
{ "dprint", LS_global_dprint },
{ "localized", LS_global_localized },

{ NULL, NULL }
};
Expand Down Expand Up @@ -1139,6 +1138,19 @@ static void LS_InitGlobalTables(lua_State* state)
lua_setglobal(state, "sound");
}

// Create and register 'text' table
{
static const luaL_Reg functions[] =
{
{ "localize", LS_global_text_localize },
{ NULL, NULL }
};

luaL_newlib(state, functions);
lua_setglobal(state, "text");
}


// Register namespace for console commands
lua_createtable(state, 0, 16);
lua_setglobal(state, ls_console_name);
Expand Down

0 comments on commit 2e0846f

Please sign in to comment.