--=== Noobbotter's Bot Status Logger Userfunction ===-- --=== Version 1.1a ===-- --x-x bb moded with more info badges is arcanium coins Dly_item is not used yet. -- added tokens in bank+ bag and transmuter charges -- version 1.3 added player classes arcanium badges puries guildname .. call logplayer needs code to pass player class see next 2 lines. -- local classtable = {"WARRIOR", "SCOUT", "ROGUE", "MAGE", "PRIEST", "KNIGHT", "WARDEN", "WARDEN", "DRUID", "WARLOCK", "CHAMPION"} -- logPlayer(classtable[player.Class1],classtable[player.Class2]); 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 Badges Puris Charges Dly_item Empties Honor class1 class2 Guildname" -- 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 getbadges(arg) local amount, limit = RoMScript('GetPlayerPointInfo(3,3,"")') if arg == "max" then return limit end return amount or 0 end function logPlayer(_playrcla1,_playrcla2) 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 empties = inventory:itemTotalCount(0) local pot = 0 --- future add code to total up easy daily item materials. 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 badges = getbadges() local ch = RoMScript("GetMagicBoxEnergy()") local dahonor = getCurrency("honor") local GuildName = RoMScript("GetGuildInfo()") local newentry = string.format("%-17s %-13s %-5s %-7s %-11s %-6s %-6s %-5s %-5s %-5s %-7s %-6s %-5s %-5s %-9s %-9s %-17s",os.date(), player.Name, player.Level, add_comma(player.MaxHP), add_comma(gold), shells, add_comma(tokens), add_comma(mems), add_comma(badges), add_comma(puris), add_comma(ch), add_comma(pot), add_comma(empties), dahonor, _playrcla1, _playrcla2, GuildName) 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