Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createSpawnSequence(inputBalance)
- local outputString = ""
- local totalSpawns = 0
- for kind, count in pairs(inputBalance) do
- totalSpawns = totalSpawns + count
- end
- for i = totalSpawns, 1, -1 do
- i = math.random(i)
- for kind, count in pairs(inputBalance) do
- if i <= count then
- outputString = outputString .. "," .. kind
- inputBalance[kind] = count - 1
- break
- else
- i = i - count
- end
- end
- end
- return string.sub(outputString, 2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement