Module:CropCalcs: Difference between revisions

From IdleOn MMO Wiki
(Created page with "local crops = {} function crops.growtime(frame) local croptype = frame.args.Type local basechance = { basic = 0, earthy = 1, bulbo = 2, sushi = 3, mushie = 4, glassy = 5} end function crops.evochance(frame) local croptype = frame.args.Type local cropindex = frame.args.CropIndex local basechance = { basic = 0.3, earthy = 0.12, bulbo = 0.04, sushi = 0.01, mushie = 0.003, glassy = 0.0005 } local decay = { basic = 0.75, earthy = 0.63, bulbo = 0.3, sushi = 0.4, mus...")
 
mNo edit summary
 
(35 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local crops = {}
local crops = {}
local function typeindex(croptype)
if croptype == "basic" then
return 0
elseif croptype == "earthy" then
return 1
elseif croptype == "bulbo" then
return 2
elseif croptype == "sushi" then
return 3
elseif croptype == "mushie" then
return 4
elseif croptype == "glassy" then
return 5
end
end
local function sigFig(num,figures)
    local x=figures - math.ceil(math.log10(math.abs(num)))
    return(math.floor(num*10^x+0.5)/10^x)
end


function crops.growtime(frame)
function crops.growtime(frame)
local croptype = frame.args.Type
local baseindex = typeindex(frame.args.Type)
local basechance = { basic = 0, earthy = 1, bulbo = 2, sushi = 3, mushie = 4, glassy = 5}
local sum = 14400 * math.pow(1.5, baseindex)
local days = math.floor(sum / 86400)
local hours = math.floor((sum % 86400) / 3600)
local minutes = math.floor((sum % 3600) / 60)
local seconds = math.floor(sum % 60)
local ret = ""
if days > 0 then
ret = days .. "D "
end
if hours > 0 then
ret = ret .. hours .. "H "
end
if minutes > 0 then
ret = ret .. minutes .. "M "
end
if seconds > 0 then
ret = ret .. seconds .. "S"
end
return ret
end


function crops.evochance(frame)
local baseindex  = typeindex(frame.args.Type) +1
local cropindex = tonumber(frame.args.CropIndex)
local basechance = 0.3 --{0.3, 0.12, 0.04, 0.01, 0.003, 0.0005}
local decay = {0.75, 0.63, 0.3, 0.4, 0.2, 0.05 }
return sigFig((basechance * math.pow(decay[baseindex], cropindex)) * 100, 4) .. "%"
end
end


function crops.evochance(frame)
function crops.baseExp(frame)
local croptype  = frame.args.Type
local baseindex = typeindex(frame.args.Type)
local cropindex = frame.args.CropIndex
local cropindex = tonumber(frame.args.CropIndex)
local basechance = { basic = 0.3, earthy = 0.12, bulbo = 0.04, sushi = 0.01, mushie = 0.003, glassy = 0.0005 }
local baseXp = 5 + 25 * baseindex * math.pow(2, baseindex) * math.pow(1.25, cropindex)
local decay = { basic = 0.75, earthy = 0.63, bulbo = 0.3, sushi = 0.4, mushie = 0.2, glassy = 0.05 }
return basechance[croptype] * (decay[croptype] ^ cropindex)
    return math.floor(baseXp)
end
end


return crops
return crops

Latest revision as of 11:04, 30 March 2024

Documentation for this module may be created at Module:CropCalcs/doc

local crops = {}

local function typeindex(croptype)
	if croptype == "basic" then
		return 0
	elseif croptype == "earthy" then
		return 1
	elseif croptype == "bulbo" then
		return 2
	elseif croptype == "sushi" then
		return 3
	elseif croptype == "mushie" then
		return 4
	elseif croptype == "glassy" then
		return 5
	end
end

local function sigFig(num,figures)
    local x=figures - math.ceil(math.log10(math.abs(num)))
    return(math.floor(num*10^x+0.5)/10^x)
end

function crops.growtime(frame)
	local baseindex  = typeindex(frame.args.Type)
	local sum = 14400 * math.pow(1.5, baseindex)
	local days = math.floor(sum / 86400)
	local hours = math.floor((sum % 86400) / 3600)
	local minutes = math.floor((sum % 3600) / 60)
	local seconds = math.floor(sum % 60)
	local ret = ""
	if days > 0 then 
		ret = days .. "D " 
	end
	if hours > 0 then 
		ret = ret .. hours .. "H " 
	end
	if minutes > 0 then 
		ret = ret .. minutes .. "M " 
	end
	if seconds > 0 then 
		ret = ret .. seconds .. "S" 
	end
	
	return ret
end

function crops.evochance(frame)
	local baseindex  = typeindex(frame.args.Type) +1
	local cropindex = tonumber(frame.args.CropIndex)
	local basechance = 0.3 --{0.3, 0.12, 0.04, 0.01, 0.003, 0.0005}
	local decay = {0.75, 0.63, 0.3, 0.4, 0.2, 0.05 }
	
	return sigFig((basechance * math.pow(decay[baseindex], cropindex)) * 100, 4) .. "%"
end

function crops.baseExp(frame)
	local baseindex = typeindex(frame.args.Type)
	local cropindex = tonumber(frame.args.CropIndex)
	local baseXp = 5 + 25 * baseindex * math.pow(2, baseindex) * math.pow(1.25, cropindex)
	
    return math.floor(baseXp)
end

return crops