Script Reference:
[Utility Methods] [Tile Methods]
[Map Methods] [Land Methods] [Dialog Methods]
[Callbacks] [Globals] [Strings] [Settings]
This page lists all of the methods, globals and callbacks that you can use to make Pocket War mods and user scripts. The scripting language itself
is based on Javascript. Most of the standard Javascript libraries are included and can be used. There are a couple of things to note.
Javascript is a typeless language, but the Pocket War calls are strongly typed. The methods, callbacks and globals listed below
all have types listed but in the scripts the types are not specified they are assumed.
For example take: debug( string message )
When used in a script it would look like: debug( "hello world" );
To override a callback simply define a function in your script with the name and parameters of the callback. Then when Pocket War triggers
the event your callback will be called. For example, the startScript() method is called for every script the first time it is run. So if you
wanted to write a message to the mtrace file every time your script was started you would add the following to your script:
function startScript()
{
debug( "my script started" );
}
Then every time your script was run it would write "my script started" to the mtrace.txt file. Another thing to note is that global variables are
not guaranteed to exist between script runs. If you need to store state information use setString, getString, setGlobalString, and getGlobalString.
[Top] Utility Methods
- message( string status, bool addToList, int x, int y )
Used to put a message on the status line
status - is the message that will be put on the status line
addToList (optional) - if this is true then the message will be added to the message list
x (optional) - the x location where this message happened on the map
y (optional) - the y location where this message happened on the map
- showAlert( string message )
Displays an alert message on the screen
message - the message to display
- debug( string message )
Used to write a debug statement out to the mtrace.txt file. The statement will only appear if the user has trace turned on (see [Options] )
message - the message to write out to the mtrace.txt file
- int getPlatform()
Used to get the platform that the engine is running on
return value - 1 if it is the desktop version 2 if it is the pocket pc version
- string getVersion()
Gets the version of the game engine
return value - the version (ie "0.92")
- mapString( int id, string newString )
Used to change one of the built in strings
id - the id of the string (See the chart at the end of the page for a list of all ids and strings
newString - the string to replace the existing string with
- string messageBox( string message, string caption, string type )
Used to show a dialog to the user (NOTE: this method only works in window mode not full screen mode and should only be used for testing)
message - the message to show in the dialog
caption - the caption of the dialog
type - the type of dialog which can be one of the following "ABORTRETRYIGNORE", "OK", "OKCANCEL", "RETRYCANCEL", "YESNO", "YESNOCANCEL"
return value - a string to let you know what the user selected. It can be one of the following "abort", "cancel", "ignore", "no", "ok", "retry", "yes"
- target( Tile tile, string key, string script )
Used to allow the users to select a target
tile - a tile that will be passed into the script callback
key - a key that will be passed into the script callback
script - this script will be run when the user taps a location on the screen. It will get passed key, x, y, and the global var tile will be set.
- string getPlayerName( ownertype player )
gets the name of a player
player - the player to get the name of
return value - the players name as a string
- string getPlayerType( ownertype player )
gets the type of a player
player - the player to get the type of
return value - the players type as a string ( "none", "local", "computer", "email" )
- setPlayerType( ownertype player, string type )
sets the type of a player
player - the player to set the type of
type - the new type for the player ( "none", "local", "computer", "email" )
- surrender( OwnerType player )
makes a player surrender
player - the player that will leave the game
- int getNumberOfHumanPlayers()
returns the number of human players left in the game
return value - the number of human players still in the game
- setGlobalString( ownertype owner, string key, string value )
Used to store a string globally
owner - the player to associate this string with
key - the key to store the string under
value - the string you want to store
- string getGlobalString( ownertype owner, string key )
Used to get a string that has been stored globally
owner - the player the string is associated with
key - the key the string is stored under
return value - the string that was stored globablly
- setGlobalValue( ownertype owner, string key, int value )
Used to store an int globally
owner - the player to associate this string with
key - the key to store the int under
value - the int you want to store
- int getGlobalValue( ownertype owner, string key )
Used to get an int that has been stored globally
owner - the player the int is associated with
key - the key the int is stored under
return value - the int that was stored globablly
- string getFilePath( string key )
Gets the path to certain types of files
key - the path to get ( "submoddirectory", "scriptdirectory", "installdirectory" )
- setSetting( string settingName, int value )
sets a Pocket War setting
settingName - the name of the setting to set - see settings chart
value - the value to set the setting to
- int getSetting( string settingName )
gets a Pocket War setting
settingName - the name of the setting to get - see settings chart
return value - the value of the setting
- showImageDialog( string imagePath, string title )
Displays a screen to the user with an image on it
imagePath - the path to the image
title - the title of the screen
- newGame( string difficulty, string size )
Used to make pocket war start a new game
difficulty - how hard will the game br EASY | MEDIUM | HARD
size - the size of the new map SMALL | MEDIUM | LARGE | XLARGE
[Top] Tile Methods
- void registerUnitType( string TypeName, boolean attachOnly, int priority, string purpose )
Used to tell pocket war that this script will add a new unit type to the game
TypeName - the name of the new unit type (must have only letters, numbers and spaces in the name)
attachOnly - if true then this script will not add the unit type but will modifiy it if it already exists
prioroty - the order in which scripts are run for each unit
purpose - the purpose of this unit. This is used by the AIs. Current AIs look for the following values takecities, killground, killair, killsea, and transport.
Each value should be proceeded with a '-' sign (ex -killground) and you can place more than
one purpose in the field starting with what its best at to what it is worst at. (ex a marine can
take cities and kill ground units so it would have -takecities-killground)
- removeUnitType( string unittype )
used to remove a unit type from the game (usually at cleanup time between games)
unittype - The name of the unit type to remove
- registerCityType( string citytype, bool attachOnly, int priorty )
Used to tell pocket war that this script will add a new city type to the game
citytype - the name of the new city type (must have only letters, numbers and spaces in the name)
attachOnly - if true then this script will not add the city type but will modifiy it if it already exists
prioroty - the order in which scripts are run for each city
- removeCityType( string citytype )
used to remove a city type from the game (usually at cleanup time between games)
citytype - The name of the city type to remove
- bool hasImageSet( tile tileToCheck )
used to see if a tile has an image assigned to it already. (this is a good way to check
to see if the unit has already been setup by another script)
tileToCheck - the tile to check
return value - true if this tile has an image already
- bool isBlank( tile tileToCheck )
used to see if a tile is brand new with no data filled in yet
tileToCheck - the tile to check
return value - true if this tile is new
- string getType( tile tileToGetTypeOf )
Used to get the type of a tile
tiletoGetTypeOf - the tile to get the type of
return value - the type of the tile
- int getX( tile tileToCheck )
Used to get the X location of a tile
tileToCheck - the tile to get the X location of
return value - the X location
- int getY( tile tileToCheck )
Used to get the Y location of a tile
tileToCheck - the tile to get the Y location of
return value - the Y location
- string getName( tile tileToGetNameOf )
Used to get the name of a tile
tileToGetNameOf - the tile to get the name of
return value - the name of the tile
- bool isCity( tile tileToCheck )
Used to find out if a tile is a city
tileToCheck - the tile to check
return value - true if the tile is a city false if it isnt
- bool isUnit( tile tileToCheck )
Used to find out if a tile is a unit
tileToCheck - the tile to check
return value - true if the tile is a unit false if it isnt
- bool isGroundUnit( tile tileToCheck )
Used to find out if a tile is a ground unit
tileToCheck - the tile to check
return value - true if the tile is a ground unit false if it isnt
- bool isSeaUnit( tile tileToCheck )
Used to find out if a tile is a sea unit
tileToCheck - the tile to check
return value - true if the tile is a sea unit false if it isnt
- bool isAirUnit( tile tileToCheck )
Used to find out if a tile is a sea unit
tileToCheck - the tile to check
return value - true if the tile is an air unit false if it isnt
- bool isHoverUnit( tile tileToCheck )
Used to find out if a tile is a sea unit
tileToCheck - the tile to check
return value - true if the tile is a hover unit false if it isnt
- bool isWaypoint( tile tileToCheck )
Used to find out if a tile is a sea unit
tileToCheck - the tile to check
return value - true if the tile is a waypoint unit false if it isnt
- int getMaxWaypointID( ownertype player )
returns the max waypoint id for that player (min is always 1)
player - the player to check for
return value - the largest waypoint id for that player
- ownertype getOwner( tile tileToCheck )
Used to find out which player owns a tile
tileToCheck - the tile that you want to get the owner of
return value - the player that owns the tile
- setOwner( tile tileToSet, ownertype owner )
Used to set the owner of a tile
tileToSet - the tile you want to set the owner of
owner - the player that will now own this tile
- bool isAtWaypoint( tile unit, int waypointID )
Used to see if a unit has reached it sitting at a waypoint
unit - the unit you want to check
waypointID - the id of the waypoint you want to see if the unit is at
return value - true if the unit is at that waypoint false if it is not
- setAction( tile tileToSetActionOn, string action )
Used to set the action of a unit or city
tileToSetActionOn - the tile to assign the action to
action - the action to set
- string getAction( tile tileToGetActionOf )
Used to get the action of a unit or city
tileToGetActionOf - the tile to get the action of
return value - the action that tile is set to
- setAutoKickOut( tile unit, bool autoKickOut )
Used to let cities know if they should autokick out this unit after it is built
unit - the tile to set the kick out value on
autoKickOut - true if the city should kick this unit out after it is built false if not
- setMove( tile tileToSetMoveOf, string move )
Used to get the move of a unit or city
tileToSetMoveOf - the tile to set the move state of
move - the move type
- string getMove( tile tileToGetMoveTypeOf )
Used to get the move state of a tile
tileToGetMoveTypeOf - the unit or city to get the move state of
return value - the move type of that unit or city
- bool canReach( tile tiletoCheckpathfor, int x, int y )
A very fast way to find out if you can get from here to there. This does not take into account
armies, etc that might be in the way
tiletoCheckpathfor - the unit we are checking the path for
x - the x location we are trying to reach
y - the y location we are trying to reach
return value - true if it can get there false if not
- setWaypointTarget( tile tileToSetWaypointTargetOf, int waypointID )
Used to set the waypoint that unit will go to or a city or waypoint will forward units to
tileToSetWaypointTargetOf - the unit, city or waypoint that you want to assign the other waypoint to
waypointID - the id of the waypoint you want to associate with the above unit
- int getWaypointTarget( tile tileToGetWaypointTargetOf )
Used to get the waypoint assigned to a unit, city or another waypoint
tileToGetWaypointTargetOf - the unit, city or waypoint to check
return value - the id of the waypoint assigned to that unit. 0 if no waypoint is assigned.
- setScript( tile tileToScript, stirng scriptName )
Used to set a hidden script that will run on a tile. The user cannot see or change this script.
tileToScript - the tile to assign the script to
scriptName - the name of the script to run
- setUserScript( tile tileToScript, stirng scriptName )
Used to set a user script on a tile. The user can see and change this script.
tileToScript - the tile to set the script on
scriptName - the name of the script to run
- tile createUnit( string type, ownertype owner )
Used to create a unit
type - the type of unit to make
owner - the player that will own this unit
return value - the new unit
- tile createCity( string type, ownertype owner, bool seaAccess, bool landAccess, bool hoverAccess )
Used to create a city
type - the type of city to make
owner - the player that will own this city
seaAccess - true if this city will have sea access
landAccess - true if this city will have land access
creat
hoverAccess - true if this city will have hover access
return value - the new city
- bool canBuild( tile tileToCheck, string buildtype )
Used to find out if a tile can build another type of tile
tileToCheck - the tile to check
buildType - the type to see if it can build
return value - true if it can build it false if it cant
- setProduce( tile container, string produceType, bool forceMakeNow )
Used to set the type of unit that a city or unit will build
container - the unit that will build the new unit
produceType - the type of unit you want that unit to produce
forceMakeNow - true if you want the unit to stop building everything else and start building this unit. False if not.
- string getProduce( tile container )
Used to get the type of unit that this city or unit is set to produce
container - the unit or city you want to check
return value - the type of unit that this city or unit is set to build
- int getNumberUnitsBuilt( tile tileToCheck )
Used to get the number of units that a city or unit has built
tileToCheck - the tile to get the count from
return value - the number of units that have been built.
- array getStored( tile tileToGetStoredItemsFrom )
Used to get an array of the units being stored in a unit or city
tileToGetStoredItemsFrom - the item to get the stored units from
return value - the array of stored units (may be empty)
- bool isEmpty( tile container )
Used to see if a unit or city is empty
container - the unit or city you want to check
return value - true if the container is empty false if not
- bool isFull( tile container )
Used to see if a unit or city is full
container - the unit or city to check
return value - true if the unit or city is full false if it is not
- kickOutStored( tile container, int index )
Used to kick out units stored in a city or in another unit
container - the city or unit that contains the units you want to kick out
index - the index of the stored item you want to kick out or -1 to kick out all stored items
- int getLandMassAtPoint( string moveType, int x, int y )
Gives you an index to the land mass at a point where landmass is a blob of land that allows the moveType
passed in.
moveType - the move type (land, air, sea, underwater, hover)
x - The x location to check
y - The y location to check
return value - the index of that blob of land, air, sea, etc
- bool isNearLand( tile tileToCheck, bool largeOnly )
Used to find out if a tile is near land
tileToCheck - the tile you want to check
largeOnly - only look for large bodies of land
return value - true if the tile is near land false if not
- bool isNearWater( tile tileToCheck, bool largeOnly )
Used to find out if a tile is near water
tileToCheck - the tile you want to check
largeOnly - only look for large bodies of water
return value - true if the tile is near water false if not
- setAutoRepair( tile tileToSet, bool autoGoForRepairs )
Used to set the auto-repair state of a unit
tileToSet - the tile you want to set the state on
autoGoForRepairs - true if you want the unit to automatically go for repairs
- bool getAutoRepair( tile tileToCheck )
Used to get the auto-repair state of a unit
tileToCheck - the tile you want to get the state of
return value - true if the unit is set to automatically go for repairs
- setAutoRefuel( tile tileToSet, bool autoGoForFuel )
Used to set the auto-refuel state of a unit
tileToSet - the tile you want to set the state on
autoGoForRepairs - true if you want the unit to automatically go for fuel
- bool getAutoRefuel( tile tileToCheck )
Used to get the auto-refuel state of a unit
tileToCheck - the tile you want to get the state of
return value - true if the unit is set to automatically go for fuel
- int getStat( tile tileToCheck, string stat )
Used to get a stat of a tile.
Here are the stats you can get:
UNITS
"attack" - the unit's attack ability
"max armor" - the unit's max armor amount
"armor" - the unit's current armor amount
"atk range" - the attack range of the unit
"speed" - the base speed of the unit
"see" - the see range of the unit
"max fuel" - the max fuel of the unit
"fuel left" - the amount of fuel the unit has left
"group" - the group the unit belongs to
"transport" - the max number of units this unit can transport
"stored" - the number of units currently stored in this unit
CITIES
"stored" - the number of units currently stored in this city
WAYPONTS
"temp" - if it is a temp waypoint or not
"id" - the waypoint's id
"tracking" - if it is a tracking waypoint or not
tileToCheck - the tile to get the stat from
stat - the stat to get
return value - the value of that stat
- setStat( tile tileToCheck, string stat, int amt )
Used to set a stat of a tile.
Here are the stats you can set:
UNITS
"armor" - the unit's current armor amount
"fuel left" - the amount of fuel the unit has left
tileToCheck - the tile to set the stat on
stat - the stat to set
amt - the value to set the stat to
- blockUnitMessages( tile unit, bool block )
Used to keep a unit from generating messages
unit - the unit to block or unblock
block - true to block the messages false to not
- isBlockingUnitMessages( tile unit )
Used to find out if a unit is blocking its messages
unit - the unit to check
return value - true if the messages are being blocked false if not
- setString( tile tileToSetStringOn, string key, string value )
Used to store associate a string with a tile for later use
tileToSetStringOn - the tile to associate the string with
key - the key to associate the string with
value - the string to store
- string getString( tile tileToGetStringFrom, string key )
Used to get a string stored on a tile
tileToGetStringFrom - the tile to get the string from
key - the key that the string is stored under
return value - the string that was stored on the tile
- setValue( tile tileToSetValueOn, string key, int value )
Used to store associate an int with a tile for later use
tileToSetStringOn - the tile to associate the int with
key - the key to associate the int with
value - the int to store
- int getValue( tile tileToGetFrom, string key )
Used to get a int stored on a tile
tileToGetFrom - the tile to get the int from
key - the key that the int is stored under
return value - the int that was stored on the tile
- bool canBeAtLoc( tile tileToCheck, int x, int y, bool checkUnits, bool enemyOk, bool StoppedOnly )
Used to determine if a unit can be on a certain location on the map
tileToCheck - the unit you want to check
x - the x location on the map to check
y - the y location on the map to checl
checkUnits - if this is true then it will check to see if units are already there
enemyOk - if this is true it is ok to move where an enemy is
StoppedOnly - only checks for units on the map if they are stopped
return value - true if the unit can be there false if not
- tile waypointIDToTile( ownertype player, int id )
Turns a waypointID into an actual waypoint
player - the player that owns this waypoint
id - the id of the waypoint
return value - the waypoint itself
- int addWaypoint( ownerttype owner, int x, int y, bool temp )
Used to add a waypoint to the map
owner - the player this waypoint will belong to
x - the x location to add the waypoint
y - the y location to add the waypoint
temp - true if this is a temp waypoint
return value - the id of the waypoint that was added or 0 if it could not be added
- makeWaypointTemp( tile waypoint, bool makeTemp )
Used to add make a waypoint temp or not. NOTE: If you make a permanent waypoint turn temp it might kill the waypoint.
waypoint - the waypoint
makeTemp - true to make it temp false to make it not temp
- int addTrackingWaypoint( ownertype player, int x, int y, bool temp )
Used to add a tracking waypoint to the map
player - the player this waypoint will belong to
x - the x location on the map to add it
y - the y location on the map to add it
temp - true if it is a temp waypoint
return value - the id of the waypoint
- bool removeWaypoint( ownertype player, int waypointID )
Used to remove a waypoint from the map
player - the player that owns the waypoint
waypointID - the ID of the waypoint
return value - true if it was removed
- bool addUnitToTile( tile container, tile tileToAdd )
Used to add a tile to another unit
container - the tile to add the unit to
tileToAdd - the tile to add to the map
return value - true if it was added false if not
- bool addToMap( tile tileToAdd, int x, int y )
Used to add a tile to the map
tileToAdd - the tile to add to the map
x - the x location to add the tile
y - the y location to add the tile
return value - true if it was added false if not
- removeFromMap( tile tileToRemove )
Used to remove units from the map
tileToRemove - the tile to remove from the map
- setStats( tile tileToSet, int attack, int defense, int seeRange, int attackRange, bool attackUnderwater )
Used to set the base stats of a unit
tileToSet - the tile to set the stats on
attack - the attack of this unit
defense - the defense of this unit
seeRange - the distance this unit can see
attackRange - the distance this unit can attack
attackUnderwater - if true the unit can attack under water units
- setAttackCity( tile tileToSet, int damageAmt )
Used to set the amount of damage a unit does to a city (if zero the unit cant attack cities)
tileToSet - the tile to set the stats on
damageAmt - the amount of damage this unit will do to a city each round
- addFuel( tile tileToAddTo, int amount )
Used to add more fuel to a unit
tileToAddTo - the unit to add the fuel to
amount - the amount of fuel to add to that unit
- setMovement( tile tileToSet, int speed, int useFuel, bool fly, bool water, bool underwater, bool canLand, bool hover )
Used to set the movement attributes of a unit
tileToSet - the unit to set the move attributes on
speed - the speed of this unit
useFuel - -1 if the unit doesnt use fuel or the number of units of fuel this unit carries if the unit does use fuel
fly - true if the unit flys
water - true if the unit moves through the water
underwater - true if the unit moved under the water
canLand - true if the unit can land and save fuel
hover - true if the unit hover
- setAttackAdjustment( tile tileToSet, int air, int ground, int sea )
Used to adjust the amount of damage a unit does to another type of unit
tileToSet - the tile to set the adjustment on
air - the percent to adjust this unit's air attack -100 to +30 (-100 means it cant attack air units)
ground - the percent to adjust this unit's groun attack -30 to +30 (-100 means it cant attack ground units)
sea - the percent to adjust this unit's sea attack -100 to +30 (-100 means it cant attack sea units)
- setDefenseAdjustment( tile tileToSet, int air, int ground, int sea )
Used to adjust the amount of damage a unit takes from another type of unit
tileToSet - the tile to set the adjustment on
air - the percent to adjust this unit's air defense -100 to 100
ground - the percent to adjust this unit's groun defense -30 to +30
sea - the percent to adjust this unit's sea defense -100 to 100
- setSounds( tile tileToSet, string atksound, string missSound, string deathSound )
Used to set the sounds associated with a unit
tileToSet - the unit to set this on
atksound - a path to the wav file that will be used for an attack sound
missSound - a path to the wav file that will be used for the miss sound
deathSound - a path to the wav file that will be used for the death sound
- setImages( tile tileToSet, string imageFile, string maskFile, bool canRotate )
Used to set the images for a tile
tileToSet - the tile to assign the images to
imageFile - a path to the image file
maskFile - a path to a mask that holds the area that should change colors for each player
canRotate - true if the images should rotate when the unit turns
- setDefense( tile tileToSet, int defense )
sets the number of points of defense a city has
tileToSet - the tile you want to get the list from
defense - the number of points of defense a city will have
- setBuild( tile tileToSet, string buildList )
Used to set the list of units a city or unit can build
tileToSet - the tile you want to assign the list to
buildList - the list of units that can be build seperated with - (ex "-aaaaa-bbbbb-ccccc")
- string getBuild( tile tileToGetBuildListFrom )
Used to get the build list from a city or unit
tileToGetBuildListFrom - the tile you want to get the list from
return value - the list of units that can be built seperated with - (ex "-aaaaa-bbbbb-ccccc")
- setRepair( tile tileToSet, int repairSpeed )
Used to set the rate at which a tile can repair other units. It has to be able to transport the unit to repair it.
tileToSet - the tile to set this on
repairSpeed - the number of points of damaged it can fix per turn per unit
- setRefuel( tile tileToSet, int refuelSpeed )
Used to set the rate at which a tile can refuel other units. It has to be able to transport the unit to refuel it.
tileToSet - the tile to set this on
repairSpeed - the number of points of fuel it can provide per turn per unit
- setSuicide( tile tileToSet, bool willSuicide )
Used to turn on or off suicide on a unit. If suicide is on then when the unit attacks it will destroy itself.
tileToSet - the tile to set this on
willSuicide - if true suicide will be turned on false it will be turned off
- setStealth( tile tileToSet, bool hasStealth )
Used to turn on or off stealth on a unit. If stealth is on the unit can only be seen by cities and units with radar.
tileToSet - the tile to set this on
hasStealth - if true stealth will be turned on false it will be turned off
- setRadar( tile tileToSet, bool hasRadar )
Used to turn on or off radar on a unit. If radar is on the unit can see stealth units
tileToSet - the tile to set this on
hasRadar - if true radar will be turned on false it will be turned off
- setMultiAttack( tile tileToSet, bool hasMultiAttack )
Used to turn on or off multiattack on a unit. If on the unit can attack once for every time it can move per turn
tileToSet - the tile to set this on
hasMultiAttack - if true multiattack will be turned on false it will be turned off
- setDefaultAction( tile tileToSet, string action )
Used to set the default action of a tile
tileToSet - the unit, city or waypoint to set this on
action - the action to make it's default
- setDefaultMove( tile tileToSet, string move )
Used to set the default move of a tile
tileToSet - the unit, city or waypoint to set this on
move - the base move type for this tile
- setName( tile tileToSet, string name )
Used to set the name of a tile
tileToSet - the tile whose name you want to set
name - the new name of this tile
- setTransport( tile tileToSet, int count, stirng transportList, bool justStore )
Used to set the list of types that a unit can transport
tileToSet - the unit you want to set this on
count - the number of units this unit can carry
transportList - the list of units this unit can transport seperated by - (ex "-aaaa-bbbb-ccc")
There are five special types you can use as well -AllAir, -AllLand, -AllSea, -AllHover and -AllUnits.
Those types if set will allow this unit to transport air, land, sea, hover or all units.
justStore - if this is set to true the unit cant move while it is full
- getTransportTypes( tile tileToGetTypesFrom )
Used to set the list of types that a unit can transport
tileToGetTypesFrom - the unit you want to get the transport list from
return value - the list of types seperated by - (ex "-Marine-Commando")
- tile createBlankUnit( ownertype player, string type )
Creates a brand new blank unit
player - the player this unit will belong to
type - the type of unit to make
return value - a blank unit
- tile createBlankCity( ownertype player, string type )
Creates a brand new blank city
player - the player this city will belong to
type - the type of city to make
return value - a blank city
- destroyObject( tile tileToDestroy )
Get rid of an unused tile
tileToDestroy - the tile to get rid of
[Top] Map Methods
- setActiveView( string viewName, tile tileToShowTheViewFor )
Makes Pocket War display a view
viewName - the view to display. Legal names are "MapGen", "Map", "Zoom", "Options", "Unit", "City", "Waypoint", "Message", "UnitList", "CityList", "WaypointList", "Stats"
tileToShowTheViewFor - if the view is "Unit", "City", "Waypoint" then this is the unit, city or waypoint to show the view for
- showButton( string ID, bool show )
Used to hide and show buttons on the main map view
ID - The button ID (NEXTTURN, NEXTTURNMULTI, ZOOMOUT, WAYPOINTWALK, UNITWALK, CITYWALK, RECENTER, WAYCREATE, SHOWSELECTED, LISTS, STACK, CUSTOM1, CUSTOM2)
show - true if you want to show the button false to hide it
- setCustomButtonScript( string ID, string script )
Used to set the script at a custom button will run
ID - The button ID (CUSTOM1, CUSTOM2)
script - the script to run
- array getCities( ownertype player )
Used to get a list of the cities owned by a player
player - the player that owns the cities
return value - the list of cities
- array getUnits( ownertype player, bool onMapOnly )
Used to get the list of units owned by a player
player - the player that owns the untis
onMapOnly - true if you only want the units on the map false if you want the units stored in cities as well.
return value - the list of units
- int getDistanceFromTile( tile sourceTile, tile destTile )
Used to get the distance between two tiles
sourceTile - the source tile
destTile - the destination tile
return value - the distance between the two
- int getDistanceFromPoint( int x1, int y1, int x2, int y2 )
Used to get the distance between two points on the map
x1 - the x of point 1
y1 - the y of point 1
x2 - the x of point 2
y2 - the y of point 2
return value - the distance between the two points
- tile getTileAtPos( int x, int y )
Gets a tile at a certain position on the map
x - the x location on the map
y - the y lcoation on the map
return value - the tile at that location or false if nothing is there
- tile getCityAtPos( int x, int y )
Gets a city at a certain position on the map
x - the x location on the map
y - the y lcoation on the map
return value - the city at that location or false if nothing is there
- tile getAirUnitAtPos( int x, int y )
Gets an air unit at a certain position on the map
x - the x location on the map
y - the y lcoation on the map
return value - the air unit at that location or false if nothing is there
- tile getNonairUnitAtPos( int x, int y )
Gets a non-air unit at a certain position on the map
x - the x location on the map
y - the y lcoation on the map
return value - the tile at that location or false if nothing is there
- tile getWaypointAtPos( ownertype player, int x, int y )
Gets a waypoint at a certain position on the map
player - the owner of the waypoint
x - the x location on the map
y - the y lcoation on the map
return value - the waypoint at that location or false if nothing is there
- setPan( int x, int y )
Sets the location of the top left corner of the map
x - the x location
y - the y lcoation
- int getPanX()
Gets the X location of the top left corner of the screen
return value - the x value of the top left or -1 on error
- int getPanY()
Gets the Y location of the top left corner of the screen
return value - the y value of the top left or -1 on error
- loadMap( string mapName )
Loads a map from storage. It must be from the current mod. If this method fails bad things happen.
mapName - the name of the map to load
- saveMap( string mapName )
Saves a map top storage. It must be from the current mod. If this method fails bad things happen.
mapName - the name of the map to save
[Top] Land Methods
- tile createBlankLandType( string type )
Creates a new blank land type
type - the type of land to create
return value - a blank land type
- var getLandProperty( tile land, string prop )
Gets a property of a land tile
land - the land tile
prop - the prop to get. Legal values are "land speed", "air speed", "hover speed", "sea speed", "type"
return value - the value of the prop or false if that prop doenst exist
- tile getLandAtPos( int x, int y )
Gets the land tile at a certain location on the map
x - x location on the map to get the tile from
y - y location on the map to get the tile from
return value - the land tile at that position or false if one does not exist there
- setLandAtPos( tile land, int x, int y )
Sets the land tile at a certain location on the map
land - the land tile to place on the map
x - x location on the map to get the tile from
y - y location on the map to get the tile from
- setLandTypeSpeed( tile land, int air, int ground, int sea, int underwater, int hover )
Sets the speed multiplyer that will be applied to units on that type of land
land - the land to set this on
air - the multiplier for air units (0 means air units cant travel on this type of land)
ground - the multiplier for ground units (0 means ground units cant travel on this type of land)
sea - the multiplier for sea units (0 means sea units cant travel on this type of land)
underwater - the multiplier for underwater units (0 means underwater units cant travel on this type of land)
hover - the multiplier for hover units (0 means hover units cant travel on this type of land)
- setLandTypeColor( tile land, int red, int green, int blue )
Sets the color that will be used in the minimap for this type of land
land - the land to set this on
red - the red value
green - the green value
blue - the blue value
- setLandTypeBorderColor( tile land, string otherType, int red, int green, int blue )
Sets the color that will be used in the minimap when this land is against another type of land
land - the land to set this on
otherType - a string that is the name of the other type of land
red - the red value
green - the green value
blue - the blue value
- setLandTypeBaseImage( tile land, string path, string imageNameRoot, string ext )
Sets the base image for this type of land
land - the land to set this on
path - the path to the land image files
imageNameRoot - the root of the name of the image files for this type of land. It will look for files with this name
plus 0 - X. For example if imageNameRoot = "hello" it will look for "hello0", "hello1", etc until it cant find on of the files.
ext - the file extention of the images to look for
- setLandTypeSpecialImage( tile land, string path, string imageNameRoot, string ext )
Sets the special images for this type of land (these are images that add character)
land - the land to set this on
path - the path to the land image files
imageNameRoot - the root of the name of the image files for this type of land. It will look for files with this name
plus 0 - X. For example if imageNameRoot = "hello" it will look for "hello0", "hello1", etc until it cant find on of the files.
ext - the file extention of the images to look for
- setLandTypeBorderImages( tile land, string otherType, string path, string imageNameRoot, string ext )
Sets the border image for this type of land when it bounds some other type of land
land - the land to set this on
otherType - the type of the land this will boarder against
path - the path to the land image files
imageNameRoot - the root of the name of the image files for this type of land. It will look for files with this name
plus 0 - X. For example if imageNameRoot = "hello" it will look for "hello0", "hello1", etc until it cant find on of the files.
ext - the file extention of the images to look for
- setLandTypeGenerateInfo( tile land, string type, int iterations, int initialChance, int generationChance, int minimumDistance, int specialChance )
Sets the info needed to generate this type of land
land - the land to set this on
type - the generation method to use
iterations - the base number of iterations to grow the land
initialChance - the initial chance of this type of land being placed on the map (a number between 1 and some big number)
generationChance - the chance that this type of land will be added during each iteration
minimumDistance - the min distance between this and other land type it cant border
specialChance - the chance of a special tile being used rather than a base tile
[Top] Dialog Methods
- dialog createBlankDialog( string title, string onDisplay )
Used to create a blank dialog
title - the title of the dialog
onDisplay - javascript to run when the dialog starts up
return value - the new dialog
- addStaticText( dialog dlg, int x, int y, int wid, int hi, string ID, string text, jscode onPush, bool bold, bool center )
Used to a static text string to a dialog
dlg - the dialog
x - left side of the control
y - top of the control
wid - the width of the control
hi - the height of the control
ID - the id of this control
text - the text to display
onPush - javascript to call if the user pushes the text
bold - true if you want the text to be larger
center - true to center the text in the area
- addButton( dialog dlg, int x, int y, int wid, int hi, string ID, string pathToImage, jscode onChange )
Used to an image button to a dialog
dlg - the dialog
x - left side of the control
y - top of the control
wid - the width of the control
hi - the height of the control
ID - the id of this control
pathToImage - the path to the image to display
onPush - javascript to call if the user pushes the image
- addIntSelector( dialog dlg, int x, int y, int wid, int hi, string ID, int initialValue, jscode onChange )
Used to an int selector to a dialog
dlg - the dialog
x - left side of the control
y - top of the control
wid - the width of the control
hi - the height of the control
ID - the id of this control
initialValue - the initial value to show in the control
onChange - javascript to call when the value changes
- addCheckBox( dialog dlg, int x, int y, int wid, int hi, string ID, string title, bool checked, jscode onChange )
Used to a checkbox to a dialog
dlg - the dialog
x - left side of the control
y - top of the control
wid - the width of the control
hi - the height of the control
ID - the id of this control
title - the text to place next to the checkbox
checked - the initial value of the checkbox
onChange - javascript to call when the value changes
- int showDialog( dialog dlg )
Shows a modal dialog and returns the the value from the dialog when the dialog is closed
dlg - the dialog
return value - the return code from the dialog
- closeDialog( dialog dlg, int result )
closes a dialog
dlg - the dialog
result - the return code that will be returned from showDialog
- var getInputValue( dialog dlg, string ctrlID )
Gets the value of a control from a dialog
dlg - the dialog
ctrlID - the id of the control to get the value from
return value - int, string or bool that represents the state of the control
- bool getShow( dialog dlg, string ctrlID )
Gets the shown/hidden state of a control on a dialog
dlg - the dialog
ctrlID - the id of the control to check
return value - true if the control is shown false if not
- setShow( dialog dlg, string ctrlID, bool show )
Sets the shown/hidden state of a control on a dialog
dlg - the dialog
ctrlID - the id of the control to check
show - true if the control is shown false if not
[Top] Callbacks
- startScript()
Called when the script is about to state
The global variable tile will be set if this script is assigned to a tile
- bool worksWithThisTile()
Called to find out if the script works with a certain type of tile
The global variable tile will be set and is the tile to check
return value - return true if it does work with the tile and false if it doesnt
- preUnitMove( int moveNumber )
Called before a unit moved
The global variable tile will be set and is the unit that is about to move
moveNumber - the number of times this unit has already moved this turn
- postUnitMove( int moveNumber )
Called after a unit moves
The global variable tile will be set and is the unit that moved
postUnitMove - the number of times this unit has already moved this turn
- preDoProduction()
Called before a city carries out its production cycle
The global variable tile will be set and is the city that is about to do its production
- unitBuilt( tile unitThatWasBuilt )
Called after a unit is built by a city or another unit
The global variable tile will be set and is the unit or city that built the tile
unitThatWasBuilt - the unit that was built
- preUnitEntered( tile unitToEnter )
Called right before a unit enters a city or unit -- called on the city ot unit being entered
The global variable tile will be set and is the city or unit unitToEnter is entering
unitToEnter - the unit that will enter the city or unit
- postUnitEntered( tile unitEntered )
Called right after a unit enters a city or unit -- called on the city ot unit being entered
The global variable tile will be set and is the cityor unit, unitToEnter has entering
unitEntered - the unit that has entered the city or unit
- enteredTile( tile tileEntered )
Called right after a unit enters a city or unit -- called on the unit doing the entering
The global variable tile will be set and is the unit that entered another unit
tileEntered - the tile the unit entered
- preUnitLeaving( tile unitLeaving, bool isNew )
Called right before a unit leaves a city or unit -- called on the city ot unit being left
The global variable tile will be set and is the city or unit the stored unit is leaving from
unitLeaving - the unit leaving the city or unit
isNew - true if the unit is new
- postUnitLeaving( tile unitLeaving, bool isNew )
Called right after a unit leaves a city or unit -- called on the city ot unit being left
The global variable tile will be set and is the city or unit the stored unit left
unitLeaving - the unit leaving the city or unit
isNew - true if the unit is new
- leftTile( tile tileLeft )
Called right after a unit leaves a city or unit -- called on the unit doing the leaving
The global variable tile will be set and is the unit that left the another unit
tileLeft - the tile the unit left
- killedUnit( tile unitThatWasKilled )
Called right after a unit kills another unit
The global variable tile will be set and is the unit that killed the other unit
unitThatWasKilled - the unit that was killed
- wasKilled( tile killer )
Called right after a unit is killed by another unit
The global variable tile will be set and is the unit that was killed
killer - the unit that was the killer
- spottedEnemy( tile unitSpotted )
Called when a unit spots an enemy unit
The global variable tile will be set and is the unit that spotted the enemy
unitSpotted - the unit that was spotted
- spottedCity( tile citySpotted )
Called when a unit spots a city
The global variable tile will be set and is the unit that spotted the city
citySpotted - the city that was spotted
- cityCaptured( tile city )
Called right after a city is captured - the city scripts and ai scripts get this call
city - the city that was captured
- void capturedCity( tile cityCaptured )
Called by pocket War when a unit has captured a city. The Global var tile will contain the unit that captured the city. The unit scripts get this call
cityCaptured - the city that was captured
- void attackCityFailed( tile cityAttacked )
Called by pocket War when a unit failed to captured a city. The Global var tile will contain the unit that tried. The unit script gets this call.
cityAttacked - the city that was attacked
- reachedWaypoint( int waypointID, int x, int y )
Called when a unit reaches a waypoint. The waypoint may not exist anymore if it was a temp waypoint.
The global variable tile will be set and is the unit that reached the waypoint
waypointID - the id of the waypoint reached
x - the X location on the map where the waypoint was reached
y - the Y location on the map where the waypoint was reached
- unitArrived( tile unit )
Called on a waypoint when a unit reaches it.
The global variable tile will be set and is the waypoint the unit reached
unit - the unit that reached the waypoint
- preTurn( int turnNumber )
Called right before the player's turn happens
turnNumber - the turn number
- postTurn( int turnNumber )
Called right after the player's turn happens
turnNumber - the turn number
- lowOnFuel()
Called when a unit is running out of fuel
The global variable tile will be set and is the unit that is running out of fuel
- needRepairs()
Called when a unit is is hurt
The global variable tile will be set and is the unit that is hurt
- void wasRefueled()
Called by Pocket War when a unit has been refueled. The Global var tile will contain the unit that was just refueled.
- void wasRepaired()
Called by Pocket War when a unit has been repaired. The Global var tile will contain the unit that was just repaired.
- string getTypes()
Called by Pocket War to get the list of city types or unit types or land types depending on the script.
return value - a string with the list of types in it seperated by - (ex "-aaaa-bbbb-cccc" )
- createUnit( unit )
Called by Pocket War when it wants to create a unit
unit - the unit breing created
- tile createCity( tile city, int count )
Called by Pocket War when it wants to create a city
city - the city being created
count - how many cities have already been created
- boolean canPlaceCity( tile city, int x, int y )
Called by Pocket War when to find out if it can place a city at a certain location on the map
city - the city being created
x - the x location on the map
y - the y location on the map
return value - true if the city can be placed at that location false if not
- tile createLandType( string landType )
Called by Pocket War when it wants to create a new land type
landType - the type of land Pocket War want to create
return value - the new land type
- string getTitleScreenImage()
Called by Pocket War to get the image to use as a title screen
return value - a path to the image to use as a title screen
- doNewGame()
Called by Pocket War when it wants to start a new game
- bool checkEndOfGame()
Called by Pocket War to see if the game should end
return value - true if the game should end false if not
- bool preMapGenerate()
Called by Pocket War when it is generating a new map. It should return true
if it wants pocket war to generate the map false if not. There are some global variables set when this
method is called see global variable section blow.
return value - false if you dont want pocket war to generate the map (if the script did that instead)
- bool preAddCities()
Called by Pocket War when it is generating a new map and before it adds the cities. It should return true
if it wants pocket war to add the cities and false if not. There are some global variables set when this
method is called see global variable section blow.
return value - false if you dont want pocket war to add any cities (if the script did that instead)
- postMapGenerate()
Called by Pocket War after it has generated a new map
- postUnitLoad()
Called by Pocket War after it loads a unit
Global variable tile - will be set to the tile being loaded
- displayDialog( string name )
Called by pocket war when it wants to display a dialog
Global variable tile - will be set to the tile assoicated with the dialog if there is one
name - the name of the type of dialog. ("script", "city", "unit", "waypoint")
return value - false if you dont want pocket war to display the dialog (if the script did it)
[Top] Globals
- tile tile
If this script is associated with a tile then this variable will be defined to represent that tile - read only
- ownertype player
The player that is currently running this script - read only
- int waypoint0
The ID for waypoint 0 that was passed into this script by the user or another script
- int waypoint1
The ID for waypoint 1 that was passed into this script by the user or another script
- int waypoint2
The ID for waypoint 2 that was passed into this script by the user or another script
- ownertype player0
This global represents all neutral things on the map - read only
- ownertype player1
This global represents the human player - read only
- ownertype player2
This global represents the computer AI - read only
- ownertype player3
This global is currently unused - read only
- ownertype player4
This global is currently unused - read only
- int numNeutralCities
The number of neutral cities the game engine will create when the map is being built. This var only exists
during the preMapGenerate and preAddCities callbacks. If you can this variable them pocket war will
adjust how many cities it makes. The game engine will not support more than 100 cities total on the map.
- int numPlayer1Cities
The number of player 1 owned cities the game engine will create when the map is being built. This var only exists
during the preMapGenerate and preAddCities callbacks. If you can this variable them pocket war will
adjust how many cities it makes. The game engine will not support more than 100 cities total on the map.
- int numPlayer2Cities
The number of player 2 owned cities the game engine will create when the map is being built. This var only exists
during the preMapGenerate and preAddCities callbacks. If you can this variable them pocket war will
adjust how many cities it makes. The game engine will not support more than 100 cities total on the map.
- int numPlayer3Cities
The number of player 3 owned cities the game engine will create when the map is being built. This var only exists
during the preMapGenerate and preAddCities callbacks. If you can this variable them pocket war will
adjust how many cities it makes. The game engine will not support more than 100 cities total on the map.
- int numPlayer4Cities
The number of player 4 owned cities the game engine will create when the map is being built. This var only exists
during the preMapGenerate and preAddCities callbacks. If you can this variable them pocket war will
adjust how many cities it makes. The game engine will not support more than 100 cities total on the map.
- int mapWidth
the width of the entire map - read only
- int mapHeight
the height of the entire map - read only
- int screenWidth
the width of the game screen - read only
- int screenHeight
the height of the game screen - read only
[Top] Strings (ID. string)
- "Fuel"
- "%s refueled"
- "unlimited"
- "%s needs fuel"
- "%s low on fuel"
- "Refuel buffer"
- "Max Fuel"
- "Fuel Left"
- "Go for fuel"
- "Toggle auto-refuel"
- "Toggle auto-repair"
- "Move"
- "Action"
- "Group"
- "Stored"
- "Build"
- "Script"
- "Attack"
- "Max Armor"
- "Armor"
- "Speed"
- "See"
- "Atk Range"
- "Stop moving"
- "Go explore"
- "Go to a waypoint"
- "Go for repairs"
- "Defend"
- "Attack enemy"
- "Attack city"
- "Go to nearest transport"
- "Go to nearest city"
- "Don't run a script"
- "Defensive unit - no settings to change."
- "Kick out all stored units"
- "Leave the group"
- "Stop making %s"
- "Building a %s"
- "Building"
- "Next"
- "Automake %s"
- "Mini-Map"
- "%s repaired"
- "%s produced"
- "Production stopped city full"
- " - Enemy"
- " - Neutral"
- "Help"
- "%s entered "
- "Waypoint #%d"
- "%s is full"
- "Waypoint"
- "Let unit decide what to do"
- "Make new units stay in the city"
- "Send new units to a waypoint"
- "Make new units go to nearest transport"
- "Message List"
- "City List"
- "Unit List"
- "Waypoint List"
- "Stop units from moving"
- "Make units explore"
- "Make units go to a waypoint"
- "Let the units decided what to do"
- "Make units defend"
- "Make units attack enemies"
- "Make units attack cities"
- "Make units go to nearest transport"
- "Make units go to nearest city"
- "Building Map Please Wait"
- " Turn %d"
- "Score %d"
- "Loading Game "
- "Saving Game "
- "Auto-saving "
- "Turn #%d - Player's Turn "
- "Turn #%d - Ready"
- "Turn #%d - Computer's Turn "
- "This game is over."
- "%s IsEnemy %d"
- "Pausing after this turn"
- "Scripts"
- "Group [%d]"
- "Options"
- "Volume"
- "Repair if less than"
- "Window opaqueness"
- "Auto-save"
- "Make a new Map"
- "Enemy AI"
- "Difficulty"
- "Size"
- "Use fog of war"
- "Generating "
- "Smoothing "
- "Placing Cities "
- "%s is lost"
- "%s is attacking a city!"
- "%s is being invaded!"
- "%s has been captured"
- "%s has fallen"
- "%s was defeated"
- "%s repelled the enemy"
- "%s died"
- "%s is at waypoint %d"
- "%s spotted an enemy."
- "%s is attacking the enemy!"
- "%s is being attacked!"
- "%s killed enemy "
- "%s was destroyed"
- "%s did %d damage"
- "%s missed the enemy"
- "%s damaged %d pts %d left"
- "%s evaded the attack"
- "%s has crashed"
- "%s hit by %s"
[Top] Setting - possible settings values
- "MsgCityFull"
- "MsgHasBeenCaptured"
- "MsgHasFallen"
- "MsgWasDefeated"
- "MsgRepelledTheEnemy"
- "ShowSplash"
- "UseCursor"
- "FollowSelected"
- "Sound"
- "LeftHanded"
- "DoubleBuffer"
- "FastCursor"
- "NonexistWaypoint"
- "ShowUnitsAttacking"
- "ShowRanges"
- "RefuelBuffer"
- "RepairBuffer"
- "FullScreen"
- "Opaqueness"
- "NoStop"
- "AutoSave"
- "Music"
- "ShowGridLines"
- "ShowGridNumbers"
- "HazeFog"
- "Volume"
- "AutoShowMessages"
- "Debug"
- "FogOfWar"
[Arctic Hunter Mod Tutorial]