VoidExpanse/scope-generator: Difference between revisions

From AtomicTorchWiki
No edit summary
No edit summary
Line 161: Line 161:
<pre style="margin:0px;">var id = generator.AddSpaceObject(1, 0, 0, "Debris01", {class: "mine"})</pre> |
<pre style="margin:0px;">var id = generator.AddSpaceObject(1, 0, 0, "Debris01", {class: "mine"})</pre> |
Adds a space object to game world. Space objects are interactive object. They cannot be destroyed, but they are interactive and collision-enabled. For example, spacemines are created with space objects.
Adds a space object to game world. Space objects are interactive object. They cannot be destroyed, but they are interactive and collision-enabled. For example, spacemines are created with space objects.
As xml_type_id you can use keyword "random" - then  
NOTE: As xml_type_id you can use keyword "random" - then a random space object will spawn.
}}
 
 
{{Scripting_api|AddStar|
* int: system_id
* double: coord_x
* double: coord_y
* int: seed
* int: heat - how much damage star deals, when ship approaches
* ''(optional) string: typeID''
|
int: ID of created object|
<pre style="margin:0px;">var id = generator.AddStar(1, 0, 0, 234, 0)</pre> |
Adds a star. Conventionally, you shouldn't add more then 1 star to a system.
If typeID is not specified, type will be picked by random, based on seed parameter.
}}
 
{{Scripting_api|AddSystem|
* double: coord_x
* double: coord_y
* string: name
* int: seed|
int: ID of created system|
<pre style="margin:0px;">var id = generator.AddSystem(0, 0, "Hawkins Eta", 123)</pre> |
Adds a star system. Star system can be added anywhere, and by default it won't be connected to any other systems. See tutorial to see, how systems generation works.
}}
 
 
{{Scripting_api|SetSystemTags|
* int: system_id
* object: tags|
void|
<pre style="margin:0px;">generator.SetSystemTags(1, {"show_clouds": "yes"})</pre> |
Sets tags of specified star system. Can be expanded with generator.AddSystemTag and retrieved by
generator.GetSystemTags.
}}
 
{{Scripting_api|AddSystemTag|
* int: system_id
* string: name
* object: value|
void|
<pre style="margin:0px;">generator.AddSystemTag(1, "show_clouds", "yes")</pre> |
Adds tag to star system tags (or overwrites existing one with the same name).
}}
 
{{Scripting_api|GetSystemTags|
* int: system_id|
object: tags set by methods above|
<pre style="margin:0px;">var tags = generator.GetSystemTags(1);
if(tags != null && tags["show_clouds"] == "yes")
{
console.Print("System 1 was told to show clouds");
}</pre> |
Retrieves tags of star system, which were set by SetSystemTags and AddSystemTag.
}}
 
 
{{Scripting_api|AddAnomaly|
* int: system_id
* string: anomaly_id
* object: args |
void|
<pre style="margin:0px;">generator.AddAnomaly(args.sys_id, "radar_disable", {});</pre> |
Adds anomaly to star system. There are few predefined anomalies (see more in the article [[VoidExpanse/anomalies|Anomalies]]), but you can specify and implement your own anomalies.
}}
 
{{Scripting_api|SystemClose|
* int: system_id|
void|
<pre style="margin:0px;">generator.SystemClose(20);</pre> |
Sets system status to closed. Can be used anywhere, has no hardcoded implementation. For example, now
it's being used to prevent player to travel to alien systems. System can be opened with generator.SystemOpen.
All systems are opened by default.
}}
 
{{Scripting_api|SystemOpen|
* int: system_id|
void|
<pre style="margin:0px;">generator.SystemOpen(20);</pre> |
Sets system status to opened. Can be used anywhere, has no hardcoded implementation. For example, now
it's being used to prevent player to travel to alien systems. System can be closed with generator.SystemClose.
All systems are opened by default.
}}
 
{{Scripting_api|IsSystemClosed|
* int: system_id|
bool|
<pre style="margin:0px;">var closed = generator.IsSystemClosed(20);</pre> |
Check whether system is closed or not.
}}
 
{{Scripting_api|SetSystemPlaylists|
* int: system_id
* object: key->value object|
void|
<pre style="margin:0px;">generator.SetSystemPlaylists(args.sys_id,
{
"explore": "playlist_generic_explore",
"combat": "playlist_generic_combat"
}
);</pre> |
Sets system music playlists. There are few possible keys, see more in [[VoidExpanse/MusicPlaylists]].
}}
 
