Public[]
Utils[]
public static class Utils { internal static readonly Random random = new Random(); internal static int confirmationModalState = -1;
public static void SetIntVar(string variable, int value) { var gameVariableService = ServiceRepository.GetService<IGameVariableService>(); var variableName = variable.ToUpper();
if (gameVariableService != null) { if (gameVariableService.IsVariableRegistered(variableName)) { gameVariableService.ActiveVariables.Find(x => x.Name == variableName).IntValue = value; } else { gameVariableService.RegisterVariable(variableName, GameVariableDefinitions.Scope.Campaign, value); } } }
public static int GetIntVar(string variable) { var gameVariableService = ServiceRepository.GetService<IGameVariableService>(); var variableName = variable.ToUpper();
if (gameVariableService.IsVariableRegistered(variableName)) { return gameVariableService.ActiveVariables.Find(x => x.Name == variableName).IntValue; } else { gameVariableService.RegisterVariable(variableName, GameVariableDefinitions.Scope.Campaign, 0); return 0; } }
public static void SetStrVar(string variable, string value) { var gameVariableService = ServiceRepository.GetService<IGameVariableService>(); var variableName = variable.ToUpper();
if (gameVariableService != null) { if (gameVariableService.IsVariableRegistered(variableName)) { gameVariableService.ActiveVariables.Find(x => x.Name == variableName).StringValue = value; } else { gameVariableService.RegisterVariable(variableName, GameVariableDefinitions.Scope.Campaign, value); } } }
public static string GetStrVar(string variable) { var gameVariableService = ServiceRepository.GetService<IGameVariableService>(); var variableName = variable.ToUpper();
if (gameVariableService.IsVariableRegistered(variableName)) { return gameVariableService.ActiveVariables.Find(x => x.Name == variableName).StringValue; } else { gameVariableService.RegisterVariable(variableName, GameVariableDefinitions.Scope.Campaign, string.Empty); return string.Empty; } }
public static void Log(string message) { Main.Warning($"[Lua]:{message}"); }
public static int Random(int min, int max) { return random.Next(int.Parse(min.ToString()), int.Parse(max.ToString())); }
public static void Message(string confirmationTitle, string confirmationDescription) { var gameLocationService = ServiceRepository.GetService<IGameLocationService>();
if (gameLocationService?.LocationIsReady == true) { Gui.GuiService.ShowMessage( MessageModal.Severity.Informative1, confirmationTitle.ToString(), confirmationDescription.ToString(), "Message/&MessageOkTitle", String.Empty, delegate () { }, delegate () { }); } }
public static void Confirm( string confirmationTitle, string confirmationDescription, string variableName, string leftButtonTitle = null, string rightButtonTitle = null) { var gameLocationService = ServiceRepository.GetService<IGameLocationService>();
if (gameLocationService?.LocationIsReady == true) { var gameVariableService = ServiceRepository.GetService<IGameVariableService>();
if (leftButtonTitle == null) leftButtonTitle = "Message/&MessageYesTitle"; if (rightButtonTitle == null) rightButtonTitle = "Message/&MessageNoTitle";
Gui.GuiService.ShowMessage( MessageModal.Severity.Attention2, confirmationTitle.ToString(), confirmationDescription.ToString(), leftButtonTitle.ToString(), rightButtonTitle.ToString(), delegate () { gameVariableService.RegisterVariable(variableName.ToString().ToUpper(), GameVariableDefinitions.Scope.Location, 1); }, delegate () { gameVariableService.RegisterVariable(variableName.ToString().ToUpper(), GameVariableDefinitions.Scope.Location, 0); }); } } }
}
UserGadget[]
public class UserGadget {
public const string KeyItemTag = "KeyItem";
public UserGadget(); public UserGadget(GadgetBlueprint gadgetBlueprint);
public GadgetBlueprint GadgetBlueprint { get; set; } public Vector2Int Dimensions { get; } public LocationDefinitions.Orientation Orientation { get; set; } public Vector2Int Position { get; set; } public string UniqueName { get; set; } public bool[] ValidInteractionNodes { get; } public bool Moving { get; set; } public string GadgetBlueprintName { get; } public GadgetRefreshedHandler GadgetRefreshed { get; set; } public int OrientedHeight { get; } public bool Invalid { get; set; } public int OrientedWidth { get; } public List<UserGadgetParameterValue> ParameterValues { get; }
public void ApplyParameters(WorldGadget worldGadget, List<WorldGadget> allWorldGadgets, UserCampaign userCampaign); public void ApplySpecialDimensions(WorldGadget worldGadget); public bool AreParametersValid(string userLocationName, string userCampaignName); public UserGadget Clone(); public bool Contains(UserGadget userGadget); public bool Contains(UserProp userProp); public int GetIntParameterValue(GadgetBlueprintDefinitions.Type type); public bool IsParameterVisible(UserGadgetParameterValue userGadgetParameterValue); public bool Overlaps(UserProp userProp); public bool Overlaps(UserGadget userGadget); public void PostLoadJson(ref bool someContentRemoved); public void PreSaveJson(); public void SetCustomDimensions(Vector2Int dimensions);
public delegate void GadgetRefreshedHandler(bool rebind);
}
GameGadget[]
public class GameGadget : ISerializable, IPersistentDataHolder<GameGadgetPersistentData>, IListenerEventProvider, IEntityImplementation {
public const string DefaultContainerName = "Chest";
public GameGadget(string name, GameGadgetDefinitions.InitInfo initInfo);
public GameGadgetDefinitions.GadgetDirtyHandler GadgetDirty { get; set; } public GameGadgetDefinitions.GadgetRefreshedHandler GadgetRefreshed { get; set; } public GameGadgetDefinitions.ConditionStatusChangedHandler ConditionStatusChanged { get; set; } public GameGadgetDefinitions.InteractedByCharacterHandler InteractedByCharacter { get; set; } public GameGadgetDefinitions.GadgetEventRaisedHandler GadgetEventRaised { get; set; } public GameGadgetDefinitions.BoundCharacterDamagedHandler BoundCharacterDamaged { get; set; } public GameGadgetDefinitions.BoundCharacterAlterationInflictedHandler BoundCharacterAlterationInflicted { get; set; } public GameGadgetDefinitions.BoundCharacterTagRevealedHandler BoundCharacterTagRevealed { get; set; } public ulong GadgetGuid { get; set; } public string UniqueNameId { get; } public bool Dirty { get; } public Dictionary<int, bool> CurrentConditionStates { get; } public Dictionary<int, GadgetDefinitions.DynamicRequirement> DynamicRequirements { get; } public Dictionary<int, LightingInformation> LightingInformationPerFlow { get; set; } public GameLocationCharacter CurrentlyInteractingCharacter { get; } public RulesetContainer ItemContainer { get; } public Dictionary<string, List<ulong>> FailedAttemptsByFlag { get; } public bool Revealed { get; } public GadgetDefinition GadgetDefinition { get; set; } public Vector3 FeedbackPosition { get; set; } public Dictionary<string, List<ulong>> FailedAttemptsAlternateByFlag { get; } public List<GameGadgetListener> ActiveListeners { get; } public BoxInt ReferenceBoundingBox { get; } public Dictionary<ulong, string> FlowsToReplay { get; } public bool HasValidScope { get; } public ulong PendingEncounterId { get; set; } public int DebugForceFlowIndex { get; set; } public List<GameLocationCharacter> FilteredCharacters { get; }
public static void SerializeTemporaryReference(IAttributesSerializer serializer, IVersionProvider versionProvider, ref GameGadget gadget, string referenceName); public void Bind(); public void BindCharacter(GameLocationCharacter character); public void BuildContainerAndContent(LootableContainerDefinition containerDefinition, List<ItemDefinition> explicitItemDefinitions); public void BuildContainerAndContent(LootableContainerDefinition containerDefinition, LootPackDefinition lootPackDefinition); public bool CanInteract(GameLocationCharacter actingCharacter); public bool CheckHasActiveDetectedTrap(); public bool CheckIsEnabled(); public bool CheckIsLocked(); public void ClearPrespawnedCharacters(int flowIndex, int functorIndex); public bool ComputeIsRevealed(); [IteratorStateMachine(typeof(<ExecuteFunctorSequenceAsync>d__148))] public IEnumerator ExecuteFunctorSequenceAsync(int listenerIndex); public void ExecuteFunctorSequenceSync(int listenerIndex); public void FinalizePostLoad(); public void FirstTimeInitialize(); public void ForceRefreshInvolvedCharacters(); public List<GameLocationCharacter> GetInvolvedCharacters(int flowIndex); public List<GameLocationCharacter> GetPrespawnedCharacters(int flowIndex, int functorIndex); public List<GraphicsCharacter> GetPrespawnedGraphicsCharacters(int flowIndex, int functorIndex); public void Interact(int listenerIndex, GameLocationCharacter actingCharacter); public void OnBoundCharacterAlterationInflicted(RulesetActor source, RulesetActor character, AlterationForm.Type alterationInflicted); public void OnBoundCharacterDamaged(RulesetActor character, int damage, string damageType, ulong sourceGuid, RollInfo rollInfo); public void OnBoundCharacterTagRevealed(RulesetActor character, string revealedTag); public void PostLoad(); public void PreloadSpawners(); public void RaiseGadgetEvent(string eventName, List<GameLocationCharacter> actingCharacters); public void Register(); public void RegisterSimpleCharacter(int requestId); public void RemoveSimpleCharacters(); public void ReplayFlow(IFunctorService functorService, string flowId, FunctorDefinitions.ReplayableFunctorContext context); public void RestorePersistentData(GameGadgetPersistentData gadgetData); public void RestorePersistentData(GameLocationPersistentData data); public GameGadgetPersistentData SavePersistentData(GameLocationPersistentData data); public void SerializeAttributes(IAttributesSerializer serializer, IVersionProvider versionProvider); public void SerializeElements(IElementsSerializer serializer, IVersionProvider versionProvider); public void SetCondition(int conditionIndex, bool state, List<GameLocationCharacter> actingCharacters); public void Shutdown(); public void Unbind(); public void UnbindCharacter(GameLocationCharacter character); public void Unregister(); public void UnregisterPrespawnedCharacters(); public bool Update(bool fastTravelSimulation, ref bool fastTravelSimulationInterrupted); public bool WillBeTriggeredByFastTravel(out bool isRelevant);
public struct FunctorPrespawnInfos { public int flowIndex; public int functorIndex; public List<GameLocationCharacter> preparedCharacters; } public struct LightingInformation { public LocationDefinitions.LightingState lightingState; public BoxInt perceptionBox; } public struct FunctorSimplePrespawnInfos { public int flowIndex; public int functorIndex; public List<GraphicsCharacter> simpleGraphicsCharacters; }
public class FlowSaveData : ISerializable { public FlowSaveData();
public bool PendingTrigger { get; set; } public int Counter { get; set; } public int Counter2 { get; set; } public int HoursElapsed { get; set; }
public void SerializeAttributes(IAttributesSerializer serializer, IVersionProvider versionProvider); public void SerializeElements(IElementsSerializer serializer, IVersionProvider versionProvider); }
}
Help[]
All Lua scripting is contained within mapname.lua and is specific to each map. Remember to remove DEBUG messages when you have finished testing.
![]() |
![]() |
![]() |
![]() |