User Tools

Site Tools



lua_tutorial

This is an old revision of the document!


Learning Lua

by Kali#3326

This tutorial is designed with beginners in mind, but has topics suitable for advanced users as well. Even if you have no programming experience you should be able to easily follow along and grasp the concepts along the way. As someone who is self taught I understand the struggles of overcoming all the technical jargon traditional guides throw around, and while I understand the importance of that jargon, I think it is best to start simple with obtainable goals in mind.

Getting Started

You don't need any fancy software or an IDE to make scripts for Minion, in fact you already have everything you need, MMOMinion and Notepad. However, you can do a whole lot better than Notepad, so here are some of my recommendations:

There are other options out there, most people tend to go with VSCode or Notepad++. I personally prefer IntelliJ but the most important thing is that you know how to use it comfortably because you don't want to have to end up learning how to write Lua on top of how to install and use the software.

Next are online resources, use these to look up standard Lua functions. Minion uses a modified version of Lua 5.1 with some standard functions removed/modified for security purposes. Keep that in mind when using these and other resources.

Now that you have everything you need, lets get started with the traditional Hello, World!, and we don't even need any of the above to do it. We're going to need Minion's console for this, and if you've never used it before or don't even know what I'm talking about, you can access it by clicking on the MMOMinion button and selecting Console.

The console is one of your most important tools when developing, debugging, or even reporting an issue to other developers. At first glance it might seem like a bunch of nonsense, but everything in the console has been determined by that developer that it is important information and to output it into the console. The reason for this is if that information is not correct or not intended that we have a record of what Minion's Lua Interpreter executed and in what order if we have enough information.

Now with Minion's Lua instead of using the function print to “print to the console” like you normally would use, we simply use the function d, and to stick with tradition we can output to the console with our Hello World message:

d("Hello, World!")

Dev Tools and Lua Source Files

Next we're going to introduce Dev Tools and our Lua source files that come by default with MMOMinion. To access Dev Tools open the MMOMinion menu and hover your mouse over FFXIVMinion to expand the menu right and click Dev Tools. Dev Tools, aka Dev-Monitor, is our single greatest resource in Minion as it contains most of our API in one single script.

To show this off target something like a minion or any NPC, then in Dev-Tools expand the Target tree and expand Core Data and Position Data. Lets go over what this information means.

  • Ignore Ptr, this information is only used by developers reversing the game to update minion for new patches.
  • ID, not to be confused with ContentID, is an identifier generated by the servers so the client knows what entity is what. Imagine if you had 5 Ifrit's on the same battlefield, all with the same name, same ContentID, how does the game tell them apart otherwise? ID's are not static/reliable information, a new ID is given every time you zone or load an instance.
  • Name is entity name, character name, etc.
  • Content ID is an identifier given to each model. Where 5 Ifrit's would all have the same ContentID, imagine how many types of Mandragora there are in the game, each one has a different Content ID. Every time they reuse a creature with the same enemy model but recolor it it will have a new ContentID with it.
  • Type is entity type, in this case a minion aka minipet.
  • Status is server status, it is mainly used only for the Player and in niche cases as well. It's good to know this information is here but you may never use it.
  • ChocoboState is the Player's current state on a chocobo.
  • CharType is Character Type, in this case an NPC.
  • TargetID is the ID of the target that entity is currently targeting, in this case a minion doesn't target anything so it's 0.
  • OwnerID is used for entities like your companion chocobo, egi's and pets, sadly not minions.
  • Claimed By ID is pretty useful when you want to know who claimed an enemy, even if that player isn't the enemy's current target.
  • Fate ID only applies to FATE enemies, and will let you know what fate ID that entity is apart of.
  • Icon ID is the icon above NPCs, like quest icons.
  • Position is the position that entity is in the world, different from MeshPosition.
  • Radius is the size of the ring when you target them. For example all Players have a radius of 0.5 yalms, while large bosses will have huge rings to accommodate for melee jobs doing mechanics while still being in attack range.
  • Distance is the distance between you, and in this case, your target. This is exact distance between two points in a 3D space.
  • Distance2D is the distance between two points in a 2D space, removing height from the equation and removing the Player's radius and, in this case, the target's radius.
  • PathDistance is a calculated distance used by the Navigation Manager, aka the distance it would take to travel from your position to, in this case, your target's position.
  • LoS and LoS2, aka Line of Sight, are used to calculate if the los between two positions is clear or blocked by something. Sometimes can be unreliable/finicky.
  • OnMesh is determined by the Navigation Manager if the entity is on the navigation mesh or not.
  • IsReachable is determined by the Navigation Manager if the entity can be reached by the Player or not.
  • MeshPosition is the position on the mesh, not the same as game position.

*Deep Breath*, now that was a lot of information wasn't it? And to imagine that's not even 1% of all the information Minion provides about the game. That might sound intimidating, and it can be, but it's always important to remember that you don't need to know what everything is. You can find your way around by context and some documentation about what something is here and there.

lua_tutorial.1682438799.txt.gz · Last modified: 2023/04/25 16:06 by kali