icreator Posted December 31, 2010 Share Posted December 31, 2010 а что стандартные: string.match (s, pattern [, init]) string.gmatch (s, pattern) не работают? мне пишет: Error: addon GuildCommissionaire: Error while running the chunk Error: addon GuildCommissionaire: [string "mods/addons/guildcommissionaire/scriptgcommissionaire.lua"] attempt to call field `match' (a nil value) Error: addon GuildCommissionaire: func: match, field, line: -1, defined: C, line: -1, [c] Error: addon GuildCommissionaire: func: ?, ?, line: 31, defined: Lua, line: 25, [string "mods/addons/guildcommissionaire/scriptgcommissionaire.lua"] Quote Link to comment Share on other sites More sharing options...
Setras Posted December 31, 2010 Share Posted December 31, 2010 Не разбирался в вопросе, но были ли они в луа версии 5.0.*? Недавно столкнулся с тем что одна весьма полезная функция существует в новейшей и предыдущей версиях но отсутствует в 5.0 UPD: http://www.lua.org/manual/5.0/manual.html#5.3 Quote Link to comment Share on other sites More sharing options...
icreator Posted December 31, 2010 Author Share Posted December 31, 2010 Code: will iterate over all the words from string s, printing one per line. The next example collects all pairs key=value from the given string into a table: t = {} s = "from=world, to=Lua" for k, v in string.gfind(s, "(%w+)=(%w+)") do t [k] = v end то есть они заменили string.gmatch на это string.gfind Quote Link to comment Share on other sites More sharing options...
Setras Posted December 31, 2010 Share Posted December 31, 2010 Скорее наоборот. Но я могу и ошибаться. Quote Link to comment Share on other sites More sharing options...
icreator Posted January 1, 2011 Author Share Posted January 1, 2011 просьба это вставить в "как создавать свой аддон" Quote Link to comment Share on other sites More sharing options...
SLA Posted January 1, 2011 Share Posted January 1, 2011 Добавил туда ссылку на английский учебник по Lua 5.0, и заметку, что в АО используется именно Lua 5.0.3. Quote Link to comment Share on other sites More sharing options...
icreator Posted January 4, 2011 Author Share Posted January 4, 2011 как раз find есть щас Code: cmd = string.lower(cmd) .. " " --- выделим из командной строчки параметры "/lc wcc:NEED, ll=greed, smart:on, lln=5" for k, v in string.gfind(cmd, "%s*(.-) [=:] (.-) [%s%p] +" ) do LogInfo(" [", k, "] :=", v) end вот как я выделяю параметры с их значениями из строки Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.