Editing Module:GainLoss

From Fallen London Wiki

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 33: Line 33:
  
 
     -- Mutually-exclusive parameters
 
     -- Mutually-exclusive parameters
     local arg_count = ((has_amount and 1) or 0) + ((has_now and 1) or 0) + ((has_occurrence and 1) or 0) + ((has_to and 1) or 0) + ((has_twist and 1) or 0) + ((has_gone and 1) or 0) + ((has_reset and 1) or 0)
+
     local arg_count = (has_amount and 1 or 0) + (has_now and 1 or 0) + (has_occurrence and 1 or 0) + (has_to and 1 or 0) + (has_twist and 1 or 0) + (has_gone and 1 or 0) + (has_reset and 1 or 0)
 
     if arg_count > 1 then
 
     if arg_count > 1 then
 
         return wrap_error_message('Error, too many level parameters were given.')
 
         return wrap_error_message('Error, too many level parameters were given.')
Line 137: Line 137:
 
     if game_type == 'Item' then
 
     if game_type == 'Item' then
 
         -- "<'Gives' | 'Removes'> <amount | '? x'> <appearance | name>[, up to <cap>]"
 
         -- "<'Gives' | 'Removes'> <amount | '? x'> <appearance | name>[, up to <cap>]"
         local gain_loss_text = (gain_or_loss == 'gain' and 'Gives ') or 'Removes '
+
         local gain_loss_text = gain_or_loss == 'gain' and 'Gives ' or 'Removes '
 
         return gain_loss_text .. (amount or '? x') .. " " .. IL_link .. cap_msg_comma
 
         return gain_loss_text .. (amount or '? x') .. " " .. IL_link .. cap_msg_comma
 
     elseif is_pyramidal and is_pyramidal_cp_amount(amount) then
 
     elseif is_pyramidal and is_pyramidal_cp_amount(amount) then
 
         -- "<'Increases' | 'Decreases'> <appearance | name> by <amount | '? CP'>[, up to level <cap>]"
 
         -- "<'Increases' | 'Decreases'> <appearance | name> by <amount | '? CP'>[, up to level <cap>]"
         local gain_loss_text = (gain_or_loss == 'gain' and 'Increases') or 'Decreases'
+
         local gain_loss_text = gain_or_loss == 'gain' and 'Increases' or 'Decreases'
 
         return gain_loss_text .. " " .. IL_link .. " by " .. (amount or '? CP') .. cap_msg_comma
 
         return gain_loss_text .. " " .. IL_link .. " by " .. (amount or '? CP') .. cap_msg_comma
 
     else
 
     else
 
         -- "<'Raises' | 'Lowers'> <appearance | name> by <amount | '?'>[, up to <cap>]"
 
         -- "<'Raises' | 'Lowers'> <appearance | name> by <amount | '?'>[, up to <cap>]"
         local gain_loss_text = (gain_or_loss == 'gain' and 'Raises') or 'Lowers'
+
         local gain_loss_text = gain_or_loss == 'gain' and 'Raises' or 'Lowers'
 
         return gain_loss_text .. " " .. IL_link .. " by " .. (amount or '?') .. cap_msg_comma
 
         return gain_loss_text .. " " .. IL_link .. " by " .. (amount or '?') .. cap_msg_comma
 
     end
 
     end
Line 183: Line 183:
 
     if is_pyramidal and is_pyramidal_cp_amount(amount) then
 
     if is_pyramidal and is_pyramidal_cp_amount(amount) then
 
         -- "<appearance | name> is <'increasing' | 'dropping'>… (<'+' | '-'><amount | '? CP'>[, up to level <cap>])"
 
         -- "<appearance | name> is <'increasing' | 'dropping'>… (<'+' | '-'><amount | '? CP'>[, up to level <cap>])"
         local gain_loss_text = (gain_or_loss == 'gain' and 'increasing… (+') or 'dropping… (-'