{{Scripting_api|SetSystemPlaylists|
* int: system_id
* object: key->value object|
void|
<pre style="margin:0px;">generator.SetSystemPlaylists(args.sys_id,
{
"explore": "playlist_generic_explore",
"combat": "playlist_generic_combat"
}
);</pre> |
Sets system music playlists. There are few possible keys, see more on playlists in [[VoidExpanse/MusicPlaylists]].
}}
 
{{Scripting_api|AddSystemsLink|
* int: system_id
* int: system_2_id|
void|
<pre style="margin:0px;">generator.AddSystemsLink(1,2);</pre> |
This function creates a link between two systems. This links are simply logical, but there are
few hardcoded rules about them. There are some specific rules, that are applied to every link:
* Duplication - cannot create a link between already linked systems
* Future Linking - cannot create a link between systems, that aren't exist yet
* Proximity - link cannot pass closer then 2 units to a star
* Intersections - link cannot intersect any other link
Links created this way are displayed on galaxy map. By this links jumpgates are created (though, there is no hard rule about that - you can create jumpgate without link between two star systems, but this connection won't be displayed on galaxy map).
}}
 
{{Scripting_api|FixConnectivity|
void|
void|
<pre style="margin:0px;">generator.FixConnectivity();</pre> |
Should be called after all stars and links were created. It checks, if all stars are reachable from one another, and, if not, it creates missing star systems links.
}}
 
{{Scripting_api|DockShipToBase|
* int: ship_id
* int: base_id|
void|
<pre style="margin:0px;">generator.DockShipToBase(12253,2);</pre> |
Immediately, without any animations, checkups and routines, docks ship to a space station. It's better not to use it on players, because it'll have unpredictable behavior.
}}
 
{{Scripting_api|ExpandArea|
* array: array of stars IDs |
void|
<pre style="margin:0px;">var stars = [3];
while(true)
{
stars = generator.ExpandArea(stars);
if(newstars.length >= 10) break;
}
console.Print("Now we have an area of 10 or more stars around star with id 3");
</pre> |
Function, which returns the same array, as input + all stars, which are linked to input ones by 1 link. In other words, it returns an area, expanded by 1 link. Very useful during generation of zones in galaxy, such as faction territories.
}}
 
 
{{Scripting_api|GetAllSystems|
void|
array: IDs of all systems|
<pre style="margin:0px;">var arr = generator.GetAllSystems();</pre> |
}}
 
 
{{Scripting_api|GetAsteroidTypes|
void|
array: xml_ids (strings) of all asteroids|
<pre style="margin:0px;">var arr = generator.GetAsteroidTypes();</pre> |
}}
 
{{Scripting_api|GetClosestSystemToPoint|
* double: coord_x
* double: coord_y|
int: ID of picked system of 0, if none|
<pre style="margin:0px;">var sys_id = generator.GetClosestSystemToPoint(0,0);</pre> |
Useful during generation process.
}}
 
{{Scripting_api|GetDebrisTypes|
void|
array: xml_ids (strings) of all space objects|
<pre style="margin:0px;">var arr = generator.GetDebrisTypes();</pre> |
Useful during generation process. Alias of generator.GetSpaceObjectsTypes.
}}
 
{{Scripting_api|GetSpaceObjectsTypes|
void|
array: xml_ids (strings) of all space objects|
<pre style="margin:0px;">var arr = generator.GetSpaceObjectsTypes();</pre> |
Useful during generation process. The same as generator.GetDebrisTypes.
}}
 
{{Scripting_api|GetIntersection|
* int: system_id
* double: coord_x
* double: coord_y |
string: intersection in format "coord_x;coord_y" or empty string|
<pre style="margin:0px;">var intersection = generator.GetIntersection(0, 15, 15);
if(intersection.length > 0)
{
var arr = intersection.split(';');
console.Print("Intersection was found: point X:" + arr[0] +", Y:" + arr[1]);
}</pre> |
The function answers the question: if a put a link between system with specified id and point with
coordinates coord_x;coord_y, will it intersect any other links? Useful during galaxy generation process.
}}
 
 
{{Scripting_api|GetJumpsBetweenSystems|
* int: system_id
* int: system_2_id|
int: number of jumps|
<pre style="margin:0px;">var jumps = generator.GetJumpsBetweenSystems(1,1000);</pre> |
Returns length (number of links) of the minimal way between two systems.
}}
 
{{Scripting_api|GetLinkedSystems|
* int: sys_id|
array: IDs of systems|
<pre style="margin:0px;">var arr = generator.GetLinkedSystems(1);</pre> |
Returns an array with IDs of all systems linked to the specified one.
}}
 
{{Scripting_api|GetMinDistanceToSystem|
* double: coord_x
* double: coord_y|
double:: distance to the closest system (or maximum double value if none)|
<pre style="margin:0px;">var dist = generator.GetLinkedSystems(1);</pre> |
Return distance to the closest system to a specified point.
}}
}}

