Editing Module:Sandbox/Asarta/Market
From Fallen London Wiki (Staging)
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 6: | Line 6: | ||
["shilling"] = {name = "Rat-Shilling", symbol = "R"} | ["shilling"] = {name = "Rat-Shilling", symbol = "R"} | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function normalise_currency(currency) | function normalise_currency(currency) | ||
Line 64: | Line 37: | ||
end | end | ||
− | function create_transaction(buy_price, sell_price, buy_currency, sell_currency, buy_message, sell_message, shop, sell_market, sell_market_appearance) | + | |
+ | function p.create_transaction(buy_price, sell_price, buy_currency, sell_currency, buy_message, sell_message, shop, sell_market, sell_market_appearance) | ||
local buy_currency_name = currency_attributes[buy_currency].name | local buy_currency_name = currency_attributes[buy_currency].name | ||
local sell_currency_name = currency_attributes[sell_currency].name | local sell_currency_name = currency_attributes[sell_currency].name | ||
sell_market_appearance = sell_market_appearance or sell_market | sell_market_appearance = sell_market_appearance or sell_market | ||
local categories = {} | local categories = {} | ||
+ | -- if buy_price and buy_price is neither - or Echo set properties for | ||
if buy_price and buy_price ~= "-" then | if buy_price and buy_price ~= "-" then | ||
mw.smw.set({"Bought for", buy_price .. ";" .. buy_currency_name .. ";" .. shop}) | mw.smw.set({"Bought for", buy_price .. ";" .. buy_currency_name .. ";" .. shop}) | ||
+ | -- if buy_currency is not echoes, set properties for loss of that currency | ||
if buy_currency ~= "echoes" then | if buy_currency ~= "echoes" then | ||
mw.smw.set({"Loses", buy_currency_name}) | mw.smw.set({"Loses", buy_currency_name}) | ||
Line 76: | Line 52: | ||
end | end | ||
end | end | ||
+ | -- if sell_price and sell_price is neither - or Echo set properties for | ||
if sell_price and sell_price ~= "-" then | if sell_price and sell_price ~= "-" then | ||
mw.smw.set({"Sells for", sell_price .. ";" .. sell_currency_name .. ";" .. sell_market}) | mw.smw.set({"Sells for", sell_price .. ";" .. sell_currency_name .. ";" .. sell_market}) | ||
Line 95: | Line 72: | ||
− | local | + | local table = mw.html.create("table"):addClass("article-table") |
− | |||
if buy_price and buy_price ~= "-" then | if buy_price and buy_price ~= "-" then | ||
− | + | table:tag("tr") | |
:tag("th"):wikitext("Buying"):done() | :tag("th"):wikitext("Buying"):done() | ||
:tag("td"):wikitext(create_currency_symbol(buy_currency, buy_price)) | :tag("td"):wikitext(create_currency_symbol(buy_currency, buy_price)) | ||
Line 104: | Line 80: | ||
:done() | :done() | ||
end | end | ||
− | |||
if sell_price and sell_price ~= "-" then | if sell_price and sell_price ~= "-" then | ||
− | + | table:tag("tr") | |
:tag("th"):wikitext("Selling"):done() | :tag("th"):wikitext("Selling"):done() | ||
:tag("td"):wikitext(create_currency_symbol(sell_currency, sell_price)) | :tag("td"):wikitext(create_currency_symbol(sell_currency, sell_price)) | ||
Line 112: | Line 87: | ||
:done() | :done() | ||
end | end | ||
− | |||
local output = mw.html.create("div") | local output = mw.html.create("div") | ||
output:node(buying_selling_line) | output:node(buying_selling_line) | ||
− | output:node( | + | output:node(table) |
for _, category in ipairs(categories) do | for _, category in ipairs(categories) do | ||
output:wikitext("[[Category:" .. category .. "]]") | output:wikitext("[[Category:" .. category .. "]]") | ||
end | end | ||
− | |||
return output | return output | ||
end | end | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
return p | return p |