function file_exists(file) local f = io.open(file, "rb") if f then f:close() end return f ~= nil end function lines_from(file) if not file_exists(file) then return {} end local lines = {} for line in io.lines(file) do lines[#lines + 1] = line end return lines end function table_contains_element(table, element) for key, value in pairs(table) do if value == element then return true end end return false end function table_find_word(table, word) for key,value in ipairs(table) do for w in string.gmatch(value,"%a+") do if w == word then return true end end end return false end function comma_value(n) local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end function cprintn(color, string) cprintf(color, string.."\n") end function goto_wp(waypointTag) __WPL:setWaypointIndex(__WPL:findWaypointTag(waypointTag)) end function reload_wp_file() loadPaths(__WPL:getFileName()) end --[[ Daily Quest waypoint functions ]]-- function kill_stupid_newbie_pet() if player:findNearestNameOrId(113199) then -- search vicinity for Newbie Pet inventory:update() if (inventory:itemTotalCount(207051) > 0) then inventory:useItem(207051) local newbEgg = inventory:findItem(207051); -- Newbie Pet Egg if newbEgg ~= nil then inventory:deleteItemInSlot(newbEgg.SlotNumber) end end end end function save_daily_log(folder) local TODAY = os.date("%m_%d_%Y") local nameMaxLength = 16 -- hard in-game character limit for RoM player name local logpath = "/logs/"..folder.."/log_"..TODAY..".txt" local logfile = getExecutionPath()..logpath inventory:update() local tokenQty = inventory:itemTotalCount(203038) -- Employ spaces after the dividing hash mark so that token quantities line up perfectly local numspaces = 0 if 10 > tokenQty then numspaces = 3 elseif 100 > tokenQty then numspaces = 2 elseif 1000 > tokenQty then numspaces = 1 end -- Create and append data to log file (logs/elfdaily/daily_log_TODAY.txt) local file = io.open(logfile, "a+") -- append data to the end of log file local name = string.rep(" ", nameMaxLength - #player.Name)..player.Name if file then if table_find_word(lines_from(logfile), player.Name) then file:close() cprintf(cli.lightblue,"!! Data already exists in "..logpath.."\n") else -- file:write(name.." - "..string.rep(" ",numspaces)..tokenQty.." "..GetIdName(203038).."\n") file:write("Acc: "..string.format("%-16s",RoMScript("GetAccountName()")).."\tName: "..string.format("%-16s",player.Name).."\t"..GetIdName(203038)..": "..inventory:getItemCount(203038).."\n") file:close() cprintf(cli.lightblue,"Data saved to "..logpath.."\n") end else printf("Unable to open file to save\n") end end function sort_daily_log(folder) local TODAY = os.date("%m_%d_%Y") local nameMaxLength = 16 -- hard in-game character limit for RoM player name local logpath = "/logs/"..folder.."/log_"..TODAY..".txt" local logfile = getExecutionPath()..logpath local logdata = lines_from(logfile) table.sort(logdata) -- Remove old blank rows from current log so they don't pile up while table_contains_element(logdata,"") do for key,value in ipairs(logdata) do if value == "" then table.remove(logdata,key) end end end local sortfile = io.open(logfile,"w") -- overwrite contents of log file in place if sortfile then for key,value in ipairs(logdata) do sortfile:write(value.."\n") if key % 8 == 0 then sortfile:write("\n") -- Insert a blank line after 8 rows (one whole account) end end sortfile:close() cprintf(cli.yellow,"Data successfully cleaned and saved to "..logpath.."\n\n") else printf("Unable to open file to save\n\n") end end snoop = GetIdName(118002) -- NPC "Snoop the Stubborn" ailic = GetIdName(112051) -- NPC "Ailic's Aide" function take_snoop(snoopname, destination, _colon, _next) if player:findNearestNameOrId(snoopname) then player:target_NPC(snoopname) if _next == 1 then ChoiceOptionByName("Next Page") -- Varanas Snoop to certain destinations yrest(200) end if _colon == 1 then ChoiceOptionByName("Transport to: "..destination) -- Some have a colon and some don't else ChoiceOptionByName("Transport to "..destination) end local acceptCost = RoMScript("StaticPopup_Visible('SET_REQUESTDIALOG')") if acceptCost then RoMScript("StaticPopup_EnterPressed("..acceptCost..");") end cprintn(cli.lightblue, "Transporting via \""..snoopname.."\" to "..destination) waitForLoadingScreen() else error("Cannot find "..snoopname..", maybe you broke it!") end end function set_options(options, optionDescriptions) for i,v in ipairs(optionDescriptions) do cprintf(cli.lightblue, optionDescriptions[i]) while not options[i] do options[i] = io.stdin:read() options[i] = tonumber(options[i]) end end end function quest_check(quest, questCompleteWaypoint, _questWaypoint) if _questWaypoint then if getQuestStatus(quest) == "incomplete" then goto_wp(_questWaypoint) end end if getQuestStatus(quest) ~= "incomplete" then cprintf(cli.lightblue,"Quest \""..quest.."\" complete. Jumping to waypoint tag \""..questCompleteWaypoint.."\"\n") player:mount() goto_wp(questCompleteWaypoint) end end function quest_skip_if_complete(quest, nextWaypoint) -- if the quest hasn't been accepted, then the player must have already done it or something else has gone wrong. if getQuestStatus(quest) ~= "incomplete" then goto_wp(nextWaypoint) end end