Revision as of 07:55, 13 February 2014


Scope generator

Used for generation items, objects, systems in game, and also for getting some specific info about them.

Visibility: Global.

List of functions

AddAsteroid
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: type - xml id of asteroid
  • double: scale
  • double: resQ - resouces modifier
  • object: rotation
  • object: rotationSpeed

int: identifier of created object

var id = generator.AddAsteroid(1,100,100,"Asteroid01",1, 0, {x:0,y:0,z:0}, {x:0,y:0,z:0});
Description

Adds asteroid with specified parameters into game world. Asteroid contents (extractable resources), asteroid's look and other parameters can be modified only in .xml file, which is specified in this function by parameter "type".


AddBase
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: type - xml id of base
  • string: name
  • (optional) object: tags

int: identifier of created object

var id = generator.AddBase(1, 100, 100, "Base01", "Station Horizon", {class: "order"});
Description

Adds space station to game world.


AddItem
Arguments Returns Example
  • int: object_id
  • string: item_xml_id
  • int: quantity

object:

  • quantity - quantity was actually added
  • type - can be "item" or "resource"
var obj = generator.AddItem(1, "SomeItem", 5);
Description

Adds item to some object's inventory. In VoidExpanse not all objects do have inventory, so this function must be applied only to those, which have it, such as ships, space stations, containers.


AddContainer
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: xml_type
  • string: droplist
  • (optional) object: tags

int: identifier of object created

var id = generator.AddContainer(1, 0, 0, "Container01", "DropList01");
Description

