SWBF2 Lua API [LuaDoc]

Working on a new map? Have a new mod out for swbf2?! Post an announcement of the up-coming release here.

Moderator: Moderators

Resistance Leader
Online
User avatar
Posts: 4721
Joined: Tue Feb 09, 2010 8:43 pm
Location: Greater Seattle Area
Projects :: Shadow of War
Games I'm Playing :: Warframe+DOOM+MEA
xbox live or psn: Marth8880

SWBF2 Lua API [LuaDoc]

Postby Marth8880 » Sat Nov 12, 2016 12:02 am

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!

Gametoast Staff
User avatar
Posts: 4844
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA
Projects :: Republic Commando - Battlefront

Re: SWBF2 Lua API [LuaDoc]

Postby AQT » Mon Nov 21, 2016 7:16 pm

Looks like a very useful tool. :o

Resistance Leader
Online
User avatar
Posts: 4721
Joined: Tue Feb 09, 2010 8:43 pm
Location: Greater Seattle Area
Projects :: Shadow of War
Games I'm Playing :: Warframe+DOOM+MEA
xbox live or psn: Marth8880

Re: SWBF2 Lua API [LuaDoc]

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

You better believe it haha

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

Jedi
User avatar
Posts: 1059
Joined: Wed Aug 21, 2013 3:55 pm
Location: San Diego
Projects :: SWBF2 PSP+PS2 Conversion

Re: SWBF2 Lua API [LuaDoc]

Postby AnthonyBF2 » Sat Jan 07, 2017 1:51 am

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.

Return to SWBF2 Map/Mod Works In Progress

Who is online

Users browsing this forum: No registered users and 1 guest