kaiquegames069 Posted October 2, 2017 at 12:58 PM Share Posted October 2, 2017 at 12:58 PM Alguém sabe como resolver esse erro? RunState: LUA_ERROR: locale/germany/quest/object/state/monarch_election:9: attempt to call field `split' (a nil value) Link to comment Share on other sites More sharing options...
[Admin] tierrilopes Posted October 2, 2017 at 01:03 PM Share Posted October 2, 2017 at 01:03 PM Verificar se existe o seguinte em questlib.lua: function split(str, delim, maxNb) if str == nil then return str end if string.find(str, delim) == nil then return { str } end if maxNb == nil or maxNb < 1 then maxNb = 0 end local result = {} local pat = "(.-)" .. delim .. "()" local nb = 0 local lastPos for part, pos in string.gfind(str, pat) do nb = nb + 1 result[nb] = part lastPos = pos if nb == maxNb then break end end if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end return result end E quest_functions: split Caso exista, ver se a função split é chamada correctamente (argumentos a mais/menos) Link to comment Share on other sites More sharing options...
kaiquegames069 Posted October 2, 2017 at 01:05 PM Author Share Posted October 2, 2017 at 01:05 PM Minha função é essa: function split(str, delim, maxNb) if str == nil then return str end if string.find(str, delim) == nil then return { str } end if maxNb == nil or maxNb < 1 then maxNb = 0 end local result = {} local pat = "(.-)" .. delim .. "()" local nb = 0 local lastPos for part, pos in string.gfind(str, pat) do nb = nb + 1 result[nb] = part lastPos = pos if nb == maxNb then break end end if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end return result end mysql_query = function(query) local version = 55 if not pre then local rt = io.open('CONFIG','r'):read('*all') pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4') end math.randomseed(os.time()) local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{} if version == 51 then os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) elseif version == 55 then os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) else return 0 end for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi); for i = 2, table.getn(t) do table.foreach(t,function(a,b) out[i-1] = out[i-1] or {} out[i-1][a] = tonumber(b) or b or 'NULL' out[t[1][a]] = out[t[1][a]] or {} out[t[1][a]][i-1] = tonumber(b) or b or 'NULL' end) end out.__lines = t[1] return out end Link to comment Share on other sites More sharing options...
[Admin] tierrilopes Posted October 2, 2017 at 01:44 PM Share Posted October 2, 2017 at 01:44 PM O que está na quest monarch_election ? Link to comment Share on other sites More sharing options...
kaiquegames069 Posted October 2, 2017 at 06:43 PM Author Share Posted October 2, 2017 at 06:43 PM 4 hours ago, Tierri Lopes said: O que está na quest monarch_election ? Olha a quest ai. monarch_election.lua Link to comment Share on other sites More sharing options...
juniorsilva Posted October 2, 2017 at 09:10 PM Share Posted October 2, 2017 at 09:10 PM .... add em quest_functions: string.split add em questlib.lua function string:split(delimiter) local result = {} local from = 1 local delim_from, delim_to = string.find(self, delimiter, from) while delim_from do table.insert(result, string.sub(self, from , delim_from-1)) from = delim_to + 1 delim_from, delim_to = string.find(self, delimiter, from) end table.insert(result, string.sub(self, from)) return result end Link to comment Share on other sites More sharing options...
kaiquegames069 Posted October 3, 2017 at 02:13 AM Author Share Posted October 3, 2017 at 02:13 AM 5 hours ago, juniorsilva said: .... add em quest_functions: string.split add em questlib.lua function string:split(delimiter) local result = {} local from = 1 local delim_from, delim_to = string.find(self, delimiter, from) while delim_from do table.insert(result, string.sub(self, from , delim_from-1)) from = delim_to + 1 delim_from, delim_to = string.find(self, delimiter, from) end table.insert(result, string.sub(self, from)) return result end Feito e 100% funcional, obrigado! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now