Jump to content

Digest January-March

We talk about what was done and updated in the past month. We help keep abreast of events.

March February January

Servers monitoring and the Addons Editor

We present you two legends. All dreams come true.

Servers monitoring The Addons Editor

A statistics bot for Telegram

Convenient analytics right on your phone.

Read more

Game tooltips

Tooltips provide a way for 3rd party fansites and extensions to display detailed information on mouseover.

Read more

The Addons Updater

Let us to introduce the addons updating software and to share the details

Read more Download

New GetGameLocalization()


Setras

Recommended Posts

Многие разработчики, переводящие свои аддоны на другие языки и встраивающие в них определение локализации игрового клиента наверняка до сих пор используют старый метод:

-- AO game Localization detection by SLA. Version 2011-02-10.
function GetGameLocalization()
local B = cartographer.GetMapBlocks()
local T = { rus="\203\232\227\224", eng="Holy Land", ger="Heiliges Land",
fra="Terre Sacr\233e", br="Terra Sagrada", jpn="\131\74\131\106\131\65" }
for b in B do for l,t in T do
if userMods.FromWString( cartographer.GetMapBlockInfo(B [b] ).name ) == t
then return l end; end; end; return "eng"
end

Который с помощью изучения названия карт возвращает нам одно из заранее заданных значений(rus, eng, ger, fra, br, jpn).

Однако существует способ более простого и гарантированного(старый метод переставал работать на гипате из-за перемещения блоков карт относительно друг друга, когда он полагался на положение карты в массиве) получения игровой локализации (настолько насколько понятие "гарантированного" допустимо в аллодах :) ) найденный Ciuine:

function GetGameLocalization()
 local LocOption = options.GetOptionsByCustomType("interface_option_localization")
 if LocOption then for i, v in LocOption do
 for j, x in options.GetOptionInfo(v) do if j == "values" then
 for k, y in x do for l, z in y do if l == "name" then
 return userMods.FromWString(z)
 end end end end end end end
end

Или менее гарантированный (т.к. может перестать работать если в блок опций "локализации" добавят новый параметр перед языком локализации) но по сути своей аналогичный:

function GetGameLocalization()
local InterfaceOptionInfo = options.GetOptionInfo(options.GetOptionsByCustomType("interface_option_localization")[0])
return userMods.FromWString(InterfaceOptionInfo.values[interfaceOptionInfo.baseIndex].name)
end

  • Upvote 1
Link to comment
Share on other sites

круто! мож там еще версия клиента хранится?

Версия клиента получается либо так (нам недоступно, как понимаете) :

protectedCommon.GetGameVersion()
protectedCommon.GetGameBuildInfo()

Либо с помощью извращений (Вам уж это прекрасно известно).

А функция GetOptionByCustomType() принимает следущие аргументы:

"autonavigation_enabled"
"interface_option_simplified_move"
"detailed_item_compare"
"inverted_item_compare"
"show_player_name"
"emote_icons_show"
"chat_bubbles_show"
"chat_bubbles_opacity"

, итд... то есть те, которые вы указываете в настройках интерфейса.

P.S. Setras, спасиб за инфу!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use