Abyss_
Atlantika RPG Owner
Hi!
I made this script which should transform an item into a random one. There are different chances but it always ends up that its the "silver node" (the first 'elseif') which gets generated.
The code:
How to fix this problem so that not only the silver node gets generated? Thanks!
I made this script which should transform an item into a random one. There are different chances but it always ends up that its the "silver node" (the first 'elseif') which gets generated.
The code:
Code:
function onStartup()
local nodePositions = {
{x = 3749, y = 3526, z = 6, stackpos = 1}
}
for _, pos in ipairs(nodePositions) do
local node = getTileThingByPos(pos).uid
local randnum = math.random(0,100)
if randnum >= 1 and randnum <= 50 then
doTransformItem(node, 22703) -- copper 50%
elseif randnum >= 51 and randnum <= 75 then
doTransformItem(node, 22709) -- silver 25%
elseif randnum >= 76 and randnum <= 90 then
doTransformItem(node, 22712) -- gold 15%
elseif randnum >= 91 and randnum <= 100 then
doTransformItem(node, 22706) -- mythril 10%
end
end
end
How to fix this problem so that not only the silver node gets generated? Thanks!