Page 1 of 1
Undocumented Lua functions?
Posted: Sat Jan 30, 2016 5:03 pm
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
Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 12:56 pm
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.
Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 7:01 pm
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.
Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 7:32 pm
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.

Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 7:47 pm
by jedimoose32
I highly recommend Zerted's Example Finder. That's how I check for usage of Lua functions I'm unfamiliar with.
Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 8:01 pm
by AnthonyBF2
Says I need Java... -_-"
Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 8:03 pm
by jedimoose32
Congrats on your 500th post!
I'll check right now to see if I can find an example.
Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 8:07 pm
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.
Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 8:09 pm
by jedimoose32
Fair enough.
Well unfortunately I was unable to find any examples of how the function is used.
Re: Undocumented Lua functions?
Posted: Sun Jan 31, 2016 8:10 pm
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'