Page 1 of 1

SWBF2 Lua API [LuaDoc]

Posted: Sat Nov 12, 2016 12:02 am
by Marth8880
Hey everyone, so I've spent the last several hours documenting the entire SWBF2 Lua API (all the Lua functions, basically) in LuaDoc format, so that they can be read by the Lua Development Tools. I'm currently around halfway done.

What does this mean?

Well, basically, 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. However, you can take it a step further: if you format your function comments in the LuaDoc syntax, you can enter descriptions of what the function does, what each parameter does, any return values, etc. Here's what LuaDoc looks like in action with a custom function:

Function declaration in normal .lua file:
Hidden/Spoiler:
Image
LuaDoc popup:
Hidden/Spoiler:
Image
Now, along with formatting function comments with LuaDoc in your .lua files, you can define an entire function library (without actually overriding what the functions do) in external .doclua files.

Here's what it looks like in action with a pre-defined LuaDoc library:

Function declaration in .doclua file:
Hidden/Spoiler:
Image
LuaDoc popup:
Hidden/Spoiler:
Image
Be sure to leave any comments/questions/etc. below!

Re: SWBF2 Lua API [LuaDoc]

Posted: Mon Nov 21, 2016 7:16 pm
by AQT
Looks like a very useful tool. :o

Re: SWBF2 Lua API [LuaDoc]

Posted: Mon Nov 21, 2016 9:51 pm
by Marth8880
You better believe it haha

@everyone, I've completed this and released it here: http://www.gametoast.com/viewtopic.php?f=64&t=32676

Re: SWBF2 Lua API [LuaDoc]

Posted: Sat Jan 07, 2017 1:51 am
by AnthonyBF2
I completely read your doc (and am grateful for it) and I'd like to clear a few things up that you seem unsure of (places where you had questions marks or assume things are not used)

1) SetHeroUnlockRule() -- This is used in multiplayer settings, rules are (according to server manager) reinforcements, kills, points, timer, and captures. I think a number 1 - 5 is used as a the value inside () but I can't confirm which value links to which rule.

2) SetHeroPlayerRule() -- Again, this is a multiplayer thing. It sets how the first player gets the hero first on each team (I think I explained that right) and according to server manager the options are most points, most kills, most deaths, least points, least kills, least deaths, random, and hero slayer. Again, I think there is a numerical value that represents which option to set.

3) SetHeroTeamRule() -- Multiplayer thing, server manager options are one team, both teams simultaneous, both teams separate, and cycle teams. I think this is what controls if both heroes can exist at the same time or one team at a time. Numerical values assumed.

4) SetHeroRespawnRule() -- Multiplayer thing, numerical value for determining how long each hero can be offered to the next person on either team after it has been defeated. I think the value is in seconds.

5) ShowAllUnitsOnMinimap() -- I only found traces of this in the debugger game version and nothing in the regular game executable. Safe to assume unused.

6) SetMapRangeOverall, SetMapRangeShooting, SetMapRangeViewCone, and SetMapViewConeAngle are actually functional ODF parameters but without the Set prefix. These are most likely unused as Lua functions.

7) ScriptCB_RemoveTexture() -- This is something I discovered recently and intend to make use of in the PSP project. This removes any texture loaded into memory at any time. Example; enter ScriptCB_RemoveTexture("all_inf_bothanspy") during gameplay into code console and the Bothan's skin will become removed and appear solid black. Cloaking device still works as it does.