VoidExpanse/scope-generator: Difference between revisions
No edit summary |
No edit summary |
||
Line 291: | Line 291: | ||
<pre style="margin:0px;">var numOfPirates= generator.CountNpcInSystemByTags(20, {class: "pirate"});</pre> | | <pre style="margin:0px;">var numOfPirates= generator.CountNpcInSystemByTags(20, {class: "pirate"});</pre> | | ||
Counts npcs with specified tags in specified system. | Counts npcs with specified tags in specified system. | ||
}} | |||
{{Scripting_api|ClearDropList| | |||
* int: ship_id| | |||
void| | |||
<pre style="margin:0px;">generator.ClearDropList(20025);</pre> | | |||
Clears droplist of a specified NPC. | |||
}} | }} | ||
Revision as of 09:04, 10 April 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: 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: 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 |
|
object:
|
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. |
AddItemToSpecifiedContainer | ||
---|---|---|
Arguments | Returns | Example |
|
object:
|
var obj = generator.AddItemToSpecifiedContainer(1525, "SomeItem", 5); |
Description | ||
Important notice: container_id - is a special, unique in-game identifier for containers, which cannot be obtained by any way through API. Container id can only be obtained as a function parameter in events. Currently used in OnInstancedContainerGeneration event. |
GenerateItemsWithItemlist | ||
---|---|---|
Arguments | Returns | Example |
|
array of objects:
|
var items = generator.GenerateItemsWithItemlist(1, "SomeItem", 5); for(var i = 0; i < items.length; i++) { generator.AddItemToSpecifiedContainer( args.container_id, items[i].id, items[i].quantity ); } |
Description | ||
Generates set of items with itemlist. After generation, items can be added to any container. |
AddContainer | ||
---|---|---|
Arguments | Returns | Example |
|
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: 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: 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 |
|
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 |
|
void |
generator.OverrideDropList(23303, ["DropList01", "DropList02"]); |
Description | ||
Adds specified droplists to npc's droplists list. |
AddPlanet | ||
---|---|---|
Arguments | Returns | Example |
|
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: 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: 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. |
AddLever | ||
---|---|---|
Arguments | Returns | Example |
|
int: ID of created object |
var id = generator.AddLever(1, 0, 0, "Debris01", 0, {class: "mine"}) |
Description | ||
Adds a lever object to world. Lever - is a special object, which can be activated. Parameter "visible_to" specifies, to whom lever is visible. If 0, it's visible to all, else - only to specified ship. Useful when you need to create a special object only to a man, who took the quest. |
AddStar | ||
---|---|---|
Arguments | Returns | Example |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
bool |
var closed = generator.IsSystemClosed(20); |
Description | ||
Check whether system is closed or not. |
CountNpcInSystemByTags | ||
---|---|---|
Arguments | Returns | Example |
|
int |
var numOfPirates= generator.CountNpcInSystemByTags(20, {class: "pirate"}); |
Description | ||
Counts npcs with specified tags in specified system. |
ClearDropList | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.ClearDropList(20025); |
Description | ||
Clears droplist of a specified NPC. |
SetSystemPlaylists | ||
---|---|---|
Arguments | Returns | Example |
|
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 MusicPlaylists. |
AddSystemsLink | ||
---|---|---|
Arguments | Returns | Example |
|
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:
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 |
|
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 |
|
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 |
|
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 |
|
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: 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 |
|
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: 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. |
GetNumberOfLinks | ||
---|---|---|
Arguments | Returns | Example |
|
int: number of links to specified system |
var links = generator.GetNumberOfLinks(1); |
Description | ||
GetPlanetCoordinates | ||
---|---|---|
Arguments | Returns | Example |
|
vector2: coordinates of a planet |
var coords = generator.GetPlanetCoordinates(242); console.Print("Planet coordinates: X:" + coords.x + ", Y:" + coords.y); |
Description | ||
Returns coordinates of specified planet. |
GetRandomPlanetInSystem | ||
---|---|---|
Arguments | Returns | Example |
|
int: ID of a planet |
var id = generator.GetRandomPlanetInSystem(1); |
Description | ||
Returns ID of random planet in system (or 0 if there are no planets). |
GetSystemPlanets | ||
---|---|---|
Arguments | Returns | Example |
|
array: IDs of planets |
var arr = generator.GetSystemPlanets(1); |
Description | ||
Returns an array with IDs of all planets in system. |
GetSystemByID | ||
---|---|---|
Arguments | Returns | Example |
|
object:
|
var obj = generator.GetSystemByID(1); |
Description | ||
Returns basic info about specified system. Tags of star system can be gained with generator.GetSystemTags. |
GetBaseByID | ||
---|---|---|
Arguments | Returns | Example |
|
object:
|
var obj = generator.GetBaseByID(1); |
Description | ||
Returns space station basic description. Tags cannot be retrieved with this function - use game.GetTags instead. |
GetSystemsByDistanceTo | ||
---|---|---|
Arguments | Returns | Example |
|
array: IDs of systems |
var arr = generator.GetSystemsByDistanceTo(1); |
Description | ||
Returns an array with IDs of systems, which are sorted by distance to specified system. Specified system is included into resulting array. |
GetAllResources | ||
---|---|---|
Arguments | Returns | Example |
void |
array: xml_ids (strings) of resources |
var arr = generator.GetAllResources(); |
Description | ||
Returns an array of all resources of VoidExpanse. |
GetResourceByID | ||
---|---|---|
Arguments | Returns | Example |
|
object:
|
var obj = generator.GetResourceByID("Resource01"); |
Description | ||
Returns a description of a resource by it's xml_id. |
GetItemByXmlID | ||
---|---|---|
Arguments | Returns | Example |
|
object:
|
var obj = generator.GetItemByXmlID("Item01"); |
Description | ||
Returns a description of an item by it's xml_id. |
RemoveAsteroid | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemoveAsteroid(123); |
Description | ||
Removes asteroid from a game world. |
RemoveBase | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemoveBase(123); |
Description | ||
Removes base (space station) from a game world. |
RemoveDecoration | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemoveDecoration(123); |
Description | ||
Removes decoration from a game world. |
RemoveJumpgate | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemoveJumpgate(123); |
Description | ||
Removes a jumpgate from a game world. |
RemovePlanet | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemovePlanet(123); |
Description | ||
Removes a planet from a game world. |
RemoveSpaceObject | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemoveSpaceObject(123); |
Description | ||
Removes a space object from a game world. |
RemoveLever | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemoveLever(123); |
Description | ||
Removes specified lever from a game world. |
RemoveStar | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemoveStar(123); |
Description | ||
Removes a star from a game world. |
RemoveSystemsLink | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.RemoveSystemsLink(1,2); |
Description | ||
Removes a link between two systems. |
ReportLoadingPhase | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.ReportLoadingPhase("Loading galaxy"); |
Description | ||
Adds message to singleplayer client with loader (then to alter loader use generator.ReportLoadingProgress). |
ReportLoadingPhaseNoLoader | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.ReportLoadingPhaseNoLoader("Loading galaxy"); |
Description | ||
Adds message to singleplayer client. |
ReportLoadingProgress | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.ReportLoadingProgress(0.5); |
Description | ||
Adds message to singleplayer client. |
SetNPCAvatar | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.SetNPCAvatar(12553, [1,2,3,4,5,6]); |
Description | ||
Sets npc avatar. |
SetSystemDangerLevel | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.SetSystemDangerLevel(1, 99); |
Description | ||
Set star system danger level. Danger level usually affects a level of system's npc and many other parameters. |
SetSystemTechLevel | ||
---|---|---|
Arguments | Returns | Example |
|
void |
generator.SetSystemTechLevel(1, 99); |
Description | ||
Set star system tech level. Tech level usually affects shops store items. |
ShipExists | ||
---|---|---|
Arguments | Returns | Example |
|
bool: whether ship exists or not |
generator.ShipExists(12552); |
Description | ||