Undocumented Lua functions?

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Undocumented Lua functions?

Post by AnthonyBF2 »

As just about any one knows, On can be combined with lots of things to do different things, like OnCharacterSpawn or OnObjectDeath. I was digging around in the game executable and located some things that I did not find in the documentation. I am wondering if any one else has found these and attempted to do anything with them...

ScoreChange -- find when player's current point count change?
DeathsChange -- find when player's current death count changes?
KillsChange -- find when player's current kill count changes?
TargetChange -- when player locks on and changes target?
PlayerChange -- no idea
WeaponChange -- player changes weapons?
FlagReset -- flag goes back to home space
FlagPickUp -- flag gets grabbed
TeamPointsChange
TicketBleedChange
TicketCountChange
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: Undocumented Lua functions?

Post by jedimoose32 »

I have worked with FlagReset and FlagPickup. They are self-explanatory. I forget what the arguments are at the moment but you can find examples of them in the stock CTF scripts.

I browsed through the executable a long time ago and don't remember seeing KillsChange or DeathsChange... those sound very useful, if they are usable. I can't say I've ever seen them used in any of the scripts that shipped with the mod tools so maybe they aren't fully implemented... and even if they are I guess someone would have to play around with them to determine what their arguments are. Maybe I'll give that a try this afternoon.
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Undocumented Lua functions?

Post by Nedarb7 »

If I recall correctly PlayerChange is when you swap classes; however, there may not be too many uses for it considering CharacterSpawn can be used for class swaps as well.
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: Undocumented Lua functions?

Post by AnthonyBF2 »

Nedarb7 wrote:If I recall correctly PlayerChange is when you swap classes; however, there may not be too many uses for it considering CharacterSpawn can be used for class swaps as well.
Would you mind writing a quick use of PlayerChange? I may have a wonderful use for this but I suck bad at Lua. 8)
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: Undocumented Lua functions?

Post by jedimoose32 »

I highly recommend Zerted's Example Finder. That's how I check for usage of Lua functions I'm unfamiliar with.
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: Undocumented Lua functions?

Post by AnthonyBF2 »

Says I need Java... -_-"
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: Undocumented Lua functions?

Post by jedimoose32 »

Congrats on your 500th post!

I'll check right now to see if I can find an example.
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: Undocumented Lua functions?

Post by AnthonyBF2 »

Sorry but I am on my phone hotspot that is 25kbs... Not going to be updating anything until I pay my next phone bill to reset data.
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: Undocumented Lua functions?

Post by jedimoose32 »

Fair enough.
Well unfortunately I was unable to find any examples of how the function is used.
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: Undocumented Lua functions?

Post by AnthonyBF2 »

Thanks anyway. I'll fool around with it later on my own.

EDIT: Failed.

I used:

Code: Select all

OnPlayerChange(function(player)
if GetCharacterUnit(player) and 
IsCharacterHuman(player) then
KillObject(GetCharacterUnit(player))
end
end
)
And the debugger cries:

Code: Select all

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `OnPlayerChange' (a nil value)
stack traceback:
	(none): in function `ScriptPostLoad'
Post Reply