Documentation and TutorialMain Code PartsOptions

Options

Definition

Stored in this.options is a data structure where you can set options for your custom modded game. These options are used for initializing the game when you start your mod. Changing them while the mod is running does not affect the game.

Custom ships and custom tree

You can import ships made within the Starblast Ship Editor. Use “Mod Export” feature to export a JavaScript code snippet for the modding interface. Then paste this snipped in the coding window and add this:

var myship_101 = "{ … … <this is your exported ship code> …";
 
var ships = [myship_101]; // add your ship to an array of ship
 
this.options = {
  root_mode: "survival",
  ships: ships,         // specifying a list of ships to complement / replace existing ships
  reset_tree: true,     // set to true if you want to remove the original ship tree, false if you just want to replace some of the ships
  map_size: 30
};
 
this.tick = function(game) {
};

Then run your mod. If your ship is set to level=1 model=1, your ship will replace the Fly. You can replace other ships in the tree in a similar way, using reset_tree: false. Or you can remove the original ship tree completely and provide a whole new one using reset_tree: true.

Customizing the emote-chat system

The vocabulary used for the emote-chat system can be customized by setting the field vocabulary in the game option as follows:

var vocabulary = [
  { text: "Hello", icon: "\u0045", key: "O" },
  { text: "Bye", icon: "\u0046", key: "B" },
  { text: "Yes", icon: "\u004c", key: "Y" },
  { text: "No", icon: "\u004d", key: "N" },
 
  { text: "Flower", icon: "\u{1F33B}", key: "F" },
  { text: "Snowman", icon: "\u26c4", key: "M" },
  { text: "Shark", icon: "\u{1F988}", key: "S" },
  { text: "Ghost", icon: "\u{1F47B}", key: "G" }
];
 
this.options = {
  vocabulary: vocabulary,
  // ...
};

This allows using Starblast built-in emote icons, which are listed here for reference: https://starblast.io/glyphs.html

You can also use unicode icons, here is a good source for reference: https://unicode.org/emoji/charts/full-emoji-list.html

Note that wide unicode characters (using more than 2 bytes) requires a specific Javascript syntax as shown in the example above (example: \u{1F47B})

Custom asteroids maps

You can create a custom map of asteroids. This allows creating a maze for example. The custom map you provide is actually a JavaScript character string that is used to “paint” the map.

For example:

var map =
"999999999999999999999999999999\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"99                          99\n"+
"999999999999999999999999999999" ;
 
 
this.options = {
  custom_map: map,
  map_size: 30
}

In the example above, 9 sets the biggest size of the asteroid. You can use smaller values for adding smaller asteroids to the grid. Any value other than a digit will be interpreted as no asteroid. If your map_size is set to 30, make sure to create 30 lines and 30 columns, or you may get unpredictable results.

Note: Use "" for blank custom map

You can use Online Map Editor (a community tool) to create, edit and export maps.

Other common options

Most of the options are inherited from the usual custom games. A few more options have been added, specifically for modding (top of the list):

