Jump to content
Alloder.pro  about Allods with love 😱
Search In
  • More options...
Find results that contain...
Find results in...

Results of the competition "Allods and Life"

Stories, that warm souls.

Read More

Digest April

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

Read more

Game tooltips

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

Read more

Сравнение строк


GRuSHa
 Share

Recommended Posts

Доброго времени суток всем.

Столкнулся с проблемой, нужно проверять имя шарда и в зависимости от имени выводить сообщение, но не получается сравнить строки с помощью ==  , перевожу обе строки в WString и всёравно не сравнивает, что посоветуете?

Link to comment
Share on other sites

Если хочется сравнивать через ==, то переводить надо в обычные строки и сравнивать их, а не WString

 

Если хочется сравнивать именно WString, то для этого есть функции:

http://alloder.pro/md/LuaApi/FunctionCompareWString.html

http://alloder.pro/md/LuaApi/FunctionCompareWStringEx.html

Link to comment
Share on other sites

оно не сравнивает ни в обычных строках ни в WString

Error: addon Addon:   func: ToWString, field, line: -1, defined: C, line: -1, [C]
Error: addon Addon:     func: OnGetShard, global, line: 33, defined: Lua, line: 23, [string "Mods/Addons/Addon/scripts/AddonScript.lua"]
Error: addon Addon:       func: Init, global, line: 96, defined: Lua, line: 91, [string "Mods/Addons/Addon/scripts/AddonScript.lua"]
Error: addon Addon:         func: ?, ?, line: 112, defined: main, line: 0, [string "Mods/Addons/Addon/scripts/Addon.lua"]
Error: addon Addon: Game::LuaDebugToWString: param 1 not a class nstl::basic_string<char> (type: WString), details: int __cdecl Game::LuaDebugToWString(struct lua_State *)
Link to comment
Share on other sites


if common.CompareWString( mission.GetShardName(), userMods.ToWString( "Нужный шард" ) ) ~=  0 then

--- some code

end


if userMods.FromWString( mission.GetShardName() ) ~= "Нужный шард" then

  --- some code

end

  • Upvote 1
Link to comment
Share on other sites

 

оно не сравнивает ни в обычных строках ни в WString

Error: addon Addon: Game::LuaDebugToWString: param 1 not a class nstl::basic_string<char> (type: WString), details: int __cdecl Game::LuaDebugToWString(struct lua_State *)

Передаваемый в функцию ToWString параметр 1 не "nstl::basic_string<char>", а WString.

 

Т.е. вместо обычной строки (string) вы в функуию "превратить обычную строку в WideString" передаете WideString, в то время как функции нужно передать обычную строку.

В описании функции mission.GetShardName() написано что функция возвращает WString:

-- возвращаемое значение: WString - локализованное имя шарда

 

А в коде у вас наверняка используется string вроде "Ожившие Легенды". Соответственно чтобы сравнить string и WString их нужно привести к одному типу. Т.е. либо сконвертировать string в WString, либо наоборот.

 

П.С. И WString не сравниваются оператором ==, для них есть специальная функция.

  • Upvote 1
Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use