モジュール:NoitaUtils
ナビゲーションに移動
検索に移動
Documentation
[purge]
このモジュールは、Wikiで使用されるさまざまなテンプレートの機能をサポートするために存在します。
使い方
このモジュールから次のように関数を呼び出します
{{#invoke:NoitaUtils|functionName|argument}}
関数
getEnemyGoldValue
ゲーム内のHP値に基づいて、敵がドロップするゴールドの量を計算します。
パラメータ
hp
- ゲーム内の敵のHPの数値
見本
Enemy HP: 100; Gold: {{#invoke:NoitaUtils|getEnemyGoldValue|hp = 100}}
Enemy HP: 100; Gold: 40
getUIDamageValue
XML / luaの内部ダメージ数からダメージのUI値を計算します。
パラメータ
damage
- lua / xmlファイルからの内部数値損傷値
見本
Internal Damage: 1.0; UI Damage: {{#invoke:NoitaUtils|getUIDamageValue|damage = 1.0}}
Internal Damage: 1.0; UI Damage: 25
getUIHealthValue
XML / luaの内部HP値からHPのUI値を計算します。
パラメータ
hp
- lua / xmlファイルからの内部数値hp値
見本
Internal HP: 1.7; UI HP: {{#invoke:NoitaUtils|getUIHealthValue|hp = 1.7}}
Internal HP: 1.7; UI HP: 42.5
getTimeValue
フレームの入力値から秒単位の時間値を計算します。
パラメータ
frames
- the internal numeric frames value from the lua/xml file.
見本
Time in frames: 1600; Time in seconds: {{#invoke:NoitaUtils|getTimeValue|frames = 1600}}
Time in frames: 1600; Time in seconds: 26.667
getFramesInDuration
Calculates the number of frames in a period of time given an input value in seconds.
Parameters
duration
- a period of time in seconds.
Example
There are {{#invoke:NoitaUtils|getFramesInDuration|duration = 1.32}} frames in a period of 1.32s.
There are 79.2 frames in a period of 1.32s.
getRealExplosionDamage
Calculates the 'true' in game UI damage from a given explosion damage UI number value.
Parameters
damage
- the explosion damage shown in the spell tooltip.
Example
Stated spell explosion damage: 400; Real spell explosion damage: {{#invoke:NoitaUtils|getRealExplosionDamage|damage = 400}}
Stated spell explosion damage: 400; Real spell explosion damage: 100
Example
Stated spell explosion damage: 40 (x3); Real spell explosion damage: {{#invoke:NoitaUtils|getRealExplosionDamage|damage = 40 (x3)}}
Stated spell explosion damage: 40 (x3); Real spell explosion damage: 10 (x3)
local p = {}
local framesPerSecond = 60
local function trim(str)
return str:gsub("^%s*(.-)%s*$", "%1")
end
local function is_empty(str)
return str == nil or str.len(trim(str)) == 0
end
local function append_table(tbl, data)
tbl[#tbl + 1] = data
end
local parseFloat = require('Module:Y_util').string.parseFloat -- this function gets the first number from a string
function getUIHealthOrDamageValue(internalValue)
return 25 * internalValue
end
function formatNumeric(number)
return ("%.5g"):format(tonumber(number))
end
function split(str, delimiter)
local chunks = {}
for c in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(chunks, c)
end
return chunks
end
function subrange(t, first, last)
local sub = {}
for i = first, last do
sub[#sub + 1] = t[i]
end
return sub
end
function p.getEnemyGoldValue(frame)
local hpValue = frame.args["hp"]
local internalHpValue = tonumber(hpValue) / 25
return formatNumeric(math.max(1, math.floor(internalHpValue)) * 10)
end
function p.getUIDamageValue(frame)
local internalDamageValue = tonumber(frame.args["damage"])
return formatNumeric(getUIHealthOrDamageValue(internalDamageValue))
end
function p.getUIHealthValue(frame)
local internalHPValue = tonumber(frame.args["hp"])
return formatNumeric(getUIHealthOrDamageValue(internalHPValue))
end
function p.getTimeValue(frame)
local timeInFrames = tonumber(frame.args["frames"])
return formatNumeric(timeInFrames / framesPerSecond)
end
function p.getFramesInDuration(frame)
local durationInSeconds = tonumber( parseFloat(frame.args["duration"]) )
return formatNumeric(durationInSeconds * framesPerSecond)
end
function p.getRealExplosionDamage(frame)
local damage = frame.args["damage"]
local damageNum = 0.0
local suffix = ""
if string.find(damage, " ") then
local parts = split(damage, " ")
p.parts = parts
damageNum = tonumber(parts[1])
p.testDamageNum = damageNum
suffix = " " .. table.concat(subrange(parts, 2, #parts), " ")
else
damageNum = tonumber(damage)
end
local explosionDamage = damageNum / 4.0
return formatNumeric(explosionDamage) .. suffix
end
return p
カテゴリ:
- 非推奨のsourceタグを使用しているページ