DocsMegalithMode files

The mode header

A block comment from a line --[=[ mode to ]=] holds the mode's settings as TOML. It can stand anywhere in the file; the bundled modes put it at the top, under a comment that says what the mode is. A source without a header plays as Slayer, with no points per kill and no score limit, named after its file.

zone-control.rmeg's header
--[=[ mode
name = "Zone Control"

[rules]
score_to_win = 30
kill_points = 0
death_points = 0
suicide_points = 0
betrayal_points = 0

[options]
"rounds.teams" = 0
"rounds.limit" = 1
"rounds.minutes" = 10

[logic.options]
points_per_second = { value = 1, min = 1, max = 10 }

[logic.objects.hill]
source = { kind = "zone" }
label = "objective"
shape = { kind = "sphere", radius = 8.0 }

[[logic.megalo_traits]]
aura = 4
speed = 7
]=]

A setting the game doesn't know, or a value out of range, keeps the mode out of the game type list; mode-check and the log say why. Option names have dots, so TOML needs them in quotes.

name
The name the picker and lobby show, 1 to 48 characters. Without one, the file's name.
mode
The game type it plays. Slayer without one.
author
Who made it, up to 32 characters. The loading screen shows it.
[rules]
Slayer's scoring: score_to_win (−1 to 500), kill_points, death_points, suicide_points and betrayal_points (−10 to 10). Other game types score through mode. options.
[options]
Game options by name, as Game Options saves them.
[world]
sprint ("off", "unlimited" or "stamina"), sprint_speed_percent, sprint_stamina_seconds, exposure (0.1 to 4) and atmospheric_fog (true or false). player_scale_percent isn't allowed: a script controls player size itself.
[base_map]
The map the mode plays when nobody picks one, such as a server's variant, by id, stem and title: id = 380, stem = "riverworld", title = "Valhalla". In a lobby the host picks the map.
[logic.options]
Settings hosts can change, each { value, min, max }. See options, traits and zones.
[logic.objects.NAME]
Zones and objects the mode declares. See below.
[[logic.megalo_traits]]
Trait sets, script_traits[0] and on, up to 16. See trait values.
[logic.deployment]
Classes. See classes and class pickers.
logic.hud_layout
How the script's first four widgets are laid out when they have no position: "objective_rows", the default, or "team_tickets": widget 0 blue, widget 1 red, then widgets 2 and 3 as centered status lines.
logic.scripted_round_end
true: the game type's score, time and objective limits no longer end a round. The script ends it, with game.end_round() or team.end_round().
logic.seed
Where rand starts, a whole number from 0 up. The same seed gives the same numbers: call rand while players wait, as Flood Infection does, to vary them.
logic.fine_units
true: positions, speeds and facings count in thousandths. See fine units.

Write [logic] as a table of its own for the last four, as Conquest does:

Part of a header
[logic]
scripted_round_end = true
hud_layout = "team_tickets"
seed = 7

Game options by name

[options] takes every setting of Game Options. The quickest way to find one: change it in Game Options, choose Save as Variant and read the options of the .json file it saves. These are the names, with their values:

