Expose getKartType(int kartId) to scripting

This change attempts to expose the KartType (local player, networked player, AI, etc.) to scripting.
This is useful if a track creator wants an action to only occur if triggered by a real player, or only if triggered by a non-networked player (e.g. alternate route music in Frozen Drive unofficial add-on).

I have rushed this in to try and get it added in STK 1.1 and I have not yet been able to configure and build STK from source, so this change is currently untested!

I have placed this in the Track section because it uses the race manager. Please let me know if the Kart section is more appropriate.
This commit is contained in:
Jeff
2019-12-25 21:49:00 +11:00
committed by GitHub
parent 7f32842e76
commit de33244ae7

View File

@@ -165,7 +165,16 @@ namespace Scripting
{
return race_manager->getNumLocalPlayers();
}
/**
* Gets the kart type, such as local player, networked player, AI, etc.
* @return A KartType enum as defined in race_manager.hpp, implicitly casted to an int
*/
int getKartType(int kartId)
{
return race_manager->getKartType(kartId);
}
bool isTrackReverse()
{
return race_manager->getReverseTrack();
@@ -554,6 +563,10 @@ namespace Scripting
r = engine->RegisterGlobalFunction("int getNumLocalPlayers()",
mp ? WRAP_FN(getNumLocalPlayers) : asFUNCTION(getNumLocalPlayers),
call_conv); assert(r >= 0);
r = engine->RegisterGlobalFunction("int getKartType(int kartId)",
mp ? WRAP_FN(getKartType) : asFUNCTION(getKartType),
call_conv); assert(r >= 0);
r = engine->RegisterGlobalFunction("bool isReverse()",
mp ? WRAP_FN(isTrackReverse) : asFUNCTION(isTrackReverse),