Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions WoLua/ExcelContainer.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace PrincessRTFM.WoLua;

public static class ExcelContainer {
private static Lazy<ExcelSheet<T>> init<T>() where T: ExcelRow {
private static Lazy<ExcelSheet<T>> init<T>() where T: struct, IExcelRow<T> {
return new(() => {
if (Service.DataManager is null)
throw new InvalidOperationException("Cannot load excel sheet without DataManager instance", new NullReferenceException("Service.DataManager does not exist"));
Expand Down
4 changes: 2 additions & 2 deletions WoLua/Game/ServerChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace PrincessRTFM.WoLua.Game;

internal class ServerChat {
private static class Signatures {
internal const string SendChat = "48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9";
internal const string SanitiseString = "E8 ?? ?? ?? ?? 48 8D 4C 24 ?? 0F B6 F0 E8 ?? ?? ?? ?? 48 8D 4D C0";
internal const string SendChat = "48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F2 48 8B F9 45 84 C9";
internal const string SanitiseString = "E8 ?? ?? ?? ?? EB 0A 48 8D 4C 24 ?? E8 ?? ?? ?? ?? 48 8D AE";
}


Expand Down
18 changes: 9 additions & 9 deletions WoLua/Lua/Api/Game/EntityWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using FFXIVClientStructs.FFXIV.Client.Game.Character;

using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

using MoonSharp.Interpreter;

Expand Down Expand Up @@ -86,9 +86,9 @@ public string? TitleText {
if (!this.IsPlayer)
return null;
Title? title = this.playerTitle;
return title is null
? string.Empty
: this.MF(title.Masculine, title.Feminine);
return title.HasValue
? this.MF(title.Value.Masculine.ToString(), title.Value.Feminine.ToString())
: string.Empty;
}
}
public bool? TitleIsPrefix => this.IsPlayer ? this.playerTitle?.IsPrefix : null;
Expand All @@ -113,11 +113,11 @@ public string? TitleText {

#region Worlds

public ushort? HomeWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.HomeWorld.GameData!.RowId : null;
public string? HomeWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.HomeWorld.GameData!.Name!.RawString : null;
public ushort? HomeWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.HomeWorld.Value.RowId : null;
public string? HomeWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.HomeWorld.Value.Name!.ToString() : null;

public ushort? CurrentWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.CurrentWorld.GameData!.RowId : null;
public string? CurrentWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.CurrentWorld.GameData!.Name!.RawString : null;
public ushort? CurrentWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.CurrentWorld.Value.RowId : null;
public string? CurrentWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.CurrentWorld.Value.Name!.ToString() : null;

#endregion

Expand Down Expand Up @@ -149,7 +149,7 @@ public string? TitleText {
public JobData Job {
get {
return this && this.Entity is ICharacter self
? new(self.ClassJob!.Id, self.ClassJob!.GameData!.Name!.ToString().ToLower(), self.ClassJob!.GameData!.Abbreviation!.ToString().ToUpper())
? new(self.ClassJob.RowId, self.ClassJob!.Value.Name!.ToString().ToLower(), self.ClassJob!.Value.Abbreviation!.ToString().ToUpper())
: new(0, JobData.InvalidJobName, JobData.InvalidJobAbbr);
}
}
Expand Down
3 changes: 1 addition & 2 deletions WoLua/Lua/Api/Game/FateWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

using Dalamud.Game.ClientState.Fates;

using FFXIVClientStructs.FFXIV.Client.Game.Fate;

using MoonSharp.Interpreter;

using PrincessRTFM.WoLua.Constants;
using PrincessRTFM.WoLua.Lua.Docs;

using Fate = Dalamud.Game.ClientState.Fates.IFate;
using FateContext = FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext;

namespace PrincessRTFM.WoLua.Lua.Api.Game;

Expand Down
4 changes: 2 additions & 2 deletions WoLua/Lua/Api/Game/MountWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;

using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

using MoonSharp.Interpreter;

Expand All @@ -21,7 +21,7 @@ internal static void LoadGameData() {

ExcelSheet<Mount> mounts = Service.DataManager.GetExcelSheet<Mount>()!;
foreach (Mount mount in mounts) {
mountNames[(ushort)mount.RowId] = mount.Singular;
mountNames[(ushort)mount.RowId] = mount.Singular.ToString();
mountArticles[(ushort)mount.RowId] = "A" + (mount.StartsWithVowel > 0 ? "n" : string.Empty);
}
mountNames.Remove(0);
Expand Down
21 changes: 10 additions & 11 deletions WoLua/Lua/Api/Game/PlayerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using FFXIVClientStructs.FFXIV.Client.UI.Agent;

using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

using MoonSharp.Interpreter;

Expand Down Expand Up @@ -252,7 +252,6 @@ internal PlayerApi(ScriptContainer source) : base(source) { }
[LuaDoc("Provides three values consisting of the current character's X (east/west), Y (north/south), and Z (vertical) coordinates.",
"If the player isn't loaded, all three values will be nil.",
"This property is shorthand for `.Entity.MapCoords`.")]
[return: AsLuaType(LuaType.Number)]
public DynValue MapCoords => this.Entity.MapCoords;

[LuaPlayerDoc("The current character's rotation in radians, ranging from 0 to 2pi.",
Expand Down Expand Up @@ -476,24 +475,24 @@ internal static void InitialiseEmotes() {

ExcelSheet<Emote> emotes = Service.DataManager.GameData.GetExcelSheet<Emote>()!;
try {
uint max = emotes.RowCount;
int max = emotes.Count;
Service.Log.Information($"[{LogTag.Emotes}] Indexing {max:N0} emotes...");
for (uint i = 0; i < max; ++i) {
Emote? emote = emotes.GetRow(i);
if (emote is not null) {
Emote? emote = emotes.GetRowOrDefault(i);
if (emote.HasValue) {
string[] commands = (new string?[] {
emote.Name.RawString,
emote.TextCommand.Value?.Command?.ToString(),
emote.TextCommand.Value?.ShortCommand?.ToString(),
emote.TextCommand.Value?.Alias?.ToString(),
emote.TextCommand.Value?.ShortAlias?.ToString(),
emote.Value.Name.ToString(),
emote.Value.TextCommand.ValueNullable?.Command.ToString(),
emote.Value.TextCommand.ValueNullable?.ShortCommand.ToString(),
emote.Value.TextCommand.ValueNullable?.Alias.ToString(),
emote.Value.TextCommand.ValueNullable?.ShortAlias.ToString(),
})
.Where(s => !string.IsNullOrWhiteSpace(s))
.Cast<string>()
.Select(s => s.TrimStart('/'))
.ToArray();
foreach (string command in commands)
emoteUnlocks[command] = emote.UnlockLink;
emoteUnlocks[command] = emote.Value.UnlockLink;
}
}
Service.Log.Information($"[{LogTag.Emotes}] Cached {emoteUnlocks.Count:N0} emote names");
Expand Down
6 changes: 3 additions & 3 deletions WoLua/Lua/Api/Game/WeatherWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;

using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

using MoonSharp.Interpreter;

Expand Down Expand Up @@ -56,8 +56,8 @@ internal static void LoadGameData() {
if (Service.DataManager.GetExcelSheet<Weather>() is ExcelSheet<Weather> skies) {
// Cache the names and descriptions for each type of weather
foreach (Weather row in skies) {
weatherNames[row.RowId] = row.Name;
weatherDescriptions[row.RowId] = row.Description;
weatherNames[row.RowId] = row.Name.ToString();
weatherDescriptions[row.RowId] = row.Description.ToString();
}
Service.Log.Information($"[{LogTag.Weather}] Indexed {weatherNames.Count} weather types");
}
Expand Down
10 changes: 5 additions & 5 deletions WoLua/Lua/Api/Game/WorldPosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Utility;

using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

using MoonSharp.Interpreter;

Expand Down Expand Up @@ -46,10 +46,10 @@ internal Vector3? UiCoords {
return null;
uint zone = Service.ClientState.TerritoryType;
if (zone > 0) {
Map? map = Service.DataManager.GetExcelSheet<Map>()!.GetRow(zone);
TerritoryTypeTransient? territoryTransient = Service.DataManager.GetExcelSheet<TerritoryTypeTransient>()!.GetRow(zone);
if (map is not null && territoryTransient is not null) {
return MapUtil.WorldToMap(this.GameEnginePosition, map, territoryTransient, true);
Map? map = Service.DataManager.GetExcelSheet<Map>()!.GetRowOrDefault(zone);
TerritoryTypeTransient? territoryTransient = Service.DataManager.GetExcelSheet<TerritoryTypeTransient>()!.GetRowOrDefault(zone);
if (map.HasValue && territoryTransient.HasValue) {
return MapUtil.WorldToMap(this.GameEnginePosition, map.Value, territoryTransient.Value, true);
}
}
return null;
Expand Down
6 changes: 2 additions & 4 deletions WoLua/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Graphics.Environment;

using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

using MoonSharp.Interpreter;
using MoonSharp.Interpreter.Platforms;
Expand All @@ -24,8 +24,6 @@
using PrincessRTFM.WoLua.Ui;
using PrincessRTFM.WoLua.Ui.Chat;

using XivCommon;

namespace PrincessRTFM.WoLua;

public class Plugin: IDalamudPlugin {
Expand Down Expand Up @@ -218,7 +216,7 @@ public void OnCommand(string command, string argline) {
break;
case "class":
case "job":
if (Service.ClientState.LocalPlayer.ClassJob.GameData is ClassJob job) {
if (Service.ClientState.LocalPlayer.ClassJob.Value is ClassJob job) {
this.Print($"You current job is {job.RowId} ({job.Abbreviation}, {job.Name}) at level {Service.ClientState.LocalPlayer.Level}.");
}
else {
Expand Down
2 changes: 1 addition & 1 deletion WoLua/dalamud.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Import Project="framework.props" />

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="DalamudPackager" Version="11.0.0" />
<Reference Include="Newtonsoft.Json">
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
Expand Down
6 changes: 3 additions & 3 deletions WoLua/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
"requested": "[11.0.0, )",
"resolved": "11.0.0",
"contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
},
"MoonSharp": {
"type": "Direct",
Expand Down
4 changes: 2 additions & 2 deletions examples/03-local-chat-messages/command.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Game.PrintChat("Yes, you can actually send chat messages on script load. It's not a GOOD idea, but you CAN do it.")
Game.PrintMessage("Yes, you can actually send chat messages on script load. It's not a GOOD idea, but you CAN do it.")

Script(function()
Game.PrintError("Oh no! This script prints an error when called!")
Game.PrintChat("Don't worry, nothing's actually wrong.")
Game.PrintMessage("Don't worry, nothing's actually wrong.")
end)

-- yeah, this example is really that simple
Expand Down
Loading