Module:Sandbox/LVL: Difference between revisionsGive feedback
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
-- | -- Get NPC data values (you may need to adjust these based on your wiki's implementation) | ||
local baseValue = 20 -- This should match {{NpcData|neutral_sinners_sacrifice|GoldReward}} | |||
local bonusPercentPerMinute = 0.02 -- This should match {{NpcData|neutral_sinners_sacrifice|GoldRewardBonusPercentPerMinute}} / 100 | |||
local | |||
--{{ | |||
--{{ | |||
function p.calculatePayouts(frame) | |||
local time = tonumber(frame.args[1]) or 0 | |||
-- Calculate total soul value | |||
local totalValue = math.floor((baseValue + (baseValue * bonusPercentPerMinute * time)) * 2) | |||
-- Calculate individual payouts | |||
local lightMelee = math.floor(totalValue / 20 + 0.5) -- Adding 0.5 for proper rounding | |||
local heavyMelee = math.floor(totalValue / 10 + 0.5) | |||
local finalHit = math.floor(totalValue / 2 + 0.5) + math.floor(totalValue / 10 + 0.5) | |||
-- Return JSON format for easy parsing by JavaScript | |||
return mw.text.jsonEncode({ | |||
total = totalValue, | |||
light = lightMelee, | |||
heavy = heavyMelee, | |||
final = finalHit | |||
}) | |||
end | end | ||
return p | return p | ||
Revision as of 18:03, 16 November 2025
Documentation for this module may be created at Module:Sandbox/LVL/doc
local p = {}
-- Get NPC data values (you may need to adjust these based on your wiki's implementation)
local baseValue = 20 -- This should match {{NpcData|neutral_sinners_sacrifice|GoldReward}}
local bonusPercentPerMinute = 0.02 -- This should match {{NpcData|neutral_sinners_sacrifice|GoldRewardBonusPercentPerMinute}} / 100
function p.calculatePayouts(frame)
local time = tonumber(frame.args[1]) or 0
-- Calculate total soul value
local totalValue = math.floor((baseValue + (baseValue * bonusPercentPerMinute * time)) * 2)
-- Calculate individual payouts
local lightMelee = math.floor(totalValue / 20 + 0.5) -- Adding 0.5 for proper rounding
local heavyMelee = math.floor(totalValue / 10 + 0.5)
local finalHit = math.floor(totalValue / 2 + 0.5) + math.floor(totalValue / 10 + 0.5)
-- Return JSON format for easy parsing by JavaScript
return mw.text.jsonEncode({
total = totalValue,
light = lightMelee,
heavy = heavyMelee,
final = finalHit
})
end
return p