diff --git a/.Experimental/LuaNetworkVariables/Main.cs b/.Experimental/LuaNetworkVariables/Main.cs index ce59fa0..2a8b2fb 100644 --- a/.Experimental/LuaNetworkVariables/Main.cs +++ b/.Experimental/LuaNetworkVariables/Main.cs @@ -2,9 +2,9 @@ using MelonLoader; using UnityEngine; -namespace NAK.LuaNetworkVariables; +namespace NAK.LuaNetVars; -public class LuaNetworkVariablesMod : MelonMod +public class LuaNetVarsMod : MelonMod { internal static MelonLogger.Instance Logger; diff --git a/.Experimental/LuaNetworkVariables/NetLuaModule.cs b/.Experimental/LuaNetworkVariables/NetLuaModule.cs index 23855ed..b13bc9b 100644 --- a/.Experimental/LuaNetworkVariables/NetLuaModule.cs +++ b/.Experimental/LuaNetworkVariables/NetLuaModule.cs @@ -3,7 +3,7 @@ using ABI.Scripting.CVRSTL.Common; using JetBrains.Annotations; using MoonSharp.Interpreter; -namespace NAK.LuaNetworkVariables.Modules; +namespace NAK.LuaNetVars.Modules; [PublicAPI] public class LuaNetModule : BaseScriptedStaticWrapper @@ -37,7 +37,7 @@ public class LuaNetModule : BaseScriptedStaticWrapper if (_controller == null) { - LuaNetworkVariablesMod.Logger.Error("LuaNetVarController is null."); + LuaNetVarsMod.Logger.Error("LuaNetVarController is null."); return; } @@ -56,7 +56,7 @@ public class LuaNetModule : BaseScriptedStaticWrapper if (_controller == null) { - LuaNetworkVariablesMod.Logger.Error("LuaNetVarController is null."); + LuaNetVarsMod.Logger.Error("LuaNetVarController is null."); return; } @@ -75,7 +75,7 @@ public class LuaNetModule : BaseScriptedStaticWrapper if (_controller == null) { - LuaNetworkVariablesMod.Logger.Error("LuaNetVarController is null."); + LuaNetVarsMod.Logger.Error("LuaNetVarController is null."); return; } @@ -94,7 +94,7 @@ public class LuaNetModule : BaseScriptedStaticWrapper if (_controller == null) { - LuaNetworkVariablesMod.Logger.Error("LuaNetVarController is null."); + LuaNetVarsMod.Logger.Error("LuaNetVarController is null."); return; } @@ -113,7 +113,7 @@ public class LuaNetModule : BaseScriptedStaticWrapper if (_controller == null) { - LuaNetworkVariablesMod.Logger.Error("LuaNetVarController is null."); + LuaNetVarsMod.Logger.Error("LuaNetVarController is null."); return; } @@ -130,7 +130,7 @@ public class LuaNetModule : BaseScriptedStaticWrapper if (_controller == null) { - LuaNetworkVariablesMod.Logger.Error("LuaNetVarController is null."); + LuaNetVarsMod.Logger.Error("LuaNetVarController is null."); return false; } @@ -144,7 +144,7 @@ public class LuaNetModule : BaseScriptedStaticWrapper if (_controller == null) { - LuaNetworkVariablesMod.Logger.Error("LuaNetVarController is null."); + LuaNetVarsMod.Logger.Error("LuaNetVarController is null."); return string.Empty; } diff --git a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaEventContext.cs b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaEventContext.cs index 59b385e..6a3fd57 100644 --- a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaEventContext.cs +++ b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaEventContext.cs @@ -2,7 +2,7 @@ using MoonSharp.Interpreter; using ABI_RC.Core.Player; -namespace NAK.LuaNetworkVariables; +namespace NAK.LuaNetVars; public struct LuaEventContext { diff --git a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaEventTracker.cs b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaEventTracker.cs index 98f6322..ed60cee 100644 --- a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaEventTracker.cs +++ b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaEventTracker.cs @@ -1,4 +1,4 @@ -namespace NAK.LuaNetworkVariables; +namespace NAK.LuaNetVars; internal class LuaEventTracker { diff --git a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Base.cs b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Base.cs index 51e60e8..811fa9b 100644 --- a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Base.cs +++ b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Base.cs @@ -7,7 +7,7 @@ using MoonSharp.Interpreter; using UnityEngine; using Coroutine = UnityEngine.Coroutine; -namespace NAK.LuaNetworkVariables; +namespace NAK.LuaNetVars; public partial class LuaNetVarController : MonoBehaviour { @@ -58,13 +58,13 @@ public partial class LuaNetVarController : MonoBehaviour if (ModNetworkID.Length > ModNetworkManager.MaxMessageIdLength) { - LuaNetworkVariablesMod.Logger.Error($"ModNetworkID ({ModNetworkID}) exceeds max length of {ModNetworkManager.MaxMessageIdLength} characters!"); + LuaNetVarsMod.Logger.Error($"ModNetworkID ({ModNetworkID}) exceeds max length of {ModNetworkManager.MaxMessageIdLength} characters!"); return false; } _hashes.Add(_uniquePathHash); ModNetworkManager.Subscribe(ModNetworkID, OnMessageReceived); - LuaNetworkVariablesMod.Logger.Msg($"Registered LuaNetVarController with ModNetworkID: {ModNetworkID}"); + LuaNetVarsMod.Logger.Msg($"Registered LuaNetVarController with ModNetworkID: {ModNetworkID}"); switch (_luaClientBehaviour.Context.objContext) { @@ -101,7 +101,7 @@ public partial class LuaNetVarController : MonoBehaviour return; ModNetworkManager.Unsubscribe(ModNetworkID); - LuaNetworkVariablesMod.Logger.Msg($"Unsubscribed LuaNetVarController with ModNetworkID: {ModNetworkID}"); + LuaNetVarsMod.Logger.Msg($"Unsubscribed LuaNetVarController with ModNetworkID: {ModNetworkID}"); _hashes.Remove(_uniquePathHash); } diff --git a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Networking.cs b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Networking.cs index a674987..bed3bb8 100644 --- a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Networking.cs +++ b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Networking.cs @@ -2,7 +2,7 @@ using ABI_RC.Systems.ModNetwork; using MoonSharp.Interpreter; -namespace NAK.LuaNetworkVariables +namespace NAK.LuaNetVars { public partial class LuaNetVarController { @@ -46,7 +46,7 @@ namespace NAK.LuaNetworkVariables msg.Read(out string varName); DynValue newValue = DeserializeDynValue(msg); - LuaNetworkVariablesMod.Logger.Msg($"Received LuaVariable update: {varName} = {newValue}"); + LuaNetVarsMod.Logger.Msg($"Received LuaVariable update: {varName} = {newValue}"); if (_registeredNetworkVars.TryGetValue(varName, out DynValue var)) { @@ -54,7 +54,7 @@ namespace NAK.LuaNetworkVariables } else { - LuaNetworkVariablesMod.Logger.Warning($"Received update for unregistered variable {varName}"); + LuaNetVarsMod.Logger.Warning($"Received update for unregistered variable {varName}"); } } @@ -79,7 +79,7 @@ namespace NAK.LuaNetworkVariables args[i + 1] = DeserializeDynValue(msg); } - LuaNetworkVariablesMod.Logger.Msg($"Received LuaEvent: {eventName} from {context.SenderName} with {argsCount} args"); + LuaNetVarsMod.Logger.Msg($"Received LuaEvent: {eventName} from {context.SenderName} with {argsCount} args"); InvokeLuaEvent(eventName, args); } @@ -98,7 +98,7 @@ namespace NAK.LuaNetworkVariables } else { - LuaNetworkVariablesMod.Logger.Warning($"Received sync for unregistered variable {varName}"); + LuaNetVarsMod.Logger.Warning($"Received sync for unregistered variable {varName}"); } } } @@ -121,7 +121,7 @@ namespace NAK.LuaNetworkVariables } else { - LuaNetworkVariablesMod.Logger.Warning($"No registered callback for event {eventName}"); + LuaNetVarsMod.Logger.Warning($"No registered callback for event {eventName}"); } } @@ -159,7 +159,7 @@ namespace NAK.LuaNetworkVariables } modMsg.Send(); - LuaNetworkVariablesMod.Logger.Msg($"Sent variable sync to {userId}"); + LuaNetVarsMod.Logger.Msg($"Sent variable sync to {userId}"); } private void RequestVariableSync() @@ -167,7 +167,7 @@ namespace NAK.LuaNetworkVariables using ModNetworkMessage modMsg = new(ModNetworkID); modMsg.Write((byte)MessageType.RequestSync); modMsg.Send(); - LuaNetworkVariablesMod.Logger.Msg("Requested variable sync"); + LuaNetVarsMod.Logger.Msg("Requested variable sync"); } // private DynValue SendLuaEventCallback(ScriptExecutionContext context, CallbackArguments args) diff --git a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Registration.cs b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Registration.cs index fde4fdf..e68170f 100644 --- a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Registration.cs +++ b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Registration.cs @@ -1,6 +1,6 @@ using MoonSharp.Interpreter; -namespace NAK.LuaNetworkVariables; +namespace NAK.LuaNetVars; public partial class LuaNetVarController { @@ -8,7 +8,7 @@ public partial class LuaNetVarController { if (_registeredNetworkVars.ContainsKey(varName)) { - LuaNetworkVariablesMod.Logger.Warning($"Network variable {varName} already registered!"); + LuaNetVarsMod.Logger.Warning($"Network variable {varName} already registered!"); return; } @@ -18,7 +18,7 @@ public partial class LuaNetVarController RegisterGetterFunction(varName); RegisterSetterFunction(varName); - LuaNetworkVariablesMod.Logger.Msg($"Registered network variable {varName}"); + LuaNetVarsMod.Logger.Msg($"Registered network variable {varName}"); } private void RegisterGetterFunction(string varName) @@ -38,7 +38,7 @@ public partial class LuaNetVarController var newValue = args[0]; if (!IsSupportedDynValue(newValue)) { - LuaNetworkVariablesMod.Logger.Error($"Unsupported DynValue type: {newValue.Type} for variable {varName}"); + LuaNetVarsMod.Logger.Error($"Unsupported DynValue type: {newValue.Type} for variable {varName}"); return DynValue.Nil; } @@ -68,10 +68,10 @@ public partial class LuaNetVarController if (!ValidateCallback(callback) || !ValidateNetworkVar(varName)) return; if (_registeredNotifyCallbacks.ContainsKey(varName)) - LuaNetworkVariablesMod.Logger.Warning($"Overwriting notify callback for {varName}"); + LuaNetVarsMod.Logger.Warning($"Overwriting notify callback for {varName}"); _registeredNotifyCallbacks[varName] = callback; - LuaNetworkVariablesMod.Logger.Msg($"Registered notify callback for {varName}"); + LuaNetVarsMod.Logger.Msg($"Registered notify callback for {varName}"); } internal void RegisterEventCallback(string eventName, DynValue callback) @@ -79,23 +79,23 @@ public partial class LuaNetVarController if (!ValidateCallback(callback)) return; if (_registeredEventCallbacks.ContainsKey(eventName)) - LuaNetworkVariablesMod.Logger.Warning($"Overwriting event callback for {eventName}"); + LuaNetVarsMod.Logger.Warning($"Overwriting event callback for {eventName}"); _registeredEventCallbacks[eventName] = callback; - LuaNetworkVariablesMod.Logger.Msg($"Registered event callback for {eventName}"); + LuaNetVarsMod.Logger.Msg($"Registered event callback for {eventName}"); } private bool ValidateCallback(DynValue callback) { if (callback?.Function != null) return true; - LuaNetworkVariablesMod.Logger.Error("Passed DynValue must be a function"); + LuaNetVarsMod.Logger.Error("Passed DynValue must be a function"); return false; } private bool ValidateNetworkVar(string varName) { if (_registeredNetworkVars.ContainsKey(varName)) return true; - LuaNetworkVariablesMod.Logger.Error($"Attempted to register notify callback for non-registered variable {varName}."); + LuaNetVarsMod.Logger.Error($"Attempted to register notify callback for non-registered variable {varName}."); return false; } } \ No newline at end of file diff --git a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Serialization.cs b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Serialization.cs index ba20565..57221a7 100644 --- a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Serialization.cs +++ b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Serialization.cs @@ -1,7 +1,7 @@ using ABI_RC.Systems.ModNetwork; using MoonSharp.Interpreter; -namespace NAK.LuaNetworkVariables; +namespace NAK.LuaNetVars; public partial class LuaNetVarController { @@ -24,7 +24,7 @@ public partial class LuaNetVarController case DataType.Nil: return DynValue.Nil; default: - LuaNetworkVariablesMod.Logger.Error($"Unsupported data type received: {dataType}"); + LuaNetVarsMod.Logger.Error($"Unsupported data type received: {dataType}"); return DynValue.Nil; } } @@ -49,7 +49,7 @@ public partial class LuaNetVarController msg.Write((byte)DataType.Nil); break; default: - LuaNetworkVariablesMod.Logger.Error($"Unsupported DynValue type: {value.Type}"); + LuaNetVarsMod.Logger.Error($"Unsupported DynValue type: {value.Type}"); msg.Write((byte)DataType.Nil); break; } diff --git a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Utility.cs b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Utility.cs index d52d504..7712781 100644 --- a/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Utility.cs +++ b/.Experimental/LuaNetworkVariables/NetworkVariables/LuaNetVarController.Utility.cs @@ -1,7 +1,7 @@ using ABI_RC.Core.Savior; using UnityEngine; -namespace NAK.LuaNetworkVariables; +namespace NAK.LuaNetVars; public partial class LuaNetVarController { @@ -13,10 +13,10 @@ public partial class LuaNetVarController // Check if it already exists (this **should** only matter in worlds) if (_hashes.Contains(hash)) { - LuaNetworkVariablesMod.Logger.Warning($"Duplicate RelativeSyncMarker found at path {path}"); + LuaNetVarsMod.Logger.Warning($"Duplicate RelativeSyncMarker found at path {path}"); if (!FindAvailableHash(ref hash)) // Super lazy fix idfc { - LuaNetworkVariablesMod.Logger.Error($"Failed to find available hash for RelativeSyncMarker after 16 tries! {path}"); + LuaNetVarsMod.Logger.Error($"Failed to find available hash for RelativeSyncMarker after 16 tries! {path}"); return false; } } diff --git a/.Experimental/LuaNetworkVariables/Patches.cs b/.Experimental/LuaNetworkVariables/Patches.cs index a442013..672e1df 100644 --- a/.Experimental/LuaNetworkVariables/Patches.cs +++ b/.Experimental/LuaNetworkVariables/Patches.cs @@ -2,9 +2,9 @@ using ABI.Scripting.CVRSTL.Common; using HarmonyLib; using MoonSharp.Interpreter; -using NAK.LuaNetworkVariables.Modules; +using NAK.LuaNetVars.Modules; -namespace NAK.LuaNetworkVariables.Patches; +namespace NAK.LuaNetVars.Patches; internal static class LuaScriptFactory_Patches { diff --git a/.Experimental/LuaNetworkVariables/Properties/AssemblyInfo.cs b/.Experimental/LuaNetworkVariables/Properties/AssemblyInfo.cs index 66b2858..84217ef 100644 --- a/.Experimental/LuaNetworkVariables/Properties/AssemblyInfo.cs +++ b/.Experimental/LuaNetworkVariables/Properties/AssemblyInfo.cs @@ -1,17 +1,17 @@ -using NAK.LuaNetworkVariables.Properties; +using NAK.LuaNetVars.Properties; using MelonLoader; using System.Reflection; [assembly: AssemblyVersion(AssemblyInfoParams.Version)] [assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] [assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] -[assembly: AssemblyTitle(nameof(NAK.LuaNetworkVariables))] +[assembly: AssemblyTitle(nameof(NAK.LuaNetVars))] [assembly: AssemblyCompany(AssemblyInfoParams.Author)] -[assembly: AssemblyProduct(nameof(NAK.LuaNetworkVariables))] +[assembly: AssemblyProduct(nameof(NAK.LuaNetVars))] [assembly: MelonInfo( - typeof(NAK.LuaNetworkVariables.LuaNetworkVariablesMod), - nameof(NAK.LuaNetworkVariables), + typeof(NAK.LuaNetVars.LuaNetVarsMod), + nameof(NAK.LuaNetVars), AssemblyInfoParams.Version, AssemblyInfoParams.Author, downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/LuaNetworkVariables" @@ -24,9 +24,9 @@ using System.Reflection; [assembly: MelonAuthorColor(255, 158, 21, 32)] // red [assembly: HarmonyDontPatchAll] -namespace NAK.LuaNetworkVariables.Properties; +namespace NAK.LuaNetVars.Properties; internal static class AssemblyInfoParams { - public const string Version = "1.0.2"; + public const string Version = "1.0.1"; public const string Author = "NotAKidoS"; } \ No newline at end of file diff --git a/.Experimental/LuaNetworkVariables/README.md b/.Experimental/LuaNetworkVariables/README.md index 5ad6ee2..c78a56a 100644 --- a/.Experimental/LuaNetworkVariables/README.md +++ b/.Experimental/LuaNetworkVariables/README.md @@ -1,77 +1,6 @@ -# LuaNetworkVariables +# WhereAmIPointing -Adds a simple module for creating network variables & events *kinda* similar to Garry's Mod. - -Example Usage: -```lua --- Requires UnityEngine and NetworkModule -UnityEngine = require("UnityEngine") -NetworkModule = require("NetworkModule") - --- Unity Events -- - -function Start() - - if NetworkModule == nil then - print("NetworkModule did not load.") - return - end - - -- Registers "AvatarHeight" as a network variable - -- This creates Get and Set functions (GetAvatarHeight() and SetAvatarHeight()) - NetworkModule:RegisterNetworkVar("AvatarHeight") - - -- Registers a callback for when "AvatarHeight" is changed. - NetworkModule:RegisterNotifyCallback("AvatarHeight", function(varName, oldValue, newValue) - print(varName .. " changed from " .. tostring(oldValue) .. " to " .. tostring(newValue)) - end) - - -- Registers "ButtonClickedEvent" as a networked event. This provides context alongside the arguments passed. - NetworkModule:RegisterEventCallback("ButtonClickedEvent", function(context, message) - print("ButtonClickedEvent triggered by " .. tostring(context.SenderName) .. " with message: " .. tostring(message)) - print("Context details:") - print(" SenderId: " .. tostring(context.SenderId)) - print(" SenderName: " .. tostring(context.SenderName)) - print(" LastInvokeTime: " .. tostring(context.LastInvokeTime)) - print(" TimeSinceLastInvoke: " .. tostring(context.TimeSinceLastInvoke)) - print(" IsLocal: " .. tostring(context.IsLocal)) - end) - - -- Secondry example - NetworkModule:RegisterEventCallback("CoolEvent", OnCoolEventOccured) -end - -function Update() - if not NetworkModule:IsSyncOwner() then - return - end - - SetAvatarHeight(PlayerAPI.LocalPlayer:GetViewPointPosition().y) -end - --- Global Functions -- - -function SendClickEvent() - NetworkModule:SendLuaEvent("ButtonClickedEvent", "The button was clicked!") - print("Sent ButtonClickedEvent") -end - -function SendCoolEvent() - NetworkModule:SendLuaEvent("CoolEvent", 1, 2) -end - --- Listener Functions -- - -function OnCoolEventOccured(context, value, value2) - print("CoolEvent triggered by " .. tostring(context.SenderName)) - print("Received values: " .. tostring(value) .. ", " .. tostring(value2)) - print("Context details:") - print(" SenderId: " .. tostring(context.SenderId)) - print(" LastInvokeTime: " .. tostring(context.LastInvokeTime)) - print(" TimeSinceLastInvoke: " .. tostring(context.TimeSinceLastInvoke)) - print(" IsLocal: " .. tostring(context.IsLocal)) -end -``` +Simple mod that makes your controller rays always visible when the menus are open. Useful for when you're trying to aim at something in the distance. Also visualizes which ray is being used for menu interaction. --- diff --git a/README.md b/README.md index 93d8d1e..39be991 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ |------|-------------|----------| | [CVRLuaToolsExtension](.Experimental/CVRLuaToolsExtension/README.md) | Extension mod for [CVRLuaTools](https://github.com/NotAKidoS/CVRLuaTools) Hot Reload functionality. | No Download | | [CustomRichPresence](.Experimental/CustomRichPresence/README.md) | Lets you customize the Steam & Discord rich presence messages & values. | No Download | -| [LuaNetworkVariables](.Experimental/LuaNetworkVariables/README.md) | Adds a simple module for creating network variables & events *kinda* similar to Garry's Mod. | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/LuaNetworkVariables.dll) | +| [LuaNetworkVariables](.Experimental/LuaNetworkVariables/README.md) | Simple mod that makes your controller rays always visible when the menus are open. Useful for when you're trying to aim at something in the distance. Also visualizes which ray is being used for menu interaction. | No Download | | [LuaTTS](.Experimental/LuaTTS/README.md) | Provides access to the built-in text-to-speech (TTS) functionality to lua scripts. Allows you to make the local player speak. | No Download | | [OriginShift](.Experimental/OriginShift/README.md) | Experimental mod that allows world origin to be shifted to prevent floating point precision issues. | No Download | | [ScriptingSpoofer](.Experimental/ScriptingSpoofer/README.md) | Prevents **local** scripts from accessing your Username or UserID by spoofing them with random values each session. | No Download |