This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lua_tutorial [2023/04/25 15:55] – kali | lua_tutorial [2023/04/29 07:52] (current) – kali | ||
---|---|---|---|
Line 11: | Line 11: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
- | 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. | + | 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. This guide will assume you use VSCode and any references I make will refer to that 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/ | 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/ | ||
Line 24: | Line 24: | ||
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' | 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' | ||
- | Now with Minion' | + | Now with Minion' |
+ | |||
+ | {{: | ||
d(" | d(" | ||
- | {{ :: | ||
===== Dev Tools and Lua Source Files ===== | ===== Dev Tools and Lua Source Files ===== | ||
{{ :: | {{ :: | ||
Line 32: | Line 33: | ||
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. | 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. | * 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' | * **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' | ||
Line 55: | Line 56: | ||
* **IsReachable** is determined by the Navigation Manager if the entity can be reached by the Player 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. | * **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, | + | //*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, |
+ | |||
+ | {{ :: | ||
+ | ..\MINIONAPP\Bots\FFXIVMinion64\LuaMods\Dev | ||
+ | The LuaMods folder contains every Lua script that runs with Minion including addons from the store. When you begin making your own modules, which is very soon, you'll maintain all your projects within LuaMods. Now open the Dev folder and open **dev.lua** in the text editor you chose to use. From this point forward I'm going to assume you are using VSCode, so I'll be referencing how to do things from there this point forward. | ||
+ | |||
+ | {{: | ||
+ | Now there is a lot of information that we aren't ready to talk about in this file, so press **CTRL+F** to search for **Core Data**, there will only be one entry in the file so it will take you right to it. | ||
+ | |||
+ | This is the same thing you interacted with before in Dev Tools, just the source of it. We're just going to borrow some information from this to help demonstrate how you can use this information in the future, but also it helps you get use to using these files to learn from them. In this image on line 2459 for **Name**, at the very end of the line you see '' | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | local c = Player: | ||
+ | Lets break this line down, **local c** is making **c** a local variable, which we'll talk about later, **c = Player: | ||
+ | |||
+ | We'll talk about all that and more later, but we just need to use **Player: | ||
+ | |||
+ | {{:: | ||
+ | In this example we have 5 Striking Dummies, you can target any entity for this but for this example I'll be targeting these. Target something and in your console, execute this: | ||
+ | |||
+ | {{ : | ||
+ | d(Player: | ||
+ | Now as you rotate between different targets execute it again to have it print the target' | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | local target = Player: | ||
+ | |||
+ | Now what did I do there? I simply utilized the information we learned with 3 variables and [[https:// | ||
+ | ===== Introducing Basic Lua Terms ===== | ||
+ | |||
+ | - explain what a variable is | ||
+ | - comments | ||
+ | - identifiers, | ||
+ | - the 21 reserved keywords | ||
+ | - whitespace and readability | ||
+ | - variable definition, lists, and declaration | ||
+ | - the 8 " | ||
+ | - nil, boolean, number, string, function, userdata, thread, and table | ||
+ | - the type function | ||
+ | - arithmetic operators | ||
+ | - relational operators | ||
+ | - logical operators | ||
+ | - miscellaneous operators | ||
+ | - operator precedence | ||
+ | - loops, break, and infinite loops | ||
+ | - if statements | ||
+ | - functions | ||
+ | - defining | ||
+ | - arguments | ||
+ | - calling | ||
+ | - assigning and passing | ||
+ | - variable arguments | ||
+ | - strings and string manipulation | ||
+ | - replacing a substring, find and match | ||
+ | - string formatting | ||
+ | - character and byte representation | ||
+ | - arrays and multi-dimensional arrays | ||
+ | - iterators | ||
+ | - tables and table manipulation | ||
+ | |||
+ | ===== Making our First Module ===== | ||
+ | |||
+ | ===== Common Functions and Standard Libraries ===== | ||
+ | |||
+ | ===== Error Handling and Debugging ===== | ||
+ | |||
+ | ===== Garbage Collection and Performance Impact ===== | ||
+ | |||
+ | ===== Object Oriented and Inheritance ===== |