| 🌟 | 現在、 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「モジュール:Utility/Library」の版間の差分
ナビゲーションに移動
検索に移動
(丸め演算用の関数を追加) |
(selectiveRoundの不具合を修正) |
||
| 54行目: | 54行目: | ||
function aw.selectiveRound(num, useRound) | function aw.selectiveRound(num, useRound) | ||
if useRound or false then | if useRound or false then | ||
return round(num) | return aw.round(num) | ||
else | else | ||
return roundover(num) | return aw.roundover(num) | ||
end | end | ||
end | end | ||
return aw | return aw | ||
2021年2月2日 (火) 18:29時点における版
このモジュールについての説明文ページを モジュール:Utility/Library/doc に作成できます
local aw = {}
function aw.shallowCopy(obj)
local typename = type(obj)
local copy
if typename == 'table' then
copy = {}
for key, value in pairs(obj) do
copy[key] = value
end
else
copy = obj
end
return copy
end
function aw.getAsBoolean(strOrNumOrBool, defaultValue)
defaultValue = defaultValue or false
local typename = type(strOrNumOrBool)
if typename == 'boolean' then
return strOrNumOrBool
elseif typename == 'number' then
return strOrNumOrBool ~= 0
elseif typename == 'string' then
local str = string.lower(strOrNumOrBool)
return str == 'true' or str == 't' or str == '1'
else
return defaultValue
end
end
function aw.getAsNumber(strOrNum, defaultValue)
defaultValue = defaultValue or 0
local typename = type(strOrNum)
if typename == 'number' then
return strOrNum
elseif typename == 'string' then
return tonumber(strOrNum)
else
return defaultValue
end
end
function aw.round(num)
return math.floor(tonumber(string.format("%.4f", num)) + 0.5)
end
function aw.roundover(num)
return math.ceil(tonumber(string.format("%.4f", num)) - 0.5)
end
function aw.selectiveRound(num, useRound)
if useRound or false then
return aw.round(num)
else
return aw.roundover(num)
end
end
return aw