From 09d1dacd95b849aebe5c5595700179b266176488 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Sun, 15 May 2016 16:38:41 +0200 Subject: [PATCH] Add a Lua API method to randomize a collection --- OpenRA.Mods.Common/Scripting/Global/UtilsGlobal.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenRA.Mods.Common/Scripting/Global/UtilsGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/UtilsGlobal.cs index 50ca3e5add..b5177936cc 100644 --- a/OpenRA.Mods.Common/Scripting/Global/UtilsGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/UtilsGlobal.cs @@ -93,6 +93,12 @@ namespace OpenRA.Mods.Common.Scripting return collection.Random(Context.World.SharedRandom).CopyReference(); } + [Desc("Returns the collection in a random order.")] + public LuaValue[] Shuffle(LuaValue[] collection) + { + return collection.Shuffle(Context.World.SharedRandom).ToArray(); + } + [Desc("Expands the given footprint one step along the coordinate axes, and (if requested) diagonals.")] public CPos[] ExpandFootprint(CPos[] footprint, bool allowDiagonal) {