Divergent/mods/Modded Executables/gamedata/scripts/modxml_test.script

24 lines
727 B
Plaintext
Raw Permalink Normal View History

2024-03-17 20:18:03 -04:00
--Test script
function on_xml_read()
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
-- Test 1: Find and replace text in string table
if xml_file_name == [[text\eng\_game_version.xml]]
or xml_file_name == [[text\rus\_game_version.xml]]
then
-- Find string element with "id=ui_st_game_version" text inside it
local res = xml_obj:query("string[id=ui_st_game_version] > text")
if res[1] then
local el = res[1]
local el_text = xml_obj:getText(el)
if el_text then
-- Set new text
local ver_to_string = tostring(MODDED_EXES_VERSION):insert(".", 4):insert(".", 7)
xml_obj:setText(el, el_text .. ". Modified exes, " .. ver_to_string)
end
end
end
end)
end