Choosing the largest of a set of values

Is there an easy way of picking the largest number out of a set of values, for instance:

[code]local value1 = math.random(0,10)
local value2 = math.random(0,10)
local value2 = math.random(0,10)

local largestValue = --something which chooses the largest value out of value1, 2 and 3

[/code] [import]uid: 116264 topic_id: 25639 reply_id: 325639[/import]

Yes there is, try this;

[lua]math.randomseed(os.time())

local value1 = math.random(0,10)
local value2 = math.random(0,10)
local value3 = math.random(0,10)

local function getNum()
return math.max(value1, value2, value3)
end

local largestValue = getNum()
print (largestValue)[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 25639 reply_id: 103685[/import]

Thanks, that is just what I needed. Just one thing though, what is the first line for? [import]uid: 116264 topic_id: 25639 reply_id: 103702[/import]

No worries.

math.randomseed() is used to make random truly random, basically.

From the math.random API page;
Consecutive invocations of math.random() return consecutive values in a given pseudorandom sequence. Use math.randomseed() to specify a seed and reset a sequence.

Peach :slight_smile: [import]uid: 52491 topic_id: 25639 reply_id: 103823[/import]