allow to to use a custom rng in helper.rand
This commit is contained in:
parent
99de242524
commit
8c4e09e940
1 changed files with 3 additions and 2 deletions
|
@ -402,7 +402,8 @@ function helper.shallow_parsed(cfg)
|
|||
end
|
||||
end
|
||||
|
||||
function helper.rand (possible_values)
|
||||
function helper.rand (possible_values, random_func)
|
||||
random_func = random_func or wesnoth.random
|
||||
assert(type(possible_values) == "table" or type(possible_values) == "string", string.format("helper.rand expects a string or table as parameter, got %s instead", type(possible_values)))
|
||||
|
||||
local items = {}
|
||||
|
@ -460,7 +461,7 @@ function helper.rand (possible_values)
|
|||
end
|
||||
end
|
||||
|
||||
local idx = wesnoth.random(1, num_choices)
|
||||
local idx = random_func(1, num_choices)
|
||||
|
||||
for i, item in ipairs(items) do
|
||||
if type(item) == "table" then -- that's a range
|
||||
|
|
Loading…
Add table
Reference in a new issue