Module:Schedule

From Palia Wiki
Jump to navigation Jump to search
Time Villager Description
12:00 AM Auni Profile.png Auni Goes to sleep.
Einar Profile.png Einar Walking home.
Eshe Profile.png Eshe Starts to walk back to the Mayor's Estate.
Jel Profile.png Jel Walks through the field outside of town towards the Fisherman's Lagoon.
Nai'o Profile.png Nai'o Leaves Ormuu pen and goes to bed.
Reth Profile.png Reth Goes to The Underground
Sifuu Profile.png Sifuu Walks home to sleep.
Tamala Profile.png Tamala Walks to her house.
12:45 AM Einar Profile.png Einar Sleeping.
1:00 AM Delaila Profile.png Delaila Leaves the Tavern.
Jel Profile.png Jel Walks towards the Mayor's Estate down on the coast.
1:19 AM Eshe Profile.png Eshe Enters her room in the Mayor's Estate.
1:30 AM Jel Profile.png Jel Turns and walks over the boardwalk.
2:00 AM Jel Profile.png Jel Stands near the tree on the little island.
Tamala Profile.png Tamala Making potions in her house.
2:30 AM Zeki Profile.png Zeki Leaves The Underground to walk home.
2:34 AM Delaila Profile.png Delaila Reaches home.
3:00 AM Chayne Profile.png Chayne Wakes up and walks to the Dragon Shrine
Einar Profile.png Einar Walking to the Fisherman's Lagoon to fish all day.
Hassian Profile.png Hassian Walks from Hassian's Grove to the pond in Hideaway Bluffs.
Hekla Profile.png Hekla Wakes up and looks at ruins outside Jina's locked ruin.
Jina Profile.png Jina Looks at ruins outside her locked ruin.
Kenyatta Profile.png Kenyatta Walks back to the Mayor's Estate to sleep.
Tau Profile.png Tau Walking from Hassian's Grove to the pond in Hideaway Bluffs.
4:00 AM Auni Profile.png Auni Wakes up and walks to the town square.
Badruu Profile.png Badruu Wakes up, and walks out to the farm.
Delaila Profile.png Delaila Gets up and walks to the hay near the Ormuu pen at the farm.
Elouisa Profile.png Elouisa Wakes up and goes to riverbank south of Mirror Fields (Map grid section D-6).
Eshe Profile.png Eshe Exits her room in the Mayor's Estate.
Hodari Profile.png Hodari Goes to the kitchen in Hodari and Najuma's House.
Jel Profile.png Jel Turns around and goes back towards the Fisherman's Lagoon.
Nai'o Profile.png Nai'o Leaves bedroom and walks to Ormuu pen near Badruu's Barn.
Reth Profile.png Reth Leaves The Underground from his storeroom
Sifuu Profile.png Sifuu Wakes up and goes to ruins southwest of Kilima Village.
Tamala Profile.png Tamala Goes to her bedroom.
5:00 AM Ashura Profile.png Ashura Goes upstairs in the Tavern to sleep.
Caleri Profile.png Caleri Wakes up and starts her shift at the library, behind the desk.
Eshe Profile.png Eshe Arrives at Elouisa and Caleri's House and stands in front of it.
Hodari Profile.png Hodari Walks over to workshop, northeast of the house.
Jel Profile.png Jel Turns towards town.
Kenli Profile.png Kenli Wakes up and heads to the back garden of the Mayor's Estate.
Najuma Profile.png Najuma Walks to her room to sleep.
Reth Profile.png Reth Standing in the path behind the Tailor shop
6:00 AM Jel Profile.png Jel Walks through town and into the Tailor shop.
Tish Profile.png Tish Waking up, leaves her house
6:30 AM Tish Profile.png Tish Stands near the Apothecary
7:00 AM Eshe Profile.png Eshe Leaves the front of Elouisa and Caleri's House and starts to walk towards the City Hall.
Jel Profile.png Jel Goes to his room to sleep.
Kenyatta Profile.png Kenyatta Walks to the City Hall to work.
8:00 AM Ashura Profile.png Ashura Exercises upstairs in the Tavern.
Chayne Profile.png Chayne Walks over to the Apothecary
Hassian Profile.png Hassian Leaves the pond and walks to Kilima Valley.
Reth Profile.png Reth Walks to the Tavern and starts work
Tamala Profile.png Tamala Wakes up and makes potions in her house.
Tau Profile.png Tau Kilima Valley - Crossing between windmills.
Zeki Profile.png Zeki Waking up to walk to and run the General Store for the day.
8:01 AM Hassian Profile.png Hassian Appears in Kilima Valley and walks to Chapaa Crossing fields between windmills.
8:15 AM Eshe Profile.png Eshe Arrives at her office in the City Hall and waits behind the desk.
8:30 AM Tish Profile.png Tish Stands near a big tree close to Fisherman's Lagoon
9:00 AM Badruu Profile.png Badruu Walks over to the farm shop.
Jel Profile.png Jel Goes down into the Tailor shop.
Kenli Profile.png Kenli Walks to City Hall.
Tish Profile.png Tish Walks to the Furniture Store
10:00 AM Ashura Profile.png Ashura Walks to fishing spot northwest of the village.
Auni Profile.png Auni Walks east of town to a windmill.
Elouisa Profile.png Elouisa Walks over to the ruins north of Fisherman's Lagoon.
Hodari Profile.png Hodari Going to Kilima Valley.
Jel Profile.png Jel Stands in the Tailor shop.
Kenli Profile.png Kenli Naps in his office.
Nai'o Profile.png Nai'o Leaves Ormuu pen and walks to Kilima Central Stables.
Najuma Profile.png Najuma Wakes up and walks to the east side of the pond near her house.
Sifuu Profile.png Sifuu Walks up to the Blacksmith.
10:01 AM Hodari Profile.png Hodari Appearing in Kilima Valley and going in to the Tavern.
11:00 AM Eshe Profile.png Eshe Moves from her office in the City Hall to the balcony of the City Hall.
12:00 PM Delaila Profile.png Delaila Walks from the Ormuu pen at the farm to the General Store.
Hekla Profile.png Hekla Walks to the Night Sky Temple.
Jina Profile.png Jina Walks to the Night Sky Temple.
Tamala Profile.png Tamala Walks to stand west of Flooded Steps.
1:00 PM Badruu Profile.png Badruu Walks over to the Tavern.
Eshe Profile.png Eshe Starts to walk towards the end of the bridge at the exit of Kilima Village between the Tavern and the Tailor.
1:49 PM Delaila Profile.png Delaila Reaches the General Store.
2:00 PM Ashura Profile.png Ashura Walks to Remembrance Garden for Sabine.
Auni Profile.png Auni Heads to the Tavern.
Eshe Profile.png Eshe Arrives at the end of the bridge at the exit of Kilima Village between the Tavern and the Tailor.
Hassian Profile.png Hassian Walks to the Tavern's porch.
Hodari Profile.png Hodari Going back to Bahari Bay.
Tau Profile.png Tau Walks to the porch behind the Tavern.
2:01 PM Hodari Profile.png Hodari Appearing in Bahari Bay and going over to the mines southeast of Pavel Mines.
3:00 PM Auni Profile.png Auni Stands on the back porch of the Tavern.
Elouisa Profile.png Elouisa Walks to Library.
Hekla Profile.png Hekla Walks towards the Library.
Jina Profile.png Jina Walks towards the Library.
4:00 PM Najuma Profile.png Najuma Walks to her workshop.
Sifuu Profile.png Sifuu Walks into the eating area in the Tavern.
Tamala Profile.png Tamala Walks to stand north of Bahari Central Stables.
5:00 PM Ashura Profile.png Ashura Walks to the Tavern counter for work.
Badruu Profile.png Badruu Walks back to the kitchen at the farm.
Chayne Profile.png Chayne Walks to the middle of the Tavern
Delaila Profile.png Delaila Walks from the General Store back home.
Eshe Profile.png Eshe Starts to walk towards Reflection Fields.
Hassian Profile.png Hassian Walks inside the Tavern.
Jel Profile.png Jel Walks behind the counter and stands there.
Kenyatta Profile.png Kenyatta Walks to the Library.
Reth Profile.png Reth Leaves work at the Tavern and walks to the Tailor shop
Tau Profile.png Tau Walks inside the Tavern.
Tish Profile.png Tish Leaves work at the Furniture Store and walks to the Tailor to visit Jel
Zeki Profile.png Zeki Leaves the General Store to walk to the Tavern.
5:45 PM Eshe Profile.png Eshe Arrives at the Gate to Remembrance Garden between Elouisa and Caleri's House and the Apothecary in Reflection Fields and stands at the side of the Gate.
6:00 PM Auni Profile.png Auni Walks to the kitchen on the farm.
6:45 PM Delaila Profile.png Delaila Reaches the Daiya family kitchen.
6:49 PM Kenli Profile.png Kenli Is in the Tavern.
7:00 PM Hassian Profile.png Hassian Leaves the Tavern and walks back to Bahari Bay.
Nai'o Profile.png Nai'o Stands in the Daiya family kitchen.
Tau Profile.png Tau Travelling to Hassian's Grove.
7:01 PM Hassian Profile.png Hassian Appears in Bahari Bay and walks to stand watch on the hill past Hideaway Bluffs.
8:00 PM Hodari Profile.png Hodari Walks back to the little area just outside the house.
Najuma Profile.png Najuma Walks to the picnic table in front of her house.
Reth Profile.png Reth Leaves the Tailor shop and goes to his storeroom
9:00 PM Auni Profile.png Auni Goes to his treehouse and stands next to it.
Badruu Profile.png Badruu Walks in to the barn.
Chayne Profile.png Chayne Goes back to sleep
Delaila Profile.png Delaila Walks from home to the Tavern.
Eshe Profile.png Eshe Starts to walk to the balcony of the City Hall.
Hodari Profile.png Hodari Passes by Bahari Ruins.
Kenyatta Profile.png Kenyatta Walks to the Kilima Central Stables.
Nai'o Profile.png Nai'o Walks to Ormuu pen near Badruu's Barn.
Zeki Profile.png Zeki Leaves the Tavern to walk to the General Store.
9:01 PM Zeki Profile.png Zeki Appears in The Underground.
10:00 PM Badruu Profile.png Badruu Walks to his room and goes to sleep. (briefly wakes up at 1 AM)
Caleri Profile.png Caleri Goes to sleep.
Hassian Profile.png Hassian Walks back to Hassian's Grove to sleep.
Hodari Profile.png Hodari Arrives at the little area just outside the house.
Kenli Profile.png Kenli Heads back to the Mayor's Estate.
Tish Profile.png Tish Leaves the Tailor shop and goes to her house
10:10 PM Eshe Profile.png Eshe Arrives at the balcony of the City Hall.
10:40 PM Delaila Profile.png Delaila Reaches the Tavern.
11:00 PM Elouisa Profile.png Elouisa Walks from Library to her home.
Hekla Profile.png Hekla Walks back to sleep in their tent.
Hodari Profile.png Hodari Going in to sleep.
Jel Profile.png Jel Leaves his shop to walk through town.
Jina Profile.png Jina Walks back to sleep in Hekla's Tent.
Najuma Profile.png Najuma Walks back to her workshop.
11:30 PM Kenli Profile.png Kenli Goes to sleep on the couch.

