Module:CropCalcs: Difference between revisions

From IdleOn MMO Wiki
mNo edit summary
mNo edit summary
Line 20: Line 20:
function crops.growtime(frame)
function crops.growtime(frame)
local baseindex  = typeindex(frame.args.Type)
local baseindex  = typeindex(frame.args.Type)
 
local sum = 14400 * math.pow(1.5, baseindex)
local days = floor(sum / 86400)
local hours = floor((sum % 86400) / 3600)
local minutes = floor((sum % 3600) / 60)
local seconds = 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
end



Revision as of 16:53, 26 February 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


function crops.growtime(frame)
	local baseindex  = typeindex(frame.args.Type)
	local sum = 14400 * math.pow(1.5, baseindex)
	local days = floor(sum / 86400)
	local hours = floor((sum % 86400) / 3600)
	local minutes = floor((sum % 3600) / 60)
	local seconds = 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 = frame.args.CropIndex
	local basechance = {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 basechance[baseindex] * math.pow(decay[baseindex], cropindex)
end

return crops