Adds a floating container to game world. By default container is empty. Also containers, which has no contents, are unstable (self-destroyed as soon as someone will look at it's contents), so it's better not to create empty containers. Content can be added with generator.AddItem function.


AddDecoration
Arguments Returns Example
  • int: system_id
  • string: item_xml_id
  • vector2: position
  • double: depth
  • vector2: rotation
  • vector2: rotation_speed,
  • double: scale

int: ID of created object

var id = generator.AddDecoration(1, "Decoration01", {x:0,y:0}, 100, {x:5, y:5}, {x:5, y:5}, 2);
Description

Adds a decoration to game world. Decoration is a non-interactive object, which is used as a... decoration.


AddJumpgate
Arguments Returns Example
  • int: system_id
  • int: system_to
  • double: coord_x
  • double: coord_y
  • double: angle
  • string: xml_type
  • (optional) object: tags

int: ID of created object

var id = generator.AddJumpgate(1, 2, 100, 100, 20, "Jumpgate01", {sometag: "sometag"});
Description

Adds a jumpgate - an object, which allows ships to travel between systems. Every jumpgate must be paired with another one, for example, if in system A theres a jumpgate, that leads to system B, then in system B must be a jumpgate, that leads to system A.


AddNPCShipToSystem
Arguments Returns Example
  • string: npc_name
  • string: behavior - AI-script ("brains")
  • int: level
  • string: xml_type - npc xml type
  • int: system_id
  • double: coord_x
  • double: coord_y
  • (optional) object: tags

int: ID of created object

var id = generator.AddNPCShipToSystem("Pirate",
	"PirateAI", 100, "PirateNpc01",
	1, 105, 223, 
	{class: "pirate", uniq_id: "boss"});
Description

Adds an npc ship into game. NPC's avatar and faction are set through another functions - generator.SetNPCAvatar and relations.SetShipFaction


OverrideDropList
Arguments Returns Example
  • int: ship_id
  • array: droplists - strings array of droplists

void

generator.OverrideDropList(23303, ["DropList01", "DropList02"]);
Description

Adds specified droplists to npc's droplists list.


AddPlanet
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: name
  • int: seed

int: ID of created object

var id = generator.AddPlanet(1, 0, 0, "Earth", 123);
Description

Adds planet to game world. Planet's look is driven by seed, based on which planet's look will be defined by random generator. If you want a particular planet, you should either use seed with defined results (by our tool - SeedGenerator), or use another function - AddPlanetWithType.


AddPlanetWithType
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: name
  • int: seed
  • string: planet_config_type

int: ID of created object

var id = generator.AddPlanetWithType(1, 0, 0, "Earth", 123, "EarthTypePlanet");
Description

Adds planet to game world. Planet's look is driven partially be seed, but mostly by the specified type.


AddSpaceObject
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: xml_type_id
  • object: tags

int: ID of created object

var id = generator.AddSpaceObject(1, 0, 0, "Debris01", {class: "mine"})
Description

Adds a space object to game world. Space objects are interactive object. They cannot be destroyed, but they are interactive and collision-enabled. For example, spacemines are created with space objects.


AddSpaceObject
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: xml_type_id
  • object: tags

int: ID of created object

var id = generator.AddSpaceObject(1, 0, 0, "Debris01", {class: "mine"})
Description

Adds a space object to game world. Space objects are interactive object. They cannot be destroyed, but they are interactive and collision-enabled. For example, spacemines are created with space objects. NOTE: As xml_type_id you can use keyword "random" - then a random space object will spawn.


AddStar
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • int: seed
  • int: heat - how much damage star deals, when ship approaches
  • (optional) string: typeID

int: ID of created object

var id = generator.AddStar(1, 0, 0, 234, 0)
Description

Adds a star. Conventionally, you shouldn't add more then 1 star to a system. If typeID is not specified, type will be picked by random, based on seed parameter.


AddSystem
Arguments Returns Example
  • double: coord_x
  • double: coord_y
  • string: name
  • int: seed

int: ID of created system

var id = generator.AddSystem(0, 0, "Hawkins Eta", 123)
Description

Adds a star system. Star system can be added anywhere, and by default it won't be connected to any other systems. See tutorial to see, how systems generation works.


SetSystemTags
Arguments Returns Example
  • int: system_id
  • object: tags

void

generator.SetSystemTags(1, {"show_clouds": "yes"})
Description

Sets tags of specified star system. Can be expanded with generator.AddSystemTag and retrieved by generator.GetSystemTags.


AddSystemTag
Arguments Returns Example
  • int: system_id
  • string: name
  • object: value

void

generator.AddSystemTag(1, "show_clouds", "yes")
Description

Adds tag to star system tags (or overwrites existing one with the same name).


GetSystemTags
Arguments Returns Example
  • int: system_id

object: tags set by methods above

var tags = generator.GetSystemTags(1);
if(tags != null && tags["show_clouds"] == "yes")
{
	console.Print("System 1 was told to show clouds");
}
Description

Retrieves tags of star system, which were set by SetSystemTags and AddSystemTag.


AddAnomaly
Arguments Returns Example
  • int: system_id
  • string: anomaly_id
  • object: args

void

generator.AddAnomaly(args.sys_id, "radar_disable", {});
Description

Adds anomaly to star system. There are few predefined anomalies (see more in the article Anomalies), but you can specify and implement your own anomalies.


SystemClose
Arguments Returns Example
  • int: system_id

void

generator.SystemClose(20);
Description

Sets system status to closed. Can be used anywhere, has no hardcoded implementation. For example, now it's being used to prevent player to travel to alien systems. System can be opened with generator.SystemOpen. All systems are opened by default.


SystemOpen
Arguments Returns Example
  • int: system_id

void

generator.SystemOpen(20);
Description

Sets system status to opened. Can be used anywhere, has no hardcoded implementation. For example, now it's being used to prevent player to travel to alien systems. System can be closed with generator.SystemClose. All systems are opened by default.


IsSystemClosed
Arguments Returns Example
  • int: system_id

bool

var closed = generator.IsSystemClosed(20);
Description

Check whether system is closed or not.


SetSystemPlaylists
Arguments Returns Example
  • int: system_id
  • object: key->value object

void

generator.SetSystemPlaylists(args.sys_id,
				{
					"explore": "playlist_generic_explore",
					"combat": "playlist_generic_combat"
				}
			);
Description

Sets system music playlists. There are few possible keys, see more in VoidExpanse/MusicPlaylists.


SetSystemPlaylists
Arguments Returns Example
  • int: system_id
  • object: key->value object

void

generator.SetSystemPlaylists(args.sys_id,
				{
					"explore": "playlist_generic_explore",
					"combat": "playlist_generic_combat"
				}
			);
Description

Sets system music playlists. There are few possible keys, see more on playlists in VoidExpanse/MusicPlaylists.


AddSystemsLink
Arguments Returns Example
  • int: system_id
  • int: system_2_id

void

generator.AddSystemsLink(1,2);
Description

This function creates a link between two systems. This links are simply logical, but there are few hardcoded rules about them. There are some specific rules, that are applied to every link:

  • Duplication - cannot create a link between already linked systems
  • Future Linking - cannot create a link between systems, that aren't exist yet
  • Proximity - link cannot pass closer then 2 units to a star
  • Intersections - link cannot intersect any other link

Links created this way are displayed on galaxy map. By this links jumpgates are created (though, there is no hard rule about that - you can create jumpgate without link between two star systems, but this connection won't be displayed on galaxy map).


FixConnectivity
Arguments Returns Example

void

void

generator.FixConnectivity();
Description

Should be called after all stars and links were created. It checks, if all stars are reachable from one another, and, if not, it creates missing star systems links.


DockShipToBase
Arguments Returns Example
  • int: ship_id
  • int: base_id

void

generator.DockShipToBase(12253,2);
Description

Immediately, without any animations, checkups and routines, docks ship to a space station. It's better not to use it on players, because it'll have unpredictable behavior.


ExpandArea
Arguments Returns Example
  • array: array of stars IDs

void

var stars = [3];
while(true)
{
	stars = generator.ExpandArea(stars);
	if(newstars.length >= 10) break;
}
console.Print("Now we have an area of 10 or more stars around star with id 3");
Description

Function, which returns the same array, as input + all stars, which are linked to input ones by 1 link. In other words, it returns an area, expanded by 1 link. Very useful during generation of zones in galaxy, such as faction territories.


GetAllSystems
Arguments Returns Example

void

array: IDs of all systems

var arr = generator.GetAllSystems();
Description


GetAsteroidTypes
Arguments Returns Example

void

array: xml_ids (strings) of all asteroids

var arr = generator.GetAsteroidTypes();
Description


GetClosestSystemToPoint
Arguments Returns Example
  • double: coord_x
  • double: coord_y

int: ID of picked system of 0, if none

var sys_id = generator.GetClosestSystemToPoint(0,0);
Description

Useful during generation process.


GetDebrisTypes
Arguments Returns Example

void

array: xml_ids (strings) of all space objects

var arr = generator.GetDebrisTypes();
Description

Useful during generation process. Alias of generator.GetSpaceObjectsTypes.


GetSpaceObjectsTypes
Arguments Returns Example

void

array: xml_ids (strings) of all space objects

var arr = generator.GetSpaceObjectsTypes();
Description

Useful during generation process. The same as generator.GetDebrisTypes.


GetIntersection
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y

string: intersection in format "coord_x;coord_y" or empty string

var intersection = generator.GetIntersection(0, 15, 15);
if(intersection.length > 0)
{
	var arr = intersection.split(';');
	console.Print("Intersection was found: point X:" + arr[0] +", Y:" + arr[1]);
}
Description

The function answers the question: if a put a link between system with specified id and point with coordinates coord_x;coord_y, will it intersect any other links? Useful during galaxy generation process.


GetJumpsBetweenSystems
Arguments Returns Example
  • int: system_id
  • int: system_2_id

int: number of jumps

var jumps = generator.GetJumpsBetweenSystems(1,1000);
Description

Returns length (number of links) of the minimal way between two systems.


GetLinkedSystems
Arguments Returns Example
  • int: sys_id

array: IDs of systems

var arr = generator.GetLinkedSystems(1);
Description

Returns an array with IDs of all systems linked to the specified one.


GetMinDistanceToSystem
Arguments Returns Example
  • double: coord_x
  • double: coord_y

double:: distance to the closest system (or maximum double value if none)

var dist = generator.GetLinkedSystems(1);
Description

Return distance to the closest system to a specified point.