local common = require('Module:Common')
local tbls   = require('Module:Common/Tables')
local cargo  = require('Module:Common/Cargo')

local p = {}

local function toFloat(input)
	local finds = { input:match('^([0-9]+):([0-9]+)(.*)$') }
	
	if #finds > 0 then
		-- Minutes cannot be '0' or '123', should be '10', '15', '45', etc
		if #finds[2] ~= 2 then
			return nil
		end
		
		-- Convert to a number type
        local h = tonumber(finds[1])
        local m = tonumber(finds[2]) / 60
        
        if m > 1 then
            return nil
        end
        
        local e = mw.text.trim((finds[3] or ''):lower())
        if e == 'am' then
        	if h == 12 then
        		h = h - 12
        	end
        elseif e == 'pm' then
        	if h ~= 12 then
        		h = h + 12
        	end
        elseif e ~= '' then
        	return nil
    	end
        
        if h < 0 or h >= 24 then
        	return nil
        end
        
        return h + m
	end
	
	return nil
end

local function fromFloat(input)
	local h = math.floor(input)
	local m = (input - h) * 60
	
	return ('%d:%02d'):format(h, m)
end

local function formatFullTable(keys, times)
	local tbl = tbls.create({
		['class'] = 'paliatable'
	})
	
	tbl:th('Time')
		:th('Villager')
		:th('Description')
	
	for _, key in ipairs(keys) do
		local vals = times[key]
		
		for i, t in ipairs(vals) do
			local row = tbl:row()
			
			-- Add the rowspan time value
			if i == 1 then
				row:td({ ['rowspan'] = #vals })
					:text('{{Time|' .. key .. '}}')
			end
			
			row:td('{{NPC|' .. t['npc'] .. '}}')
				:td(t['desc'])
		end
	end
	
	return tbl:done()
end

function p.store(frame)
	local args = common.getArgs(frame)
	
	for key, val in pairs(args) do
		local num = toFloat(key)
		if num ~= nil then
			cargo.store({
				['_table']      = 'Schedules',
				['time']        = num,
				['description'] = val
			})
		end
	end
	
	return ''
end

function p.fullList(frame)
	local keys  = {} -- Sorted set of keys
	local times = {}
	local rows = cargo.query({
		['tables']  = 'Schedules, Categories',
		['fields']  = 'CONCAT(Schedules._pageName) = npc, time, description = desc',
		['join']    = 'Schedules._pageName = Categories._pageName',
		['where']   = 'Categories.category = "Villager"',
		['orderBy'] = 'time, npc',
		['limit']   = 5000
	})
	
	for _, row in ipairs(rows) do
		local t = fromFloat(row['time'])
		if not times[t] then
			table.insert(keys, t)
			times[t] = {}
		end
		
		table.insert(times[t], row)
	end
	
	return frame:preprocess(formatFullTable(keys, times))
end

function p.match(input)
	return toFloat(input)
end

return p