--=== Noobbotter's Bot Status Logger Userfunction ===-- --=== Version 1.1a ===-- -- added tokens in bank+ bag and transmuter charges local logFileName = "scripts/rom/logs/BotSummary.txt" -- you can specify what filename or directory you want here. local fileheader = "Date/Time Name Level Max HP Gold Shells Tokens Mems Puris Charges" -- if you change this your columns may not align properly local function add_comma(n) local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end local function createLogfile(_filename) local file = io.open(_filename, "w") file:write(fileheader) file:close() -- never forget to close a file! print("New file Created\n") end function file_exists(_filename) local f=io.open(_filename,"r") if f~=nil then io.close(f) return true else return false end end function logPlayer() cprintf(cli.yellow,"Logging Player info to Log Summary \n") if not file_exists(logFileName) then print("No file found... creating one now\n") createLogfile(logFileName) end local readfile,err = io.open(logFileName,"r") if err then return err end local newfile = {} for line in readfile:lines() do --print(line) if not string.match(line, player.Name) then table.insert(newfile, line) end end local btokens = inventory:itemTotalCount(203038) local tokencount = 0 for slotnumber = 1,40 do local name, id, count, slot = bankItemBySlot(slotnumber) if id == 204874 then -- phirius tokens local tokencount = tokencount + count end end local tokens = btokens + tokencount readfile:close() local gold = RoMScript('GetPlayerMoney("copper");') local shells = getCurrency("shell") local tokens = inventory:itemTotalCount(203038) local puris = inventory:itemTotalCount("Purified Fusion Stone","itemshop") local mems = getCurrency("mems") local ch = RoMScript("GetMagicBoxEnergy()") local newentry = string.format("%-17s %-13s %-5s %-7s %-11s %-6s %-6s %-5s %-5s %-5s",os.date(), player.Name, player.Level, add_comma(player.MaxHP), add_comma(gold), shells, add_comma(tokens), add_comma(mems), puris, add_comma(ch)) table.insert(newfile,newentry) local writefile,err = io.open(logFileName,"w+") for k,v in pairs(newfile) do --printf("%s\n",v) writefile:write(v.."\n") end writefile:close() end