wea.parse.chance: use not

This commit is contained in:
Starbeamrainbowlabs 2021-05-11 21:59:43 +01:00
parent 4ec04c03b3
commit 040d7fbfde
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -6,7 +6,7 @@ function worldeditadditions.parse.chance(str)
if tonumber(str) ~= nil then return tonumber(str) end
if str:sub(#str) == "%" then
local result = tonumber(str:sub(1, #str-1))
if result == nil then return nil end
if not result then return nil end
return 1 / (result / 100) -- Convert percentage to 1-in-N chance
end
return nil