Galaxy (Server)

This object is only available on the server.

function  Galaxy()

Returns

 A new instance of Galaxy

```
           function Faction

```

 Creates a new faction with home sector at the given coordinates. Name, turrets and styles will be generated automatically.

Parameters

```
           x The x coordinate of the faction's home sector

           y The y coordinate of the faction's home sector

```

Returns

 The new faction

```
           function Faction

```

### createFaction

(string name, int x, int y)

 Creates a new faction with a specified name and home sector at the given coordinates. Turrets and styles will be generated automatically. If the faction name is already taken, returns the faction with the specified name.

Parameters

```
           name The name of the new faction. Must be unique.

           x The x coordinate of the faction's home sector

           y The y coordinate of the faction's home sector

```

Returns

 The new faction, or, if already existing, the existing faction

```
           function Faction

```

### getLocalFaction

(int x, int y)

 Does a lookup on the faction map and retrieves the faction controlling the given sector. This may trigger a creation of a faction that does not yet exist.

Parameters

```
           x The x coordinate of the sector

           y The y coordinate of the sector

```

Returns

 The new faction, or nil if the sector is in no man's land

```
           function Faction

```

### getNearestFaction

(int x, int y)

 Does a lookup on the faction map and retrieves the nearest faction to the given sector. Distance is calculated by the factions' home sector. This may trigger a creation of a faction that does not yet exist.

Parameters

```
           x The x coordinate of the sector

           y The y coordinate of the sector

```

Returns

 The new faction, or nil if the sector is in no man's land

```
           function Faction

```

### getControllingFaction

(int x, int y)

 Does a lookup on the faction map and retrieves the faction controlling the sector. The faction is determined by the influence of sectors around the sector to check. As sectors are generated while players are exploring, influence over sectors is also only generated while players are exploring. It's very possible that as long as not all sectors near the tested sector have been discovered, the influence is not yet determined nor final.

Parameters

```
           x The x coordinate of the sector

           y The y coordinate of the sector

```

Returns

 The new faction, or nil if the sector's controller is unknown

```
           function Faction

```

### findFaction

(var identifier)

 Looks for a faction with the given name or index. This will not trigger the creation of a new faction. Finding players with this method is not possible, since player names can change via Steam.

Parameters

```
           identifier A string or int, describing the name or index of the faction, respectively

```

Returns

 The faction if found, or nil

```
           function Faction

```

### getPirateFaction

(int level)

```
           function string...

```

### getPlayerNames

()

```
           function string...

```

### getOnlinePlayerNames

()

```
           function

```

### setFactionRelations

(Faction a, Faction b, int level)

Returns

 nothing

```
           function

```

### changeFactionRelations

(Faction a, Faction b, int delta)

Returns

 nothing

```
           function int

```

### registerCallback

(string callbackName, string functionName)

 Register a callback in the galaxy. The callback may arrive with a delay.

Parameters

```
           callbackName The name of the callback

           functionName The name of the function that will be executed in the script when the callback happens

```

Returns

 0 on success, 1 if the registration failed

```
           function int

```

### unregisterCallback

(string callbackName, string functionName)

```
           function bool

```

### sectorExists

(int x, int y)

 Check if a sector exists. This function checks if the sector exists in the database.

Parameters

```
           x The x coordinate of the sector

           y The y coordinate of the sector

```

Returns

 1 if the sector exists, 0 otherwise