Scripting API
A map script is a Go program that imports these packages (module w4). The game runs main once before the map starts; what you register there runs at the right step. The reference is generated from the SDK's own doc comments, so it is always what the shipped editor has.
import (
"w4/campaign"
"w4/event"
"w4/game"
"w4/maporder"
"w4/player"
"w4/ui"
)Packages
- package campaign: is the memory a campaign carries from one map to the next: flags, whole numbers and real numbers that the next mission can read, kept under named scopes.
- package event: is where a map script says what should happen when: register a function for an event and the game calls it at the right step.
- package game: is what a map script can see and do in the game.
- package maporder: gives the order a map is walked in, the same on every machine and in every run.
- package player: names the players of a map: the twelve colours, the two neutral owners and "everyone".
- package ui: is a map's own interface on the players' screens: a few plain elements (text, a button, a panel that holds others) placed from a corner or the centre of the screen, in the same 1080-pixel units as the rest of the interface, drawn in its style.
Start with the scripting guide if you have not written a map script yet; the tutorials build a few.
In this section
package event Package event is where a map script says what should happen when: register a function for an event and the game calls it at the right step.package game Package game is what a map script can see and do in the game.package maporder Package maporder gives the order a map is walked in, the same on every machine and in every run.package player Package player names the players of a map: the twelve colours, the two neutral owners and "everyone".package ui Package ui is a map's own interface on the players' screens: a few plain elements (text, a button, a panel that holds others) placed from a corner or the centre of the screen, in the same 1080-pixel units as the rest of the interface, drawn in its style.package campaign Package campaign is the memory a campaign carries from one map to the next: flags, whole numbers and real numbers that the next mission can read, kept under named scopes.