rounds.teams, rounds.reset_players, rounds.reset_map, rounds.friendly_fire, rounds.betrayal_booting
0 off, 1 on. Capture the Flag, Assault, Territories and VIP always play in teams; Infection and Juggernaut never do.
rounds.limit
1 to 10 rounds.
rounds.minutes
0 (unlimited) to 60.
rounds.early_victory
Wins for an early victory, 0 (off) to 5.
rounds.team_changing
0 disabled, 1 enabled, 2 balancing only.
respawn.lives, respawn.team_lives
0 (unlimited) to 50; to 100.
respawn.seconds, respawn.suicide, respawn.betrayal
0 to 240 seconds.
respawn.growth, respawn.traits_duration
0 to 15; 0 to 60 seconds.
respawn.synchronize, respawn.on_kills
0 off, 1 on.
map.weapons
0 default, 1 assault rifles, 2 dual wield, 3 hammers, 4 lasers, 5 rockets, 6 shotguns, 7 sniper rifles, 8 swords, 9 no power weapons, 10 no snipers, 11 no weapons, 12 random, 13 ODST weapons.
map.vehicles
0 default, 1 none, 2 Mongooses, 3 light ground, 4 tanks, 5 aircraft, 6 no light ground, 7 no tanks, 8 no aircraft, 9 all.
map.grenades, map.indestructible_vehicles
0 or 1.
powerups.red_duration, powerups.blue_duration, powerups.yellow_duration
0 to 120 seconds.
player.… and the other trait sets below
The trait names, with grenades (1 the map's, 2 none), forced_color (0 to 12), camera (1 third person, 2 first person), primary_weapon and secondary_weapon.
mode.…
The game type's own options, below.

Trait sets: player, respawn_traits, red_powerup, blue_powerup and yellow_powerup in every game type, then Slayer's leader, Capture the Flag's flag_carrier, Oddball's ball_carrier, King of the Hill's hill_occupant, Infection's infected, initial_infected, safe_haven and last_survivor, VIP's vip_team, vip_proximity and vip, Juggernaut's juggernaut, Territories' defender and attacker, and Assault's bomb_carrier and bomb_arming.

Starting weapons: −3 random, −2 unchanged, −1 the map's, 0 Battle Rifle, 1 Assault Rifle, 2 Plasma Pistol, 3 Spiker, 4 SMG, 5 Carbine, 6 Energy Sword, 7 Magnum, 8 Needler, 9 Plasma Rifle, 10 Rocket Launcher, 11 Shotgun, 12 Sniper Rifle, 13 Brute Shot, 14 unarmed, 15 Beam Rifle, 16 Spartan Laser, 17 no weapon, 18 Gravity Hammer, 19 Mauler, 20 Flamethrower, 21 Missile Pod, 22 Sentinel Beam, 23 Fuel Rod Gun, 24 Silenced SMG, 25 Automag, 26 Brute Plasma Rifle, 27 Machine Gun Turret, 28 Plasma Turret, 29 Golf Club.

Game typemode. options
Slayerscore, kill, assist, death, suicide, betrayal, leader_kill, elimination, assassination, headshot, beatdown, sticky, splatter, spree, team_scoring
Capture the Flagscore, reset, sudden_death, touch_return, flag_at_home, flag_waypoint, flag_type, objective_respawn
Oddballscore, carrying, kill, ball_kill, carrier_kill, ball_count, spawn_delay, reset, auto_pickup, ball_effect, team_scoring
King of the Hillscore, uncontested, kill, inside, outside, opaque_hill, team_scoring, hill_movement, hill_order
VIPscore, kill, takedown, vip_kill, vip_death, arrival, suicide, betrayal, vip_suicide, radius, single_vip, destinations, end_on_vip_death, vip_selection, destination_movement, destination_order
Juggernautscore, kill, takedown, juggernaut_kill, arrival, suicide, betrayal, juggernaut_delay, allied_against_juggernaut, respawn_on_lone_juggernaut, destinations, initial_juggernaut, next_juggernaut, destination_movement, destination_order
Territoriescapture, sudden_death, one_sided, lock_on_capture, objective_respawn
Assaultscore, sudden_death, reset, arming, disarming, fuse, reset_on_disarm, objective_respawn, bomb_type, bomb_waypoint
Infectioninitial_count, haven_seconds, kill, infection, arrival, suicide, betrayal, last_survivor, respawn_on_haven_move, safe_havens, next_infected

Declared objects and zones

[logic.objects.NAME] declares up to 64 things by name, in letters, digits and underscores. A zone is there from the start of the round; the others are types that place_at_me takes by name.

{ kind = "zone" }
An invisible area with a shape. Players can't see it or bump into it; shape_contains tests it, and set_position moves it.
{ kind = "weapon", weapon = "rocket_launcher" }
A weapon.
{ kind = "biped", biped = "marine" }
A body.
{ kind = "stock", object = "warthog" }
Equipment, a mounted gun or a vehicle.
{ kind = "tag", path = "objects/vehicles/mongoose/mongoose" }
A tag path.
{ kind = "placement", index = 42 }
An object of the saved map, by its place in it, 0 to 639. It works on that map only.

An object can also have a label for for each object with label, up to 32 bytes, and a position = [x, y, z], in Forge units, within 100,000. A shape is { kind = "sphere", radius = 8 }, { kind = "box", half_extents = [4, 4, 2] } or { kind = "cylinder", radius = 8, half_height = 3 }, each size above 0 and at most 10,000 Forge units. A declared shape lines up with the map's axes, and its edge counts as inside. Forge objects' own zones are turned with the object.