FANDOM


local lang = mw.getContentLanguage()
local p = {}
 
local AC_MONTHS = { -- Bidirectional table for converting months and numbers to each other
	"January",
	"February",
	"March",
	"April",
	"May",
	"June",
	"July",
	"August",
	"September",
	"October",
	"November",
	"December",
	["January"]=1,
	["February"]=2,
	["March"]=3,
	["April"]=4,
	["May"]=5,
	["June"]=6,
	["July"]=7,
	["August"]=8,
	["September"]=9,
	["October"]=10,
	["November"]=11,
	["December"]=12
}
 
--[==[
The DATA table is formatted as follows:
DATA = {[Collectable type name 1] = Collectable type 1 data, [Collectable type name 2] = collectable type 2 data, ...}
 
Each collectable type (e.g. Fish, Bugs, Seafood, etc) have their own data which is formatted as follows:
Collectable type data = {[creature name 1] = creature 1 appearances, [creature name 2] = creature 2 appearances}
 
Creature appearances holds an array of all of its appearance data.
 
Note that collectibles with different times each month such as the violin beetle need MULTIPLE appearances, one for each unique time.
 
Appearance data = {Location, Sell Price, Array of months that it appears in, Text for time, Array of all the games it appears in}
]==]
 
local DATA = {
	["Fish"] = {
		["Angelfish"] = { {"River",1000,{5,6,7,8,9,10},"4pm - 9am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Arapaima"] = { {"River",10000,{6,7,8,9},"4pm - 9am",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Arowana"] = { {"River",10000,{6,7,8,9},"4pm - 9am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Barbel Steed"] = { {"River",200,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Barred Knifejaw"] = { {"Ocean",5000,{3,4,5,6,7,8,9,10,11},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Bass"] = { {"River",300,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+"}} },
		["Bitterling"] = { {"River",900,{1,2,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Black Bass"] = { {"River",300,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"WW","CF","NL"}} },
		["Blowfish"] = { {"Ocean",125,{1,2,11,12},"All day",{"NL"}} },
		["Blue Marlin"] = { {"Ocean",10000,{6,7,8,9},"All day",{"AFe+","WW","CF","NL"}} },
		["Bluegill"] = { {"River",300,{1,2,3,4,5,6,7,8,9,10,11,12},"9am - 4pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Brook Trout"] = { {"Pool",150,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AC","AFe+"}} },
		["Butterfly fish"] = { {"Ocean",1000,{4,5,6,7,8,9},"All day",{"CF","NL"}} },
		["Carp"] = { {"River",300,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Catfish"] = { {"Pool",800,{5,6,7,8,9,10},"4pm - 9am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Char"] = { {"Waterfall",3800,{3,4,5,6,9,10,11},"4am - 9am, 4pm - 9pm",{"WW","CF","NL"}} },
		["Cherry Salmon"] = { {"River",1000,{3,4,5,6,9,10,11},"4am - 9am, 4pm - 9pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Clownfish"] = { {"Ocean",650,{4,5,6,7,8,9},"All day",{"WW","CF","NL"}} },
		["Coelacanth"] = { {"Ocean (rain)",15000,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Crawfish"] = { {"Pond",250,{4,5,6,7,8,9},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Crucian Carp"] = { {"River",120,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Dab"] = { {"Ocean",300,{1,2,3,4,10,11,12},"All day",{"AF+","AFe+","WW","CF","NL"}} },
		["Dace"] = { {"River",200,{1,2,3,4,5,6,7,8,9,10,11,12},"4pm - 9am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Dorado"] = { {"River",15000,{6,7,8,9},"4am - 9pm",{"WW","CF","NL"}} },
		["Eel"] = { {"River",2000,{6,7,8,9},"4pm - 9am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Football Fish"] = { {"Ocean",2500,{1,2,3,11,12},"4pm - 9am",{"WW","CF","NL"}} },
		["Freshwater Goby"] = { {"River",300,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Frog"] = { {"Pond",120,{5,6,7,8},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Gar"] = { {"Pool",6000,{6,7,8,9},"4pm - 9am",{"WW","CF","NL"}} },
		["Giant Catfish"] = { {"Pool",3000,{6,7,8,9},"4pm - 9am",{"AF","AC","AF+","AFe+"}} },
		["Giant Snakehead"] = { {"Pool",5500,{6,7,8},"9am - 4pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Giant Trevally"] = { {"Island",4500,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Goldfish"] = { {"River",1300,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Guppy"] = { {"River",1300,{4,5,6,7,8,9,10,11},"9am - 4pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Hammerhead Shark"] = { {"Ocean",8000,{6,7,8,9},"4pm - 9am",{"WW","CF","NL"}} },
		["Herabuna"] = { {"River",300,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AF+"}} },
		["Horse Mackerel"] = { {"Ocean",150,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AFe+","WW","CF","NL"}} },
		["Jellyfish"] = { {"Ocean",100,{8},"All day",{"AC","AF+","AFe+","WW","CF"}} },
		["Killifish"] = { {"Pond",300,{4,5,6,7,8},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["King Salmon"] = { {"River",1800,{9},"All day",{"WW","CF","NL"}} },
		["Koi"] = { {"River",4000,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Large Bass"] = { {"River",3000,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+"}} },
		["Loach"] = { {"River",300,{3,4,5},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Lobster"] = { {"Ocean",2500,{1,2,11,12},"All day",{"CF"}} },
		["Mitten Crab"] = { {"River",2000,{9,10,11},"4pm - 9am",{"NL"}} },
		["Moray Eel"] = { {"Ocean",2000,{8,9,10},"All day",{"CF","NL"}} },
		["Napoleonfish"] = { {"Ocean",10000,{7,8},"All day",{"CF","NL"}} },
		["Nibble Fish"] = { {"River",1200,{5,6,7,8,9},"9am - 4pm",{"NL"}} },
		["Neon Tetra"] = { {"River",500,{4,5,6,7,8,9,10,11},"9am - 4pm",{"CF","NL"}} },
		["Oarfish"] = { {"Ocean",9000,{1,2,3,4,5,12},"All day",{"NL"}} },
		["Ocean Sunfish"] = { {"Ocean",4000,{6,7,8,9},"4am - 9pm",{"WW","CF","NL"}} },
		["Octopus"] = { {"Ocean",500,{3,4,5,6,7,1,9,10,11,12},"All day",{"AFe+","WW","CF"}} },
		["Olive Flounder"] = { {"Ocean",800,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AFe+","WW","CF","NL"}} },
		["Pale Chub"] = { {"River",160,{1,2,3,4,5,6,7,8,9,10,11,12},"9am - 4pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Pike"] = { {"River",1800,{9,10,11,12},"4am - 9pm",{"CF","NL"}} },
		["Piranha"] = { {"River",2500,{6,7,8,9},"9am - 4pm, 9pm - 4am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Popeyed Goldfish"] = { {"River",1300,{1,2,3,4,5,6,7,8,9,10,11,12},"9am - 4pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Pond Smelt"] = { {"River",300,{1,2,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Puffer fish"] = { {"Ocean",240,{7,8,9},"All day",{"AFe+","WW","CF","NL"}} },
		["Rainbow Trout"] = { {"River",800,{3,4,5,6,9,10,11},"4am - 9am, 4pm - 9pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Ray"] = { {"Ocean",3000,{8,9,10,11,12},"All day",{"CF","NL"}} },
		["Red Snapper"] = { {"Ocean",3000,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Ribbon Eel"] = { {"Island",600,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Saddled Bichir"] = { {"River",4000,{6,7,8,9},"9pm - 4am",{"NL"}} },
		["Salmon"] = { {"River",700,{9},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Saw Shark"] = { {"Ocean",12000,{6,7,8,9},"4pm - 9am",{"NL"}} },
		["Sea Bass"] = { {"Ocean",200,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Sea Butterfly"] = { {"Ocean",1000,{1,2,12},"All day",{"WW","CF","NL"}} },
		["Seahorse"] = { {"Ocean",1100,{4,5,6,7,8,9,10,11},"All day",{"AFe+","WW","CF","NL"}} },
		["Shark"] = { {"Ocean",15000,{6,7,8,9},"4pm - 9am",{"WW","CF","NL"}} },
		["Small Bass"] = { {"River",200,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+"}} },
		["Soft-shelled Turtle"] = { {"River",3750,{8,9},"4pm - 9am",{"NL"}} },
		["Squid"] = { {"Ocean",400,{1,2,3,4,5,6,7,8,12},"All day",{"AFe+","WW","CF","NL"}} },
		["Stringfish"] = { {"River",15000,{1,2,12},"4pm - 9am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Surgeonfish"] = { {"Ocean",1000,{4,5,6,7,8,9},"All day",{"CF","NL"}} },
		["Sweetfish"] = { {"River",900,{7,8,9},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Tadpole"] = { {"Pond",100,{3,4,5,6,7},"All day",{"NL"}} },
		["Tuna"] = { {"Ocean",7000,{1,2,3,11,12},"All day",{"WW","CF","NL"}} },
		["Whale Shark"] = { {"Island",13000,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Yellow Perch"] = { {"River",240,{1,2,3,11,12},"All day",{"WW","CF","NL"}} },
		["Zebra Turkeyfish"] = { {"Ocean",400,{4,5,6,7,8,9,10,11},"All day",{"WW","CF","NL"}} }
	},
	["Bugs"] = {
		["Agrias Butterfly"] = { {"Near flowers",3000,{6,7,8,9},"8am - 5pm",{"WW","CF","NL"}} },
		["Ant"] = { {"On rotten turnips, rotten fruit and candy",80,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Horned Atlas"] = { {"On palm trees",8000,{6,7,8},"7pm - 8am",{"WW","CF","NL"}} },
		["Bagworm"] = { {"Shake trees",300,{1,2,10,11,12},"7pm - 8am",{"AC","AF+","AFe+","CF","NL"}} },
		["Banded Dragonfly"] = { {"Flying",4500,{7,8},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Bee"] = { {"Shake trees",2000,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Bell Cricket"] = { {"On the ground",430,{9,10},"5pm - 8am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Birdwing Butterfly"] = { {"Near flowers",4000,{6,7,8,9},"8am - 5pm",{"WW","CF","NL"}} },
		["Brown Cicada"] = { {"On trees",200,{7,8},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Centipede"] = { {"Under rocks",300,{1,2,6,7,8,9,10,11,12},"4pm - 11pm",{"CF","NL"}} },
		["Cicada shell"] = { {"On trees",100,{7,8},"All day",{"NL"}} },
		["Cockroach"] = { {"On trees, turnips and flowers.(GCN, WW)",5,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AF","AC","AF+","AFe+","WW"}} },
		["Coconut Crab"] = { {"Shake native palm trees (they do not appear on the island)",300,{6,7,8,9},"7pm - 8am",{"AF","AC","AF+","AFe+"}} },
		["Common Butterfly"] = { {"Near flowers",90,{3,4,5,6,7,8,9},"4am - 7pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Common Dragonfly"] = { {"Flying",130,{5,6,7},"8am - 5pm",{"AF","AC","AF+","AFe+"}} },
		["Crab"] = { {"On the beach",150,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AFe+"}} },
		["Cricket"] = { {"On the ground",130,{9,10,11},"5pm - 8am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Cyclommatus Stag"] = { {"On palm trees",8000,{7,8},"5pm - 8am",{"CF","NL"}} },
		["Darner Dragonfly"] = { {"Flying",200,{6,7,8},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Diving Beetle"] = { {"In the river",800,{5,6,7,8,9},"8am - 5pm",{"AFe+","CF","NL"}} },
		["Drone Beetle"] = { {"On rotten turnips",80,{7,8},"All day",{"AF","AC"}} },
		["Dung Beetle"] = { {"Rolling snowballs",800,{1,2,12},"5pm - 8am",{"AFe+","WW","CF","NL"}} },
		["Horned Dynastid"] = { {"On trees",1350,{7,8},"5pm - 8am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Horned Elephant"] = { {"On palm trees",8000,{7,8},"7pm - 8am",{"WW","CF","NL"}} },
		["Emperor Butterfly"] = { {"Near flowers",2500,{7,8,9},"5pm - 8am",{"WW","CF","NL"}} },
		["Evening Cicada"] = { {"On trees",550,{7,8},"4am - 8am, 4pm - 7pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Firefly"] = { {"Near the river",300,{6},"7pm - 4am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Flea"] = { {"On villagers",70,{3,4,5,6,7,8,9,10,11},"All day",{"AFe+","WW","CF","NL"}} },
		["Fly"] = { {"Near garbage",60,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"WW","CF","NL"}} },
		["Fruit Beetle"] = { {"On trees",100,{7,8,9},"All day",{"WW","CF","NL"}} },
		["Giant Stag"] = { {"On trees",10000,{6,7,8},"11pm - 8am",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Giant Cicada"] = { {"On trees",500,{7,8},"8am - 5pm",{"NL"}} },
		["Petaltail Dragonfly"] = { {"Flying",8000,{8,9,10},"4pm - 7pm",{"CF","NL"}} },
		["Golden Stag"] = { {"On palm trees",12000,{7,8},"5pm - 8am",{"CF","NL"}} },
		["Goliath Beetle"] = { {"On palm trees",6000,{6,7,8},"5pm - 8am",{"WW","CF","NL"}} },
		["Grasshopper"] = { {"On the ground",160,{7,8,9},"9am - 4pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Horned Hercules"] = { {"On palm trees",12000,{7,8},"7pm - 4am",{"WW","CF","NL"}} },
		["Hermit Crab"] = { {"disguised as seashells",1000,{1,2,3,4,5,6,7,8,9,10,11,12},"7pm - 8am",{"AFe+","NL"}} },
		["Honeybee"] = { {"Near flowers",100,{3,4,5,6,7},"8am - 5pm",{"WW","CF","NL"}} },
		["House Centipede"] = { {"Under rocks",250,{8,9,10},"7pm - 8am",{"NL"}} },
		["Jewel Beetle"] = { {"On trees",2400,{7,8},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Ladybug"] = { {"On flowers",130,{3,4,5,6,7,10},"8am - 5pm",{"AF","AC","AF+","AFe+"}} },
		["Lantern Fly"] = { {"On trees",1800,{6,7,8,9},"4pm - 7pm, 11pm - 8am",{"WW","CF","NL"}} },
		["Long Locust"] = { {"On the ground",200,{5,6,7,8,9,10,11},"8am - 7pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Longhorn Beetle"] = { {"On tree stumps",260,{6,7,8},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Mantis"] = { {"On flowers",430,{4,5,6,7,8,9,10,11},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Migratory Locust"] = { {"On the ground",600,{8,9,10,11},"8am - 7pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Miyama Stag"] = { {"On trees",1000,{6,7,8},"All day",{"CF","NL"}} },
		["Mole Cricket"] = { {"Under the ground",280,{1,2,3,4,5,11,12},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Monarch Butterfly"] = { {"Near flowers",140,{9,10,11},"All day",{"WW","CF","NL"}} },
		["Mosquito"] = { {"Flying",130,{6,7,8,9},"5pm - 4am",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Moth"] = { {"Near lights",60,{5,6,7,8,9},"7pm - 4am",{"WW","CF","NL"}} },
		["Mountain Beetle"] = { {"On trees",2000,{7,8},"7pm - 8am",{"AF","AC","AF+","AFe+"}} },
		["Oak Silk Moth"] = { {"On trees",1200,{6,7,8,9},"7pm - 4am",{"WW","CF","NL"}} },
		["Orchid Mantis"] = { {"On white flowers",2400,{4,5,6,7,8,9,10,11},"8am - 5pm",{"WW","CF","NL"}} },
		["Peacock Butterfly"] = { {"On purple, black and blue flowers",220,{3,4,5,6,7,8,9},"8am - 5pm",{"WW","CF","NL"}} },
		["Pill Bug"] = { {"Under rocks",250,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Pine Cricket"] = { {"On the ground",100,{9,10},"5pm - 8am",{"AF","AC","AF+","AFe+"}} },
		["Pondskater"] = { {"On ponds",130,{5,6,7,8,9},"8am - 7pm",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Purple Butterfly"] = { {"Near flowers",2000,{6,7,8},"8am - 5pm",{"AF","AC","AF+","AFe+"}} },
		["Rainbow Stag"] = { {"On trees",10000,{6,7,8,9},"7pm - 8am",{"WW","CF","NL"}} },
		["Raja Brooke Butterfly"] = {
			{"Near flowers",2500,{5,7},"8am - 5pm",{"CF","NL"}},
			{"Near flowers",2500,{6,8,9},"8am - 7pm",{"CF","NL"}}
			},
		["Red Dragonfly"] = { {"Flying",80,{9,10},"8am - 7pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Rice Grasshopper"] = { {"On the ground",400,{8,9,10,11},"8am - 7pm",{"NL"}} },
		["Robust Cicada"] = { {"On trees",300,{7,8},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Saw Stag"] = { {"On trees",2000,{7,8},"All day",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Scarab Beetle"] = { {"On trees",6000,{7,8},"11pm - 8am",{"WW","CF","NL"}} },
		["Scorpion"] = { {"On the ground",8000,{7,8,9},"7pm - 4am",{"WW","CF","NL"}} },
		["Snail"] = { {"On flowers (rain)",250,{4,5,6,7,8,9},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Spider"] = { {"Shake trees",300,{3,4,5,6,7,8,9,10},"All day",{"AC","AF+","AFe+","WW","CF","NL"}} },
		["Spotted Ladybug"] = { {"On flowers",200,{3,4,5,6,10},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Stag Beetle"] = { {"On trees",2000,{6,7,8},"7pm - 8am",{"AF","AC","AF+","AFe+","WW"}} },
		["Stinkbug"] = { {"On trees",120,{4,5,6,7,8,9,10},"All day",{"NL"}} },
		["Tarantula"] = { {"On the ground",8000,{6,7,8},"7pm - 4am",{"WW","CF","NL"}} },
		["Tiger Beetle"] = { {"On the ground (island)",1500,{3,4,5,6,7,8,9,10},"8am - 7pm",{"NL"}} },
		["Tiger Butterfly"] = { {"Near red flowers",160,{3,4,5,6,7,8,9},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Violin Beetle"] = {
			{"On tree stumps",250,{6},"4am - 7pm",{"CF","NL"}},
			{"On tree stumps",250,{9,10},"4am - 5pm",{"CF","NL"}},
			{"On tree stumps",250,{11},"8am - 5pm",{"CF","NL"}}
			},
		["Walker Cicada"] = { {"On trees",400,{7,8,9},"8am - 5pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} },
		["Walking stick"] = { {"On trees",600,{7,8,9,10,11},"4am - 7pm",{"WW","CF","NL"}} },
		["Walking Leaf"] = { {"On the ground, beside trees",600,{7,8,9},"4am - 7pm",{"CF","NL"}} },
		["Wharf Roach"] = { {"On the beach",200,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Yellow Butterfly"] = { {"Flying",80,{3,4,5,6,9},"4am - 7pm",{"AF","AC","AF+","AFe+","WW","CF","NL"}} }
	},
	["Deep-sea creatures"] = {
		["Abalone"] = { {"Ocean",400,{1,2,3,4,5,6,7,8,9,10,11,12},"4pm - 9am",{"NL"}} },
		["Acorn Barnacle"] = { {"Ocean",200,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Chambered Nautilus"] = { {"Ocean",900,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Clam"] = { {"Ocean",400,{1,2,3,4,9,10,11,12},"All day",{"NL"}} },
		["Ear Shell"] = { {"Ocean",300,{1,2,3,4,5,6,7,8,9,10,11,12},"4pm - 9am",{"NL"}} },
		["Flatworm"] = { {"Ocean",200,{6,7,8,9},"4pm - 9am",{"NL"}} },
		["Giant Isopod"] = { {"Island",9000,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Horsehair Crab"] = { {"Ocean",4000,{1,2,3,4,11,12},"All day",{"NL"}} },
		["Horseshoe Crab"] = { {"Ocean",1500,{7,8,9},"9pm - 4am",{"NL"}} },
		["Lobster"] = { {"Ocean",2500,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Mantis Shrimp"] = { {"Ocean",1250,{1,2,3,4,5,6,7,8,9,10,11,12},"4pm - 9am",{"NL"}} },
		["Octopus"] = { {"Ocean",1000,{1,9,10,11,12,3,4,5,6,7},"All day",{"NL"}} },
		["Oyster"] = { {"Ocean",400,{1,2,9,10,11,12},"All day",{"NL"}} },
		["Pearl Oyster"] = { {"Ocean",1600,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Red King Crab"] = { {"Ocean",6000,{1,2,3,11,12},"All day",{"NL"}} },
		["Spiny Lobster"] = { {"Ocean",3000,{9,10,11,12},"4pm - 9am",{"NL"}} },
		["Scallop"] = { {"Ocean",1000,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Sea Anemone"] = { {"Ocean",100,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Sea Cucumber"] = { {"Ocean",150,{1,2,3,4,11,12},"All day",{"NL"}} },
		["Sea Grapes"] = { {"Ocean",600,{6,7,8,9},"All day",{"NL"}} },
		["Sea Slug"] = { {"Ocean",200,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Sea Star"] = { {"Ocean",100,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Sea Urchin"] = { {"Ocean",800,{5,6,7,8,9},"All day",{"NL"}} },
		["Seaweed"] = { {"Ocean",200,{1,2,3,4,5,6,7,11,12},"All day",{"NL"}} },
		["Snow Crab"] = { {"Ocean",4000,{1,2,3,4,11,12},"All day",{"NL"}} },
		["Spider Crab"] = { {"Ocean",10000,{3,4},"All day",{"NL"}} },
		["Spotted Garden Eel"] = { {"Island",600,{1,2,3,4,5,6,7,8,9,10,11,12},"All day",{"NL"}} },
		["Sweet Shrimp"] = { {"Ocean",650,{1,2,9,10,11,12},"4pm - 9am",{"NL"}} },
		["Tiger Prawn"] = { {"Ocean",1600,{6,7,8,9},"4pm - 9am",{"NL"}} },
		["Turban Shell"] = { {"Ocean",300,{1,2,3,4,5,8,9,10,11,12},"4pm - 9am",{"NL"}} } 
	}
}
 
local GAMES = {"AF", "AF+", "AC", "AFe+", "WW", "CF", "NL"}
local ALL_YEAR = {1,2,3,4,5,6,7,8,9,10,11,12}
 
local function arrayContains(array, element) -- Function that checks to see if an array contains an element. Not for hash tables
	for i=1,#array do
		if array[i] == element then
			return true
		end
	end
	return false
end
 
local function arraysAreEqual(a1, a2) -- Function that checks to see if two arrays have the same elements. Not for hash tables
	for i=1,math.max(#a1,#a2) do
		if a1[i] ~= a2[i] then
			return false
		end
	end
	return true
end
 
function p.main(frame)
	-- This is the month all collectables will be listed for.
	local target_month = tonumber(frame.args[1]) or AC_MONTHS[frame.args[1]] or AC_MONTHS[mw.title.getCurrentTitle().baseText] or tonumber(os.date("%m"))
 
	local game_colors = {} -- An array parallel to the GAMES array that holds their light color, for the table
	for i=1,#GAMES do
		game_colors[i] = frame:expandTemplate{ title = "Color", args = {mw.ustring.lower( GAMES[i] ).. " color light"} }
	end
 
	local collectablesTable = mw.html.create("table")
		:addClass("wikitable")
		:css("text-align","center")
		:css("width","100%")
 
	for creature_type,creatures in pairs(DATA) do
		collectablesTable:tag("tr"):tag("th")
			:attr("colspan",4+#GAMES)
			:css("color","white")
			:css("background","#".. frame:expandTemplate{ title = "Color", args = {mw.ustring.lower( creature_type ).. " color"} })
			:css("font-weight","bold")
			:wikitext(creature_type)
		local tr = collectablesTable:tag("tr")
		tr:tag("th"):attr("rowspan",2):wikitext("Name")
		tr:tag("th"):attr("rowspan",2):wikitext("Location")
		tr:tag("th"):attr("rowspan",2):css("width","3.5em"):wikitext("Sale price")
		tr:tag("th"):attr("rowspan",2):wikitext("Time of day")
		tr:tag("th"):attr("colspan",#GAMES):wikitext("Games")
 
		tr = collectablesTable:tag("tr")
		for i=1,#GAMES do
			tr:tag("th")
				:css("background","#"..game_colors[i])
				:css("font-size","small")
				:css("width","1em")
				:wikitext(GAMES[i])
		end
 
		-- Get the keys and sort them alphabetically
		local keys = {}
		for k,_ in pairs(creatures) do
			keys[#keys + 1] = k
		end
		table.sort(keys)
 
		--Iterate over each creature in alphabetical order
 
		for i=1,#keys do
			local creature = keys[i]
			local appearances = creatures[creature]
			local allMonthAppearances = {}
			local first_months = {}
			local last_months = {}
			do
				local keys = {}
				for k=1,#appearances do
					local months = appearances[k][3] or {}
					for i=1,#months do
						keys[months[i]] = true
					end
				end
				for m,_ in pairs(keys) do
					allMonthAppearances[#allMonthAppearances+1] = m
				end
				table.sort(allMonthAppearances)
			end
 
			if arraysAreEqual(allMonthAppearances, ALL_YEAR) then
				first_months = {0}
				last_months = {0}
			elseif #allMonthAppearances > 0 then
				local i = 1
				while (allMonthAppearances[i-1] or allMonthAppearances[#allMonthAppearances]) == (((allMonthAppearances[i]+10)%12)+1) do
					i = ((i+(#allMonthAppearances-2))%#allMonthAppearances)+1
				end
 
				local end_loop_index = i
 
				repeat
					while (allMonthAppearances[i+1] or allMonthAppearances[1]) == (((allMonthAppearances[i]%12)+1)) do
						i = (i%#allMonthAppearances)+1
					end
					last_months[#last_months+1] = allMonthAppearances[i]
 
					i = (i%#allMonthAppearances)+1
					first_months[#first_months+1] = allMonthAppearances[i]
				until i == end_loop_index
			end
 
			for k=1,#appearances do
				local appearance = appearances[k]				
				if arrayContains(appearance[3], target_month) then			
					local tr = collectablesTable:tag("tr")
 
					local nameCell = tr:tag("td"):wikitext("[["..creature.."]]")
					if arrayContains(first_months, target_month) then
						nameCell:css("font-weight","bold")
					end
					if arrayContains(last_months, target_month) then
						nameCell:css("background","#FFC0C0")
					end
 
					tr:tag("td"):wikitext(appearance[1])
					tr:tag("td"):wikitext(lang:formatNum(appearance[2]))
					tr:tag("td"):wikitext(appearance[4])
					for i=1,#GAMES do
						local gameCell = tr:tag("td"):css("background","#"..game_colors[i])
						if arrayContains(appearance[5], GAMES[i]) then
							gameCell:wikitext("✓")
						end
					end
				end
			end
		end
	end
 
	collectablesTable:tag("tr"):tag("td")
		:attr("colspan",4+#GAMES)
		:css("padding-left","2em")
		:css("padding-right","2em")
		:wikitext([==['''Notes''': Location, price, and time, comes from the collectible's most recent appearance. For older information, please see that collectible's individual page. The flat stag beetle is listed under [[stag beetle]], the [[Ladybug]] from ''Wild World'' and later is listed under [[Spotted ladybug]] and the water beetle is listed under [[Diving beetle]]. A '''bold name''' indicates that collectible makes its first appearance that month. A <span style="background-color:#FFC0C0;color:black;">red background</span> indicates that collectible will not be available in the next month. Collectibles that are available on <i>New Leaf</i>'s [[Tortimer Island|Island]] are not listed if they do not appear in the town in this month, however, island-exclusive collectibles such as the [[whale shark]] are listed for every month.<br>Please report any errors to [[Module talk:MonthCollectables]].]==])
 
	return "<b>Note: this table has not yet been updated for New Horizons</b>" .. tostring(collectablesTable)
end
return p
Community content is available under CC-BY-SA unless otherwise noted.