--==<< CV TWorkers functions >>==-- --==<< By CV Version 0.1 >>==-- local _archivo = "workers" -- Puedes ponerle el nombre que tu quieras al archivo por defecto. local lugar = "/userfunctions/" -- Puedes crear una carpeta especial donde guardar el archivo y especificarla aquí. local dbg = false local titulo = "--==<< CV TWorkers data >>==--\n--==<< By CV Version 0.1 >>==--"; function file_check(file_name) local file_found=io.open(getExecutionPath()..lugar..file_name..".txt", "r") if file_found==nil then return false else return true end end function explode(div,str) if (div=='') then return false end local pos,arr = 0,{} for st,sp in function() return string.find(str,div,pos,true) end do table.insert(arr,string.sub(str,pos,st-1)) pos = sp + 1 end table.insert(arr,string.sub(str,pos)) return arr end function start_file(_arch) if _arch then archN = _arch else archN = _archivo end local tws = {} local i = 1 if file_check(archN) then file = assert(io.open(getExecutionPath()..lugar..archN..".txt", "r")) if dbg then cprintf(cli.yellow, "\rLeemos..\n"); end for linea in file:lines() do if string.sub(linea, 1, 2) ~= '--' then tws[i] = linea if dbg then cprintf(cli.yellow, "\r%d -> %s\n",i,linea ); end i = i + 1 end end file:close() return tws; else cprintf(cli.blue, "\nTWorkers creara el archivo : %s\n",getExecutionPath()..lugar..archN..".txt" ); f = io.open(getExecutionPath()..lugar..archN..".txt","w") f:write(titulo) f:close() return tws; end end local function worker_Data() player:update() local _sep = " | "; local _datos = player.Name.._sep; local pTokenCount = inventory:itemTotalCount(203038); local fusionStones = {202880,202882,202883,202885,202995,202996,202997,202998,203000,203001,203002,203003,203004,206219,206220,206227,206694,207004,202999} local cintos = {228966,228996,228975} local cintoT = 0 local piedraN = 0 local cargas = 0 for i, t in pairs(cintos) do cintoT = cintoT + inventory:itemTotalCount(t); yrest(150) end for i, p in pairs(fusionStones) do piedraN = piedraN + inventory:itemTotalCount(p); yrest(150) end if RoMScript("IsMagicBoxEnable()") then cargas = RoMScript('GetMagicBoxEnergy();') else cargas = 0 end return _datos..cintoT.._sep..piedraN.._sep..cargas.._sep..pTokenCount; end function save_TW(_fileN,_dbg) if _dbg then dbg = true end if _fileN then nameF = _fileN else nameF = _archivo end local count = 0 local inList = false local datos = start_file(nameF) for _i in pairs(datos) do count = count + 1 end if count > 0 then if dbg then cprintf(cli.lightblue, "\rPara guardar..\n"); end for i,t in ipairs(datos) do if dbg then cprintf(cli.lightblue, "\r%d -> %s\n",i,t ); end if string.find(t, player.Name) then datos[i] = worker_Data() if dbg then cprintf(cli.blue, "\rEditamos la linea : %d\t",i ); end inList = true end end if not inList then datos[(count + 1)] = worker_Data() if dbg then cprintf(cli.blue, "\rSe agregó al Personaje : %s\t",player.Name ); end end else datos[count] = worker_Data() end archivo = assert(io.open(getExecutionPath()..lugar..nameF..".txt", "w")) archivo:write(titulo) archivo:close() archivo = assert(io.open(getExecutionPath()..lugar..nameF..".txt", "a+")) for i, d in ipairs(datos) do archivo:write("\n"..d) end archivo:close() cprintf(cli.lightgreen, "\nTWorkers guardo la linea : %s\n",worker_Data() ); end