Factorio.com|Forums|Wiki|Mod Portal|API Docs

# Factorio Runtime Docs Version 2.0.77

# LuaPlanet - Runtime Docs

## Class LuaPlanet

The runtime values of a planet

## Members

create_surface() | → LuaSurface | Creates the associated surface if one doesn't already exist.
Creates the associated surface if one doesn't already exist.
associate_surface(surface) |  | Associates the given surface with this planet. [...]
Associates the given surface with this planet. [...]
reset_map_gen_settings() |  | Resets the map gen settings on this planet to the default from-prototype state.
Resets the map gen settings on this planet to the default from-prototype state.
get_space_platforms(force) | → array[LuaSpacePlatform] | Gets the built space platforms orbiting this planet on the given force. [...]
Gets the built space platforms orbiting this planet on the given force. [...]
name | :: R string | The planets name.
The planets name.
prototype | :: R LuaSpaceLocationPrototype |
surface | :: R LuaSurface? | The surface for this planet if one currently exists. [...]
The surface for this planet if one currently exists. [...]
valid | :: R boolean | Is this object valid? [...]
Is this object valid? [...]
object_name | :: R string | The class name of this object. [...]
The class name of this object. [...]

## Methods

### create_surface() → LuaSurface

Creates the associated surface if one doesn't already exist.

### associate_surface(surface)

Associates the given surface with this planet. Surface must not already be associated with a planet and the planet must not already have an associated surface.

Planet must not be using entities_require_heating.

#### Parameters

surface | :: SurfaceIdentification | The surface to be associated.
The surface to be associated.

### reset_map_gen_settings()

Resets the map gen settings on this planet to the default from-prototype state.

### get_space_platforms(force) → array[LuaSpacePlatform]

Gets the built space platforms orbiting this planet on the given force.

Note, this does not include platforms that have not yet been built.

#### Parameters

force | :: ForceID |

## Attributes

### name :: Read string

The planets name.

### prototype :: Read LuaSpaceLocationPrototype

### surface :: Read LuaSurface?

The surface for this planet if one currently exists.

Planets do not default generate their surface. LuaPlanet::create_surface can be used to force the surface to exist.

LuaPlanet::associate_surface can be used to create an association with an existing surface.

### valid :: Read boolean

Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.

### object_name :: Read string

The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.

Class used in

- LuaGameScript::planets
- LuaSurface::planet
- RegistrationTarget