Egg Inc Wiki

A Lua script that automatically counts the number of available Eggs of Prophecy.

Usage[]

Parameters[]

  • date is the release date of the most recent contract that contains a PE. This date should be in UTC.
  • count is the total number of PEs that are available through contract, at the date of date.

Assumptions[]

The script assumes that a new contract with PE is released once every 3 weeks, on Mondays at 4pm UTC (or 8am Pacific Standard Time / 7am Pacific Daylight Time).

Methods[]

There are two methods available, contractPE returns the number of PEs available in contracts, and totalPE returns the total count, including those from daily gift calendar and trophies.

Examples[]

{{#invoke:ProphecyCounter|contractPE|date=2021-11-08|count=121}} returns 182.

{{#invoke:ProphecyCounter|totalPE|date=2021-11-08|count=121}} returns 246.


local invocable  = {}
local date = require("Dev:Date")

local WEEKS_BETWEEN_PE = 3
local NON_CONTRACT_PE_TOTAL = 64

function weeksSince(datestring)
	-- New contract is assumed to be released on 8am PST or 7am PDT.
	local past = date(datestring .. " 16:00Z") 

	local nowutc = date(true)

	return math.floor((nowutc-past):spandays() / 7)
end

function invocable.contractPE(frame)
	local count = frame.args["count"]
	local weeks =  weeksSince(frame.args["date"])
	return math.floor(weeks / WEEKS_BETWEEN_PE) + count
end

function invocable.totalPE(frame)
	return (invocable.contractPE(frame) + NON_CONTRACT_PE_TOTAL)
end

return invocable