OptionExpected data typeDescriptionDefault value (if omitted)
root_modestringThe mode to inherit from: “survival”, “team”, “invasion”, “deathmatch”, “battleroyale” or unspecified (other values)unspecified
reset_treebooleanSet to true to remove the original ship treefalse
shipsarray<string>An array of ships to add to the treeNone
map_sizeintegerSize of the map, range from 20 to 200, even value only100 (survival), 80 (team and Battle Royale), 60 (unspecified), 30 (Invasion), 20 (deathmatch)
soundtrackstring”procedurality.mp3”, “argon.mp3”, “crystals.mp3”, “red_mist.mp3”, “civilisation.mp3”, “warp_drive.mp3” or none (other values)“crystals.mp3” (invasion and Battle Royale), “argon.mp3” (deathmatch), “procedurality.mp3” (others)
max_playersintegerPlayers limit of the game, from 1 to 24070 (team), 60 (survival), 40 (unspecified), 30 (Battle Royale), 20 (deathmatch), 6 (invasion)
crystal_valuefloatCrystal multiplier applied to crystals dropping from destroyed asteroids, from 0 to 102 (team), 0 (deathmatch and Battle Royale), 1 (others)
livesintegerNumber of lives, from 1 to 54 (team), 1 (deathmatch and Battle Royale), 3 (others)
maxtierlivesintegerNumber of lives (from 1 to 5) when player reaches ships with the highest level (defined in max_level option)0 (team and deathmatch), 1 (Battle Royale), 3 (others)
max_levelintegerMax level you can reach, from 1 to 77
friendly_colorsintegerServes to define teams; how many teams (or 0, maximum 5)3 (team), 1 (invasion), 0 (others)
map_namestringName of the mapAuto-generated name
survival_levelintegerLevel which triggers survival mode (8 for no trigger, 2 minimum)7 (survival), 8 (others)
starting_shipintegerEnter desired ship code: 101, 201, 404, etc.101
starting_ship_maxedbooleanStarting ship is maxedfalse
asteroids_strengthfloatThe strength of the asteroids compared to their normal states, 0 to 10000005 (deathmatch), 0.5 (Battle Royale), 1 (others)
friction_ratiofloatFriction ratio of the game (0 to 2)1
strafefloatStrafing speed factor, from 0 to 10
speed_modfloatSpeed of the mod, from 0 to 21.25 (deathmatch), 1.2 (survival and team), 1 (others)
rcs_togglebooleanEnable RCS feature for shipstrue
map_idintegerSeed (ID) of the auto-generated map, from 0 to 9999Game ID
map_densityfloatDensity of the map, from 0 to 2None
weapon_dropfloatProbability that an asteroid will drop a weapon, from 0 to 100
crystal_dropfloatPercentage of gems that can be collected when a ship drains gems, from 0 to 10.5 (deathmatch), 1 (others)
release_crystalbooleanAllow [V] to release gemstrue (team), false (others)
mines_self_destroybooleanMines will self-destruct after a whiletrue
mines_destroy_delayintegerAll landed mines will be destroyed after this interval if no enemies trigger them (in ticks). Minimum 0, no actual maximum limit3600 (Battle Royale), 18000 (others)
healing_enabledbooleanEnable healing featuretrue (team), false (others)
healing_ratiofloatHealing ratio to actual laser damage, from 0 to 20.5 (team), 1 (others)
shield_regen_factorfloatShield regeneration multiplier to natural regeneration of ships. Minimum 0, no actual maximum limit1
power_regen_factorfloatPower (Energy) regeneration multiplier to natural regeneration of ships. Minimum 0, no actual maximum limit1
invulnerable_shipsbooleanShips are invulnerablefalse
weapons_storebooleanAllow access to the weapon storetrue
radar_zoomfloatRadar zoom ratio. Set value to 1, 2, or 4 (recommended values are powers of 2)2
auto_refillbooleanCollecting an energy or shield pill immediately refills energy or shield. Otherwise, the collected pill is added to the active weaponsfalse
projectile_speedfloatAffects the speed of rockets, missiles, and torpedoes. Use 1 for default speed. Minimum 0, no actual maximum limit1
choose_shiparray<integer>e.g., setting to [301,302,303] will let player choose a ship from these 3 ships before entering the gameNone
colliderbooleanEnable collisions of player ships with anythingtrue

Survival mode specific options

OptionExpected data typeDescriptionDefault value (if omitted)
survival_timefloatWhen to trigger survival mode (in minutes): 0 to disable survival time trigger from 1 to 600 to set the survival trigger time60
bouncing_lasersfloatMust be a value between 0 (no bounce) or 1 (bounce retains 100% of the laser damage) Note: This feature is planned to be applied to all root modes in the future0.9

Team mode specific options

OptionExpected data typeDescriptionDefault value (if omitted)
huesarray<integer>Hue numbers for teams, with the same amount of elements as used for friendly_colorsAuto-generated hues
station_regenerationfloatFactor to apply to station shield regen, from 0 to 21
station_sizeintegerSize of the stations; integer from 1 to 52
station_crystal_capacityfloatFactor to apply to the station crystal capacity, from 0.1 to 101
station_repair_thresholdfloatPart of the station crystal capacity that must be refilled to repair a module, from 0 to 10.25
auto_assign_teamsbooleanAllow assigning players to a specific team, otherwise let them choose the team themselvesfalse
all_ships_can_dockbooleanAllow ships of Tier higher than base station normally lets in, to enter depotsfalse
all_ships_can_respawnbooleanAllow ships of Tier higher than base station normally lets in, to respawn from spawn ports, otherwise randomly on mapfalse

Deathmatch mode specific options

OptionExpected data typeDescriptionDefault value (if omitted)
ship_groupsarray<string>An array containing some arrays, each of them representing one ship group (by name) available for selection. See the example below. The longer the array is, the lower chance for each ship group being available in a single matchSee [[Deathmatch]] for a list of default ship groups. The mod won’t run if reset_tree option is set to true without manually specifying the ship groups. Please note that the ship groups will be automatically set to only U-Sniper if map_name is set to “Battle of Titans”. Please [[Easter Eggs#Battle of Titans

Example:

ship_groups: [
  ["U-Sniper","Howler"],
  ["Crusader","Pioneer"]
]