changes to client-side commands and added some physics related things
This commit is contained in:
@@ -3097,20 +3097,38 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.Add(new Command("lua_cl", "lua_cl: runs a string on the client", (string[] args) =>
|
commands.Add(new Command("cl_lua", "lua_cl: runs a string on the client", (string[] args) =>
|
||||||
{
|
{
|
||||||
if (GameMain.Client != null)
|
if (GameMain.Client == null)
|
||||||
GameMain.Lua.DoString(string.Join(" ", args));
|
{
|
||||||
else
|
ThrowError("Client not connected to a server.");
|
||||||
ThrowError("Client not connected to any server.");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands))
|
||||||
|
{
|
||||||
|
ThrowError("Command not permitted.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMain.Lua.DoString(string.Join(" ", args));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
commands.Add(new Command("reloadlua_cl", "reloads lua on the client", (string[] args) =>
|
commands.Add(new Command("cl_reloadlua", "reloads lua on the client", (string[] args) =>
|
||||||
{
|
{
|
||||||
if (GameMain.Client != null)
|
if (GameMain.Client == null)
|
||||||
GameMain.Lua.Initialize();
|
{
|
||||||
else
|
ThrowError("Client not connected to a server.");
|
||||||
ThrowError("Client not connected to any server.");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands))
|
||||||
|
{
|
||||||
|
ThrowError("Command not permitted.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMain.Lua.Initialize();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using System.IO;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using FarseerPhysics.Dynamics;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -88,6 +89,14 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public World World
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GameMain.World;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OverrideTraitors(bool o)
|
public void OverrideTraitors(bool o)
|
||||||
{
|
{
|
||||||
overrideTraitors = o;
|
overrideTraitors = o;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using FarseerPhysics.Dynamics;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,13 @@ namespace Barotrauma
|
|||||||
RegisterAction<Entity>();
|
RegisterAction<Entity>();
|
||||||
RegisterAction();
|
RegisterAction();
|
||||||
|
|
||||||
|
|
||||||
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Func<Fixture, Vector2, Vector2, float, float>), v =>
|
||||||
|
{
|
||||||
|
var function = v.Function;
|
||||||
|
return (Func<Fixture, Vector2, Vector2, float, float>)((Fixture a, Vector2 b, Vector2 c, float d) => new LuaResult(function.Call(a, b, c, d)).Float());
|
||||||
|
});
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUIButton.OnClickedHandler), v =>
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUIButton.OnClickedHandler), v =>
|
||||||
{
|
{
|
||||||
@@ -39,7 +47,6 @@ namespace Barotrauma
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void RegisterAction<T>()
|
public static void RegisterAction<T>()
|
||||||
{
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v =>
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v =>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using MoonSharp.Interpreter.Interop;
|
using MoonSharp.Interpreter.Interop;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using FarseerPhysics.Dynamics;
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
@@ -352,6 +353,10 @@ namespace Barotrauma
|
|||||||
UserData.RegisterType<Skill>();
|
UserData.RegisterType<Skill>();
|
||||||
UserData.RegisterType<SkillPrefab>();
|
UserData.RegisterType<SkillPrefab>();
|
||||||
|
|
||||||
|
UserData.RegisterType<World>();
|
||||||
|
UserData.RegisterType<Fixture>();
|
||||||
|
UserData.RegisterType(typeof(Physics));
|
||||||
|
|
||||||
UserData.RegisterType<Screen>();
|
UserData.RegisterType<Screen>();
|
||||||
UserData.RegisterType<GameScreen>();
|
UserData.RegisterType<GameScreen>();
|
||||||
UserData.RegisterType<Camera>();
|
UserData.RegisterType<Camera>();
|
||||||
@@ -462,6 +467,7 @@ namespace Barotrauma
|
|||||||
lua.Globals["SubmarineInfo"] = UserData.CreateStatic<SubmarineInfo>();
|
lua.Globals["SubmarineInfo"] = UserData.CreateStatic<SubmarineInfo>();
|
||||||
lua.Globals["Rectangle"] = UserData.CreateStatic<Rectangle>();
|
lua.Globals["Rectangle"] = UserData.CreateStatic<Rectangle>();
|
||||||
lua.Globals["Entity"] = UserData.CreateStatic<Entity>();
|
lua.Globals["Entity"] = UserData.CreateStatic<Entity>();
|
||||||
|
lua.Globals["Physics"] = UserData.CreateStatic(typeof(Physics));
|
||||||
|
|
||||||
#if SERVER
|
#if SERVER
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user