+
         local gain_loss_text = gain_or_loss == 'gain' and 'increasing… (+' or 'dropping… (-'
 
         local cap_msg_comma = (cap_msg and (', ' .. cap_msg)) or ''
 
         local cap_msg_comma = (cap_msg and (', ' .. cap_msg)) or ''
 
         return "<b>" .. wikitext_link .. "</b> is " .. gain_loss_text .. (amount or '? CP') .. cap_msg_comma .. ")"
 
         return "<b>" .. wikitext_link .. "</b> is " .. gain_loss_text .. (amount or '? CP') .. cap_msg_comma .. ")"
 
     else
 
     else
 
         -- "You've <'gained' | 'lost'> <amount | '?'> <appearance | name>[ (up to <cap>)]"
 
         -- "You've <'gained' | 'lost'> <amount | '?'> <appearance | name>[ (up to <cap>)]"
         local gain_loss_text = (gain_or_loss == 'gain' and 'gained') or 'lost'
+
         local gain_loss_text = gain_or_loss == 'gain' and 'gained' or 'lost'
 
         local cap_msg_paren = (cap_msg and (' (' .. cap_msg .. ')')) or ''
 
         local cap_msg_paren = (cap_msg and (' (' .. cap_msg .. ')')) or ''
 
         return "You've " .. gain_loss_text .. " " .. (amount or '?') .. " <b>" .. wikitext_link .. "</b>" .. cap_msg_paren
 
         return "You've " .. gain_loss_text .. " " .. (amount or '?') .. " <b>" .. wikitext_link .. "</b>" .. cap_msg_paren
Line 200: Line 200:
  
 
     -- Load parameters, setting empty parameters to false
 
     -- Load parameters, setting empty parameters to false
     -- note "<expression> and <a> or <b>" is similar to the ternary operator in other languages, "<expression> ? <a> : <b>"
+
     -- note "<expression> and <a> or <b>" returns <a> if <expression> is true and <a> is truthy, otherwise returns <b>
    -- i.e. returns <a> if <expression> is true and <a> is truthy, otherwise returns <b>
 
  
 
     -- Level change type parameters
 
     -- Level change type parameters
Line 327: Line 326:
 
         -- Format cap message
 
         -- Format cap message
 
         if cap_msg and cap_msg ~= 'uncapped' then
 
         if cap_msg and cap_msg ~= 'uncapped' then
             cap_msg = 'up to ' .. ((is_pyramidal and 'level ') or '') .. cap_msg
+
             cap_msg = 'up to ' .. (is_pyramidal and 'level ' or '') .. cap_msg
 
         end
 
         end
 
     end
 
     end
Line 337: Line 336:
 
     elseif to then
 
     elseif to then
 
         -- "<appearance | name> has <'increased' | 'dropped'> to <to>!"
 
         -- "<appearance | name> has <'increased' | 'dropped'> to <to>!"
         local gain_loss_text = (gain_or_loss == 'gain' and 'increased') or 'dropped'
+
         local gain_loss_text = gain_or_loss == 'gain' and 'increased' or 'dropped'
 
         result = result .. "<b>" .. wikitext_link .. "</b> has " .. gain_loss_text .. " to " .. to .. "!"
 
         result = result .. "<b>" .. wikitext_link .. "</b> has " .. gain_loss_text .. " to " .. to .. "!"
 
     elseif twist then
 
     elseif twist then
 
         -- "A twist in your tale! You are <'now' | 'no longer'> <appearance | name>."
 
         -- "A twist in your tale! You are <'now' | 'no longer'> <appearance | name>."
         local gain_loss_text = (gain_or_loss == 'gain' and 'now') or 'no longer'
+
         local gain_loss_text = gain_or_loss == 'gain' and 'now' or 'no longer'
 
         result = result .. "A twist in your tale! You are " .. gain_loss_text .. " <b>" .. wikitext_link .. "</b>."
 
         result = result .. "A twist in your tale! You are " .. gain_loss_text .. " <b>" .. wikitext_link .. "</b>."
 
     -- These two parameters are only used by Loss
 
     -- These two parameters are only used by Loss
Line 379: Line 378:
  
 
     -- Set Gains/Loses properties
 
     -- Set Gains/Loses properties
     result = result .. '{{Noembed|{{#set:' .. ((gain_or_loss == 'gain' and 'Gains') or 'Loses') .. '=' .. name .. '}}}}'
+
     result = result .. '{{Noembed|{{#set:' .. (gain_or_loss == 'gain' and 'Gains' or 'Loses') .. '=' .. name .. '}}}}'
  
 
     -- Apply [[Property:Has cap on gain]] to Gain if cap parameter present
 
     -- Apply [[Property:Has cap on gain]] to Gain if cap parameter present

Please note that all contributions to Fallen London Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Fallen London Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)
Preview page with this template

Template used on this page: