Module:Sandbox/User:Alsang: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 4:
local currency = require('Module:Currency')
local lang = mw.getContentLanguage()
local xpdata = mw.loadData('Module:Experience/data')
local p = {}
Line 13 ⟶ 14:
-- other parameters are determined by subqueries of chained pages
local query = {
'[[Activity JSON::~*]]',
'? = name',
'?Activity JSON = activityJSON',
'
}
local results = mw.smw.ask(query)
results = p.screenResults(results)
return p.displayTable(results)
Line 29 ⟶ 28:
--return '<pre>'..mw.text.jsonEncode(results, mw.text.JSON_PRETTY)..'</pre>'
end
Line 59 ⟶ 44:
for j,json in ipairs(item.activityJSON) do
local activityJSON = mw.text.jsonDecode(json)
local itemNew = {}
itemNew.name = item.name
itemNew.XP = activityJSON.xp
itemNew.lvl = activityJSON.level
itemNew.
itemNew.duration = activityJSON.duration
itemNew.product = activityJSON.output[1].name
itemNew.XPperHour = itemNew.XP and tonumber(itemNew.XP) and itemNew.duration and tonumber(itemNew.duration) and tonumber(itemNew.XP) * 3600 / tonumber(itemNew.duration)
itemNew.fitXP = xpdata.knowledge[itemNew.lvl]*4*0.0005
if itemNew.lvl>=200 then
itemNew.fitXP = itemNew.fitXP * 4
end
itemNew.fitXP = math.floor(itemNew.fitXP * 100 ) / 100
local query = mw.smw.ask('[[Sold item::' .. itemNew.product .. ']][[Shop sell price::!~N/A]]|?Shop sell price=data|mainlabel=-')
if type(query)=='table' then
-- price is returned as a number
itemNew.productSellPrice = tonumber(query[1].data)*0.005
else
-- will return nil if the item is not in a shop, or if it is in a shop but can only be sold to the shop
itemNew.productSellPrice = nil
end
table.insert(resultsScreened,itemNew)
end
end
Line 89 ⟶ 92:
return resultsScreened
end
Line 134 ⟶ 100:
:tag('tr')
:tag('th')
:wikitext('
:done()
:tag('th')
:wikitext('Product')
:done()
:tag('th')
:wikitext('
:done()
:tag('th')
:
:done()
:tag('th')
Line 155 ⟶ 115:
:done()
:tag('th')
:wikitext('0.0005 of levelup XP
:done()
:tag('th')
:wikitext('sell price<br>per action')
:done()
-- :tag('th')
-- :wikitext('Duration')
-- :done()
-- :tag('th')
-- :wikitext('XP/hr')
-- :done()
:done()
for i, item in ipairs(results) do
Line 168 ⟶ 132:
--level
:tag('td')
:wikitext(item.name)
:done()
:tag('td')
:wikitext('[[' .. item.product .. ']]')
:done()
:tag('td')
:wikitext('[[' .. item.profession .. ']]')
:done()
:tag('td')
:wikitext(item.lvl)
:done()
:tag('td')
:wikitext(item.XP)
:done()
:tag('td')
:wikitext(item.fitXP)
:done()
:tag('td')
:wikitext(item.productSellPrice)
:done()
-- :tag('td')
-- :wikitext(item.duration)
-- :
:done()
|