Add ScriptLobbyDropdown trait and lua API.

This commit is contained in:
Paul Chote
2016-06-12 18:45:40 +01:00
parent 74f0eceb56
commit 1d1b97cb6a
3 changed files with 79 additions and 0 deletions

View File

@@ -107,6 +107,18 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Returns the difficulty selected by the player before starting the mission.")]
public string Difficulty { get { return Context.World.LobbyInfo.GlobalSettings.Difficulty; } }
[Desc("Returns the value of a `ScriptLobbyDropdown` selected in the game lobby.")]
public LuaValue LobbyOption(string id)
{
var option = Context.World.WorldActor.TraitsImplementing<ScriptLobbyDropdown>()
.FirstOrDefault(sld => sld.Info.ID == id);
if (option == null)
throw new YamlException("A ScriptLobbyDropdown with ID `" + id + "` was not found.");
return option.Value;
}
[Desc("Returns a table of all the actors that were specified in the map file.")]
public Actor[] NamedActors { get { return sma.Actors.Values.ToArray(); } }