diff --git a/AUTHORS b/AUTHORS
index f99bd317ac..32b7426e38 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -111,13 +111,6 @@ the Apache 2.0 license.
Using GeoLite2 data created by MaxMind and
distributed under the CC BY-SA 3.0 license.
-Using KopiLua created by Mark Feldman and
-maintained by Vinicius Jarina and distributed
-under the MIT license.
-
-Using NLua created by Vinicius Jarina and
-distributed under the MIT license.
-
Using SharpFont created by Robert Rouhani and
distributed under the MIT license.
diff --git a/Makefile b/Makefile
index d407aa0682..2986ec25aa 100644
--- a/Makefile
+++ b/Makefile
@@ -120,7 +120,7 @@ mod_common: $(mod_common_TARGET)
##### Official Mods #####
-STD_MOD_LIBS = $(game_TARGET) thirdparty/KopiLua.dll thirdparty/NLua.dll
+STD_MOD_LIBS = $(game_TARGET)
STD_MOD_DEPS = $(STD_MOD_LIBS) $(ralint_TARGET)
@@ -341,8 +341,6 @@ install-core: default
@$(INSTALL_PROGRAM) SharpFont.dll "$(DATA_INSTALL_DIR)"
@$(CP) SharpFont.dll.config "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) Mono.Nat.dll "$(DATA_INSTALL_DIR)"
- @$(INSTALL_PROGRAM) KopiLua.dll "$(DATA_INSTALL_DIR)"
- @$(INSTALL_PROGRAM) NLua.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) MaxMind.Db.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) MaxMind.GeoIP2.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) Newtonsoft.Json.dll "$(DATA_INSTALL_DIR)"
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 84ed13657c..ff41de2412 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -53,14 +53,6 @@
..\thirdparty\FuzzyLogicLibrary.dll
False
-
- ..\thirdparty\KopiLua.dll
- False
-
-
- ..\thirdparty\NLua.dll
- False
-
@@ -324,10 +316,7 @@
-
-
-
diff --git a/OpenRA.Mods.RA/Scripting/LuaScriptContext.cs b/OpenRA.Mods.RA/Scripting/LuaScriptContext.cs
deleted file mode 100644
index cf9af09840..0000000000
--- a/OpenRA.Mods.RA/Scripting/LuaScriptContext.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-#region Copyright & License Information
-/*
- * Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
- * This file is part of OpenRA, which is free software. It is made
- * available to you under the terms of the GNU General Public License
- * as published by the Free Software Foundation. For more information,
- * see COPYING.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using NLua;
-using NLua.Event;
-using OpenRA.Primitives;
-
-namespace OpenRA.Mods.RA.Scripting
-{
- [Desc("Part of the legacy Lua API.")]
- public sealed class LuaScriptContext : IDisposable
- {
- public Lua Lua { get; private set; }
- readonly Cache functionCache;
-
- public LuaScriptContext()
- {
- Log.AddChannel("lua", "lua.log");
- Log.Write("lua", "Creating Lua script context");
- Lua = new Lua();
- Lua.HookException += OnLuaException;
- functionCache = new Cache(Lua.GetFunction);
- }
-
- public void RegisterObject(object target, string tableName, bool exposeAllMethods)
- {
- Log.Write("lua", "Registering object {0}", target);
-
- if (tableName != null && Lua.GetTable(tableName) == null)
- Lua.NewTable(tableName);
-
- var type = target.GetType();
-
- var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance);
- RegisterMethods(tableName, target, methods, exposeAllMethods);
- }
-
- public void RegisterType(Type type, string tableName, bool exposeAllMethods)
- {
- Log.Write("lua", "Registering type {0}", type);
-
- if (tableName != null && Lua.GetTable(tableName) == null)
- Lua.NewTable(tableName);
-
- var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static);
- RegisterMethods(tableName, null, methods, exposeAllMethods);
- }
-
- void RegisterMethods(string tableName, object target, IEnumerable methods, bool allMethods)
- {
- foreach (var method in methods)
- {
- string methodName;
-
- var attr = method.GetCustomAttributes(true).FirstOrDefault();
- if (attr == null)
- {
- if (allMethods)
- methodName = method.Name;
- else
- continue;
- }
- else
- methodName = attr.Name ?? method.Name;
-
- var methodTarget = method.IsStatic ? null : target;
-
- if (tableName != null)
- Lua.RegisterFunction(tableName + "." + methodName, methodTarget, method);
- else
- Lua.RegisterFunction(methodName, methodTarget, method);
- }
- }
-
- void OnLuaException(object sender, HookExceptionEventArgs e)
- {
- ShowException(e.Exception);
- }
-
- void ShowException(Exception e)
- {
- ShowErrorMessage(e.Message, e.ToString());
- }
-
- public void ShowErrorMessage(string shortMessage, string longMessage)
- {
- Game.Debug("{0}", shortMessage);
- Game.Debug("See lua.log for details");
- Log.Write("lua", "{0}", longMessage ?? shortMessage);
- }
-
- public void LoadLuaScripts(Func getFileContents, params string[] files)
- {
- foreach (var file in files)
- {
- try
- {
- Log.Write("lua", "Loading Lua script {0}", file);
- var content = getFileContents(file);
- Lua.DoString(content, file);
- }
- catch (Exception e)
- {
- ShowException(e);
- }
- }
- }
-
- public object[] InvokeLuaFunction(string name, params object[] args)
- {
- try
- {
- var function = functionCache[name];
- if (function == null)
- return null;
- return function.Call(args);
- }
- catch (Exception e)
- {
- ShowException(e);
- return null;
- }
- }
-
- public void Dispose()
- {
- if (Lua != null)
- Lua.Dispose();
- }
- }
-}
diff --git a/OpenRA.Mods.RA/Scripting/LuaScriptEvents.cs b/OpenRA.Mods.RA/Scripting/LuaScriptEvents.cs
deleted file mode 100644
index 7dfdc049b6..0000000000
--- a/OpenRA.Mods.RA/Scripting/LuaScriptEvents.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-#region Copyright & License Information
-/*
- * Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
- * This file is part of OpenRA, which is free software. It is made
- * available to you under the terms of the GNU General Public License
- * as published by the Free Software Foundation. For more information,
- * see COPYING.
- */
-#endregion
-
-using System;
-using OpenRA.Traits;
-
-namespace OpenRA.Mods.RA.Scripting
-{
- [Desc("Part of the legacy Lua API.")]
- public class LuaScriptEventsInfo : TraitInfo { }
-
- public class LuaScriptEvents : INotifyKilled, INotifyAddedToWorld, INotifyRemovedFromWorld,
- INotifyCapture, INotifyDamage, INotifyIdle, INotifyProduction
- {
- public event Action OnKilled = (self, e) => { };
- public event Action OnAddedToWorld = self => { };
- public event Action OnRemovedFromWorld = self => { };
- public event Action OnCaptured = (self, captor, oldOwner, newOwner) => { };
- public event Action OnDamaged = (self, e) => { };
- public event Action OnIdle = self => { };
- public event Action OnProduced = (self, other, exit) => { };
-
- public void Killed(Actor self, AttackInfo e)
- {
- OnKilled(self, e);
- }
-
- public void AddedToWorld(Actor self)
- {
- OnAddedToWorld(self);
- }
-
- public void RemovedFromWorld(Actor self)
- {
- OnRemovedFromWorld(self);
- }
-
- public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
- {
- OnCaptured(self, captor, oldOwner, newOwner);
- }
-
- public void Damaged(Actor self, AttackInfo e)
- {
- OnDamaged(self, e);
- }
-
- public void TickIdle(Actor self)
- {
- OnIdle(self);
- }
-
- public void UnitProduced(Actor self, Actor other, CPos exit)
- {
- OnProduced(self, other, exit);
- }
- }
-}
diff --git a/OpenRA.Mods.RA/Scripting/LuaScriptInterface.cs b/OpenRA.Mods.RA/Scripting/LuaScriptInterface.cs
deleted file mode 100644
index fe8e22b888..0000000000
--- a/OpenRA.Mods.RA/Scripting/LuaScriptInterface.cs
+++ /dev/null
@@ -1,470 +0,0 @@
-#region Copyright & License Information
-/*
- * Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
- * This file is part of OpenRA, which is free software. It is made
- * available to you under the terms of the GNU General Public License
- * as published by the Free Software Foundation. For more information,
- * see COPYING.
- */
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using NLua;
-using OpenRA.Effects;
-using OpenRA.FileSystem;
-using OpenRA.Mods.RA.Activities;
-using OpenRA.Mods.RA.Air;
-using OpenRA.Network;
-using OpenRA.Scripting;
-using OpenRA.Support;
-using OpenRA.Traits;
-using WorldRenderer = OpenRA.Graphics.WorldRenderer;
-
-namespace OpenRA.Mods.RA.Scripting
-{
- [Desc("Part of the legacy Lua API.")]
- public class LuaScriptInterfaceInfo : ITraitInfo, Requires
- {
- public readonly string[] LuaScripts = { };
-
- public object Create(ActorInitializer init) { return new LuaScriptInterface(this); }
- }
-
- public sealed class LuaScriptInterface : IWorldLoaded, ITick, IDisposable
- {
- World world;
- SpawnMapActors sma;
- readonly LuaScriptContext context = new LuaScriptContext();
- readonly LuaScriptInterfaceInfo info;
-
- public LuaScriptInterface(LuaScriptInterfaceInfo info)
- {
- this.info = info;
- }
-
- public void WorldLoaded(World w, WorldRenderer wr)
- {
- world = w;
- sma = world.WorldActor.Trait();
-
- context.Lua["World"] = w;
- context.Lua["WorldRenderer"] = wr;
- context.RegisterObject(this, "Internal", false);
- context.RegisterType(typeof(WVec), "WVec", true);
- context.RegisterType(typeof(CVec), "CVec", true);
- context.RegisterType(typeof(WPos), "WPos", true);
- context.RegisterType(typeof(CPos), "CPos", true);
- context.RegisterType(typeof(WRot), "WRot", true);
- context.RegisterType(typeof(WAngle), "WAngle", true);
- context.RegisterType(typeof(WRange), "WRange", true);
- context.RegisterType(typeof(int2), "int2", true);
- context.RegisterType(typeof(float2), "float2", true);
-
- context.LoadLuaScripts(f => GlobalFileSystem.Open(f).ReadAllText(), Game.modData.Manifest.LuaScripts);
-
- AddMapActorGlobals();
-
- context.LoadLuaScripts(f => w.Map.Container.GetContent(f).ReadAllText(), info.LuaScripts);
-
- context.InvokeLuaFunction("WorldLoaded");
- }
-
- void AddMapActorGlobals()
- {
- foreach (var kv in sma.Actors)
- {
- if (context.Lua[kv.Key] != null)
- context.ShowErrorMessage("{0}: The global name '{1}' is reserved and may not be used by map actor {2}".F(GetType().Name, kv.Key, kv.Value), null);
- else
- context.Lua[kv.Key] = kv.Value;
- }
- }
-
- public void Tick(Actor self)
- {
- using (new PerfSample("tick_lua"))
- context.InvokeLuaFunction("Tick");
- }
-
- public void Dispose()
- {
- context.Dispose();
- }
-
- [LuaGlobal]
- public object New(string typeName, LuaTable args)
- {
- var type = Game.modData.ObjectCreator.FindType(typeName);
- if (type == null)
- throw new InvalidOperationException("Cannot locate type: {0}".F(typeName));
- if (args == null)
- return Activator.CreateInstance(type);
- var argsArray = ConvertArgs(args);
- return Activator.CreateInstance(type, argsArray);
- }
-
- static object[] ConvertArgs(LuaTable args)
- {
- var argsArray = new object[args.Keys.Count];
- for (var i = 1; i <= args.Keys.Count; i++)
- {
- var arg = args[i] as LuaTable;
- if (arg != null && arg[1] != null && arg[2] != null)
- argsArray[i - 1] = Convert.ChangeType(arg[1], Enum.Parse(arg[2].ToString()));
- else
- argsArray[i - 1] = args[i];
- }
- return argsArray;
- }
-
- [LuaGlobal]
- public void Debug(object obj)
- {
- if (obj != null)
- Game.Debug(obj.ToString());
- }
-
- [LuaGlobal]
- public object TraitOrDefault(Actor actor, string className)
- {
- var type = Game.modData.ObjectCreator.FindType(className);
- if (type == null)
- return null;
-
- var method = typeof(Actor).GetMethod("TraitOrDefault");
- var genericMethod = method.MakeGenericMethod(type);
- return genericMethod.Invoke(actor, null);
- }
-
- [LuaGlobal]
- public object Trait(Actor actor, string className)
- {
- var ret = TraitOrDefault(actor, className);
- if (ret == null)
- throw new InvalidOperationException("Actor {0} does not have trait of type {1}".F(actor, className));
- return ret;
- }
-
- [LuaGlobal]
- public bool HasTrait(Actor actor, string className)
- {
- var ret = TraitOrDefault(actor, className);
- return ret != null;
- }
-
- [LuaGlobal]
- public object[] ActorsWithTrait(string className)
- {
- var type = Game.modData.ObjectCreator.FindType(className);
- if (type == null)
- throw new InvalidOperationException("Cannot locate type: {0}".F(className));
-
- var method = typeof(World).GetMethod("ActorsWithTrait");
- var genericMethod = method.MakeGenericMethod(type);
- var result = ((IEnumerable)genericMethod.Invoke(world, null)).Cast