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

Post Reply
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

SWBF2 Lua API [LuaDoc]

Post 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!
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: SWBF2 Lua API [LuaDoc]

Post by AQT »

Looks like a very useful tool. :o
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: SWBF2 Lua API [LuaDoc]

Post 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
User avatar
AnthonyBF2
Sith
Sith
Posts: 1254
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: SWBF2 Lua API [LuaDoc]

Post 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.
Post Reply