Colobot Wiki
Advertisement

Use this type for variables that contain the characteristics of an object, be it a bot, a building, some raw material, an enemy, etc. Here are all properties of an object:

  • int    object.category     Category of the object
  • point  object.position     Position of the object (x,y,z)
  • float  object.orientation  Orientation of the object (0..360)
  • float  object.pitch        Forward/backward angle of the object
  • float  object.roll         Right/left angle of the object 
  • float  object.energyLevel  Energy level (0..1)
  • float  object.shieldLevel  Shield level (0..1)
  • float  object.temperature  Jet temperature (0..1)
  • float  object.altitude     Altitude above ground
  • float  object.lifeTime     Lifetime of the object
  • object object.energyCell   Power cell on the bot
  • object object.load         Object carried by the bot
  • int    object.team         The object's team (see code battles)
  • point  object.velocity     Velocity of the object

Also, some objects have additional methods (instructions). See them in the main list in the "Specific instructions to some bots" section.


category[]

The category of an object allows you to know what it is, for ex. what kind of bot, building, enemy, etc.

position[]

Position of the object on the planet, in meters. The coordinates x and y correspond to the location on a map, the z coordinate corresponds to the altitude above (respectively below) sea level. 

orientation[]

Orientation of the object, in degrees. The orientation tells you what direction the object is facing. An orientation of 0 corresponds to an object facing eastwards, thus following the positive x axis. The orientation is measured counterclockwise. 

pitch[]

Forward/backward angle of the robot. A pitch of 0 means that the bot is standing on flat ground. A positive inclination means that it is facing upwards, a negative inclination means that it is facing downwards. 

roll[]

Left/right angle of the bot, in degrees. A positive value means that the bot is leaning to the left side, a negative value means that it is leaning to the right side. 

energyLevel[]

Energy level, between 0 and 1. A normal power cell that is fully charged returns the value 1. A nuclear power cell never returns a value higher than 1, it just lasts longer. Attention: The energy level of a bot is always zero, because the energy is not contained in the bot, but in the power cell. To know the energy level of the power cell of a bot, you must write energyCell.energyLevel. 

shieldLevel[]

Shield level of a robot or building. A level 1 indicates that the shield is still perfect. Every time that the bot or building gets a damaged by an enemy or friendly fire, or collides with another object at high speeds, the shield level decreases. When the level reaches 0, the next attack or collision will destroy the bot or building. 

Bots can re-energize their shield on a repair center. The shield of a building is repaired if it lays inside the protection sphere of a shielder.

temperature[]

Temperature of the jet of winged bots. 0 corresponds to a cold jet. When used, the temperature increases progressively. When it reaches the value 1, the jet is overheated and stops working, until it cooled down a little. 

altitude[]

The z coordinate of the position indicates the altitude above sea level, whereas the altitude indicates the height above ground. This value is meaningful only for winged bots and for wasps. For all other objects, this value is zero. 

lifeTime[]

The age of the object in seconds since it's creation.

energyCell[]

This information is special, because it returns the information about another object, in this case the power cell. This means that energyCell contains all the characteristics of a normal object, for example category (PowerCell or NuclearCell), position (the position of the cell), etc.

If you want to know the energy level of a robot, you must not check energyLevel, but energyCell.energyLevel.

If the bot has bot no power cell, energyCell returns null.

load[]

This information also returns the description of a whole object: the description of the object carried by a grabber. If it carries nothing, load returns null.

team[]

The bot's team. Used in code battles. If the object has no team assigned (e.g. in no team-based levels, the object being a resource or the starting derricks), this is a neutral object and will be equal to 0.

velocity[]

Current velocity of the object. Should be treated as a three-dimensional vector.

Examples[]

The type object returns the special value null when the object does not exist. For example:

	object a;
	a = radar(BotGrabberRoller);
	if ( a == null )  // object does not exist ?
	{
	}
	if ( a.position.z > 50 )  // is it on a mountain ?
	{
	}
Advertisement