Map Checking
Do you use generalized map names like Catharsis Reborn?
I.e. City01_Mon_A
, City02_Mon_A
, City01_Mon_B
, City03_Mon_A
...
Then perhaps this could help you a little bit.
Execute Only If It's a City Map
Instead of checking a thousand map names with if elses, we can make it dynamic, so in the future it won't cause any problems.. Well that is if there's no insane person deciding to break the map naming rule.
We are going to check if the map's name contains City0
, then we can assume it's an outside, city map, here's how:
bool IsCityMap(string MapName)
{
// The function `engine.GetCurMapName()` already turns the string into lowercase..
if ( (MapName.findFirst("city0")) >= 0 )
return true;
return false;
}
Example (How to use)
Then in code, we can just simply call the function, but before doing so put the code in Utils.as
or some global function holding file.
#include "Utils.as"
class MyClass : IPostal3Script
{
void MyFunction()
{
CP3SObj @self = GetContextOwner();
if ( @self == null )
return;
if ( IsCityMap( engine.GetCurMapName() ) )
{
FlyAway();
}
else
{
PenguinWalk();
}
}
}