Module:Sandbox/User:Alsang: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
No edit summary
Line 64: Line 64:
['Activity coins'] = args.coins,
['Activity coins'] = args.coins,
['Activity input'] = args.input,
['Activity input'] = args.input,
['Activity container'] = args.container,
['Activity container'] = 'test',
-- straight copy from Infobox Recipe, its good to have a standard format
-- straight copy from Infobox Recipe, its good to have a standard format

Revision as of 00:25, 16 December 2024

Module documentation
This documentation is transcluded from Module:Sandbox/User:Alsang/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Sandbox/User:Alsang/doc. [edit]
Module:Sandbox/User:Alsang's function main is invoked by Template:Sandbox/User:Alsang.
Module:Sandbox/User:Alsang loads data from Module:Experience/data.

require('strict')
require('Module:Mw.html extension')
local editbutton = require('Module:Edit button')
local edit = editbutton("'''?''' (edit)")
local hc = require('Module:Param Parse').has_content
local yn = require('Module:Yesno')
local qty = require('Module:Quantity box')._main
local pcp = require('Module:Profession clickpic')._main
local currency = require('Module:Currency')
local album_xp_data = mw.loadData('Module:Experience/data').album
local lang = mw.language.getContentLanguage()
local tooltip = require('Module:Tooltip')

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local albumxp = album_xp_data[tonumber(args.level)]

	if albumxp then
		albumxp = lang:formatNum(albumxp)..' xp'
	end
	
	--Checks if the recipe has been flagged as passive, defaults to no.
	local passive = yn(args.passive or 'no', false)
	local quant = 1
	if passive then
		quant = 0.005
	end
		
	
	local function exparg(xp)
		if hc(xp) then
			return qty(xp)
		else
			return qty(0)..edit..'[[Category:Needs experience info]]'
		end
	end
	
	local function levelarg(profession, level)
		if hc(profession) and hc(level) then
			return pcp(profession, level)
		else
			return edit..'[[Category:Needs level info]]'
		end
	end
	
	local function durationarg(duration)
		if hc(duration) then
			return duration..' seconds'
		else
			return edit..'[[Category:Needs duration info]]'
		end
	end
	
	local smw_properties = {
		['Skill node name'] = args.name,
		['Uses profession'] = args.profession,
		['Profession level'] = args.level,
		['Activity XP'] = args.xp,
		['Activity album XP'] = album_xp_data[tonumber(args.level)],
		['Activity KP'] = args.kp,
		['Activity duration'] = args.duration,
		['Activity coins'] = args.coins,
		['Activity input'] = args.input,
		['Activity container'] = 'test',
		
		-- straight copy from Infobox Recipe, its good to have a standard format
		['Activity JSON'] = mw.text.jsonEncode({test = true})
	}
	mw.smw.set(smw_properties)
	
	local out = mw.html.create('table')
		:addClass('wikitable')
		:tag('tr')
			:tag('th')
				:attr{ colspan = '2' }
				:wikitext(args.name)
			:done()
		:done()
		:tag('tr')
			:tag('th')
				:wikitext('Level required')
			:done()
			:tag('td')
				:wikitext(levelarg(args.profession, args.level))
			:done()
		:done()
		:tag('tr')
			:tag('th')
				:IF(passive)
					:wikitext('[[File:Passive small icon.png|20x20px|link=Passive Activity]] [['..args.profession..'|'..args.profession..' XP]] ')
					:node(tooltip._span{ 'passive' })
					:node(tooltip._div{ name = 'passive', content = 'Passive activities give reduced experience when a players level is high enough to perform a new passive activity for that profession. The number shown here is the full experience.' })
				:ELSE()
					:wikitext('[['..args.profession..'|'..args.profession..' XP]]')
				:END()
			:done()
			:tag('td')
				:wikitext(exparg(args.xp))
			:done()
		:done()
		:tag('tr')
			:tag('th')
				:wikitext('[[Album|Album XP]]')
			:done()
			:tag('td')
				:wikitext(albumxp or 'Unknown')
			:done()
		:done()
		:tag('tr')
			:tag('th')
				:wikitext('Duration')
			:done()
			:tag('td')
				:wikitext(durationarg(args.duration))
			:done()
		:done()
	
	if hc(args.respawn) then
		out
			:tag('tr')
				:tag('th')
					:wikitext('Respawn time')
				:done()
				:tag('td')
					:wikitext(durationarg(args.respawn))
				:done()
			:done()
	end
	
	if hc(args.tool) then
		out
			:tag('tr')
				:tag('th')
					:wikitext('Required tool')
				:done()
				:tag('td')
					:wikitext(args.tool)
				:done()
			:done()
	end
	
	if hc(args.input) then
		out
			:tag('tr')
				:tag('th')
					:wikitext('Required input')
				:done()
				:tag('td')
					:wikitext(args.input)
				:done()
			:done()
	end
	
	if hc(args.container) then
		out
			:tag('tr')
				:tag('th')
					:wikitext('Required container')
				:done()
				:tag('td')
					:wikitext(args.container)
				:done()
			:done()
	end
	
	if hc(args.coins) then
		out
			:tag('tr')
				:tag('th')
					:wikitext('Coins')
				:done()
				:tag('td')
					:wikitext(currency.parse(args.coins))
				:done()
			:done()
	end
	
	return out
end

return p