Marth's Lua API Megamix!

Releasing the source files for your mod or map? Post em' here. (Applies to both SWBF1 & SWBF2)

Moderator: Moderators

Resistance Leader
User avatar
Posts: 5187
Joined: Tue Feb 09, 2010 8:43 pm
Location: Edinburgh, UK
Projects :: EVERYWHERE + Zero Munge + TCW
Games I'm Playing :: Hollow Knight
xbox live or psn: Marth8880

Marth's Lua API Megamix!

Postby Marth8880 » Mon Nov 21, 2016 9:50 pm

Intro

Hey everyone, so I've spent the last ten days or so figuring out what every single function does as well as what their arguments are and what they do. I've documented all of this in LuaDoc format, so that they can be read by the Lua Development Tools and other IDEs that support LuaDoc.

In other words, virtually every single built-in Lua function is fully documented with descriptions of all of their arguments and return values. The only ones that are still undocumented are many of the shell-exclusive callbacks, but we have pretty much no use for those anyway.


What does this mean?

By default, whenever you hover your mouse cursor over a function or variable in LDT, a small window will pop up displaying any comments located above or in-line-with the function or variable and it'll list any arguments that the function includes, like so:

Example function declaration (formatted normally):
Hidden/Spoiler:
Image

Example function call:
Hidden/Spoiler:
Image


However, you can take this a step further: if you format your function comments in the LuaDoc syntax, you can enter descriptions of what the function does, what each argument does, any return values, etc., like so:

Example function declaration (formatted in LuaDoc syntax):
Hidden/Spoiler:
Image

Example function call:
Hidden/Spoiler:
Image


Now, along with formatting function comments in LuaDoc syntax in your .lua files, you can define an entire library of functions (without actually overriding what the functions do) in external .doclua files.

Continue to the next section below to see LuaDoc in action.


Examples

FillAsteroidPath:

The portion of the .doclua file where the function is documented in LuaDoc syntax:
Hidden/Spoiler:
Image

What it looks like when you hover over a FillAsteroidPath function call in a Lua script:
Hidden/Spoiler:
Image


MapAddEntityMarker:

The portion of the .doclua file where the function is documented in LuaDoc syntax:
Hidden/Spoiler:
Image

What it looks like when you hover over a MapAddEntityMarker function call in a Lua script:
Hidden/Spoiler:
Image


How do I use this?

If you haven't already, check out my tutorial on how to use the Lua Development Tools for SWBF2 modding. Once you've done so, clone or download the SWBF2 Lua API on GitHub and put it in your project's source folder (or data_***\Common\scripts).


>> Clone or download the SWBF2 Lua API on GitHub <<


Anyway, so yeah, that's that. Please be sure to post any comments, questions, etc. that you have about any of this! :D

Return to Released Assets

Who is online

Users browsing this forum: No registered users and 2 guests