Every function, in one list
Each function with its signature, what it returns and one call, then the constants. Nothing else: the why, the pitfalls and the cost in game requests are in the guide pages, which every heading links to. Your browser search finds any name here.
Output and storage
Writes a line. Arguments are joined with a space.
Print(...)
// returns: nothing
Print("target", coord, "loot", loot) // target [P:1:64:6] loot 75Printf
Writes a formatted line, the way fmt.Printf does.
Printf(format, ...)
// returns: nothing
Printf("%d planets, %d moons", np, nm)LogDebugf
The detail that interests you alone, on a debugging day.
LogDebugf(format, ...)
// level: InfoLogInfo
The normal run: "campaign started", "twelve targets kept".
LogInfo(...)
// level: Info
LogInfo(m.SenderName, "writes:", m.Text)LogInfof
The normal run: "campaign started", "twelve targets kept".
LogInfof(format, ...)
// level: Info
LogInfof("%d targets kept out of %d", kept, seen)LogWarn
What deserves a look without being serious: a lost target, an unreadable page.
LogWarn(...)
// level: Warn
LogWarn("attack from", a.AttackerName, "on", a.DestinationName)LogWarnf
What deserves a look without being serious: a lost target, an unreadable page.
LogWarnf(format, ...)
// level: WarnLogError
What failed.
LogError(...)
// level: Error
if err != nil { LogError("reading failed:", err) }Get
Reads it back. A missing key returns the empty string, without an error.
Get(key)
// returns: 2: the value and an error
sys, err = Get("last.system") // ← TWO targets, see pitfall no. 1Has
Says whether the key exists.
Has(key)
// returns: 1: a boolean
if Has("blacklist") {
blacklist, err = Get("blacklist")
}StorageKeys
Every key stored by this script.
StorageKeys()
// returns: 1: a list
for key in StorageKeys() {
Print(key)
}PutShared
Stores a value, readable by every bot.
PutShared(key, value)
// returns: 1: an error
PutShared("fs.target", "4:120:8")GetShared
Reads it back. A missing key returns the empty string, without an error.
GetShared(key)
// returns: 2: the value and an error
target, err = GetShared("fs.target") // ← TWO targets, like GetHasShared
Says whether the key exists.
HasShared(key)
// returns: 1: a boolean
if HasShared("fs.done") {
DeleteShared("fs.done")
}SharedKeys
Every shared key.
SharedKeys()
// returns: 1: a list
for key in SharedKeys() {
Print(key)
}SendDiscord
Posts to a Discord webhook.
SendDiscord(webhook, message)
// returns: 1: an error
err = SendDiscord("https://discord.com/api/webhooks/…", "debris at " + coord)SendDiscordFile
Posts a text file as an attachment.
SendDiscordFile(webhook, name, content)
// returns: 1: an error
err = SendDiscordFile(DISCORD_WEBHOOK, "inactives.csv", rows)SendTelegram
Writes into a Telegram conversation.
SendTelegram(chatID, message)
// returns: 1: an error
SendTelegram(0, "debris at " + coord) // 0: the conversation from settingsIsPaused
Says whether the player has paused the script.
IsPaused()
// returns: 1: a boolean
if IsPaused() { SleepSec(30); continue }Shuffle
Shuffles a list in place.
Shuffle(list)
// returns: nothing
Shuffle(targets) // the order changes, the list stays the sameBytes2Str
Converts bytes to text. Anko cannot write a []byte literal, hence this function.
Bytes2Str(bytes)
// returns: 1: a stringTime and waiting
Sleep
Sleep(n)
// unit: milliseconds
Sleep(500)SleepMs
SleepMs(n)
// unit: millisecondsSleepSec
SleepSec(n)
// unit: seconds
SleepSec(30)SleepMin
SleepMin(n)
// unit: minutes
SleepMin(5)SleepDur
SleepDur(d)
// unit: a duration
SleepDur(90 * time.Second)SleepRandMs
SleepRandMs(min, max)
// unit: milliseconds
SleepRandMs(200, 800) // ✓ you wait from 200 to 800 millisecondsSleepRandSec
SleepRandSec(min, max)
// unit: seconds
SleepRandSec(20, 40)SleepRandMin
SleepRandMin(min, max)
// unit: minutes
SleepRandMin(3, 8)SleepRandHour
SleepRandHour(min, max)
// unit: hours
SleepRandHour(1, 3)SleepUntil
SleepUntil(when)
// unit: until a given time
SleepUntil("03:30:00") // the next time it is 3:30Now
The present moment.
Now()
// returns: 1: a date
if end != nil && end.Sub(Now()).Minutes() < 10 {
LogInfo("the account sleeps soon, not starting the campaign")
return
}Clock
Clock()
// returns: 3: hour, minute, second
h, m, s = Clock() // three targets, not oneDate
Date()
// returns: 3: year, month, day
y, mo, d = Date()Weekday
The day of the week, Sunday being zero.
Weekday()
// returns: 1: an integer
if Weekday() == 0 { Print("Sunday") }NowInTimeRange
Tells you whether the current time is in the range.
NowInTimeRange(start, end)
// returns: 1: a boolean
if NowInTimeRange("23:00:00", "07:00:00") {
Print("it is night") // the range crosses midnight, that is intended
}DurationBetweenTimeStrings
The gap between two clock times.
DurationBetweenTimeStrings(a, b)
// returns: 1: a durationMillisecondsBetweenTimeStrings
The same, in milliseconds.
MillisecondsBetweenTimeStrings(a, b)
// returns: 1: an integerShortDur
Writes a duration readably, 2h15m.
ShortDur(d)
// returns: 1: a string
Print(target, ShortDur(secs), "deut", fuel)GetNextDatetimeAt
The next time it is that time of day.
GetNextDatetimeAt(h, m, s)
// returns: 2: the date and an error
when, err = GetNextDatetimeAt(3, 30, 0) // returns TWO valuesParseNextDatetimeAt
The same, from "03:30:00".
ParseNextDatetimeAt(s)
// returns: 2: the date and an errorScheduling
ExecIn
Calls f once, in ms milliseconds.
ExecIn(ms, f)
// returns: 1: a cancel function
cancel = ExecIn(60000, func() { Print("one minute later") })IntervalExec
Calls f every ms milliseconds, forever.
IntervalExec(ms, f)
// returns: 1: a cancel function
IntervalExec(600000, func() { Print("every ten minutes") })CronExec
Calls f on a schedule.
CronExec(schedule, f)
// returns: 2: a number and an error
id, err = CronExec("@03h30", f)RangeCronExec
Calls f once a day, at a time drawn at random inside the window.
RangeCronExec(start, end, label, f)
// returns: 2: a number and an error
id, err = RangeCronExec("03:00:00", "03:45:00", "night return", func() {
Print("the fleet comes home")
})RemoveCron
Removes a task placed by the two above.
RemoveCron(number)
// returns: 1: a boolean
if RemoveCron(id) {
Print("unhooked")
} else {
Print("that number no longer points at anything")
}ExecInCh
Like ExecIn, but the channel closes after f.
ExecInCh(ms, f)
// returns: 1: a channel
<-ExecInCh(60000, func() { Print("one minute later") })ExecAtCh
Like ExecAt, but the channel closes after f.
ExecAtCh(when, f)
// returns: 1: a channel
<-ExecAtCh(departure, func() {
LogInfo("time to leave")
})ExecInSync
Waits, then calls f, without handing back.
ExecInSync(ms, f)
// returns: 1: a cancel functionExecAtSync
Waits for the stated time, then calls f.
ExecAtSync(when, f)
// returns: nothing
ExecAtSync("03:17:00", func() { BringTheFleetHome() })WaitAttack
Waits for an attack. The boolean says whether one came.
WaitAttack(seconds)
// returns: 2: the attack and a boolean
a, seen = WaitAttack(0)WaitAttackGone
Waits for an attack to disappear.
WaitAttackGone(seconds)
// returns: 2: the attack and a booleanWaitChatMessage
Waits for a player to write.
WaitChatMessage(seconds)
// returns: 2: the message and a boolean
m, seen = WaitChatMessage(0)WaitFleet
Waits for a worker to send a fleet.
WaitFleet(seconds)
// returns: 2: the fleet and a boolean
f, seen = WaitFleet(0)WaitHunterTargetActive
Waits for a target to come back to their screen.
WaitHunterTargetActive(seconds)
// returns: 2: the change and a boolean
e, seen = WaitHunterTargetActive(0)WaitHunterTargetIdle
Waits for a target to leave it.
WaitHunterTargetIdle(seconds)
// returns: 2: the change and a boolean
e, seen = WaitHunterTargetIdle(0)Celestials
GetUniverseName
The universe name.
GetUniverseName()
// returns: 1: a string
Printf("%s s%d-%s", GetUniverseName(), GetServerNumber(), GetLang())GetServerNumber
The server number: s152-en gives 152.
GetServerNumber()
// returns: 1: an integer
Printf("%s s%d-%s", GetUniverseName(), GetServerNumber(), GetLang())GetLang
The server language code, fr, en…
GetLang()
// returns: 1: a string
Printf("%s s%d-%s", GetUniverseName(), GetServerNumber(), GetLang())CharacterClass
The class: NO_CLASS, COLLECTOR, GENERAL or DISCOVERER.
CharacterClass()
// returns: 1: an integerIsCollector
Shortcut on the class.
IsCollector()
// returns: 1: a boolean
if IsCollector() {
Print("higher cargo capacity, faster transporters")
}HasAdmiral
The same.
HasAdmiral()
// returns: 1: a boolean
if !HasAdmiral() {
Print("fewer fleet slots than you think")
}IsVacationModeEnabled
Is the account in vacation mode.
IsVacationModeEnabled()
// returns: 1: a boolean
if IsVacationModeEnabled() {
LogWarn("vacation mode: nothing will leave, this is not a script failure")
return
}SetVacationMode
Freezes the account. Forty-eight hours minimum.
SetVacationMode()
// returns: 1: an error
err = SetVacationMode()GetPlanets
All your planets.
GetPlanets()
// returns: 1: a list
planets = GetPlanets() // ONE target: the listGetPlanet
One given planet.
GetPlanet(what)
// returns: 2: the planet and an error
p, err = GetPlanet("1:2:3") // TWO targets, the doc announces the errorGetCelestial
One given planet or moon, either one.
GetCelestial(what)
// returns: 2: the celestial and an errorGetCelestials
All your planets and moons together.
GetCelestials()
// returns: 2: the list and an error
c, err = GetCelestials() // ✓ c holds the list, err holds nilGetCachedCelestial
The celestial as the bot already knows it.
GetCachedCelestial(what)
// returns: 1: a celestial
c = GetCachedCelestial("1:2:3")GetCachedCelestials
All your planets and moons, as the bot already knows them.
GetCachedCelestials()
// returns: 1: a list
origin = GetCachedCelestials()[0]GetCachedPlanets
Your planets, taken from the same cache.
GetCachedPlanets()
// returns: 1: a list
c = GetCachedPlanets()[0]GetSortedCelestials
Your celestials, from nearest to farthest.
GetSortedCelestials(destination)
// returns: 1: a listGetSortedPlanets
Your planets alone.
GetSortedPlanets(destination)
// returns: 1: a list
base = GetSortedPlanets("4:212:9")[0] // the nearest to the targetGetResources
Metal, crystal, deuterium, energy, dark matter, population, food.
GetResources(celestial)
// returns: 2: the resources and an error
r, err = GetResources("1:2:3")GetResourcesDetails
The same, with storage capacity and production.
GetResourcesDetails(celestial)
// returns: 2: the detail and an error
d, err = GetResourcesDetails("1:2:3")GetAllResources
The resources of every celestial at once.
GetAllResources()
// returns: 2: a table and an error
all, err = GetAllResources()GetEmpire
Everything about one kind of celestial: resources, mines, facilities, defences, ships.
GetEmpire(type)
// returns: 2: a list and an error
empire, err = GetEmpire(PLANET_TYPE)GetResourcesBuildings
The nine: mines, solar plant, fusion reactor, satellites, storages.
GetResourcesBuildings(celestial)
// returns: 2: the levels and an error
bld, err = GetResourcesBuildings("1:2:3")GetFacilities
The eleven: factories, shipyard, lab, depot, silo, terraformer, dock, lunar base, phalanx, jump gate.
GetFacilities(celestial)
// returns: 2: the levels and an error
fac, err = GetFacilities(celestial)GetShips
What is parked there, not what is flying.
GetShips(celestial)
// returns: 2: the ships and an error
ships, err = GetShips(planet)GetTechs
The whole reading at once.
GetTechs(celestial)
// returns: 6: buildings, facilities, ships, defences, researches, an error
bld, fac, shp, def, rch, err = GetTechs("1:2:3")GetTechs2
The entire reading of a celestial.
GetTechs2(celestial)
// returns: 8: the six above, plus the lifeform buildings and researches
bld, fac, shp, def, rch, lfBld, lfRch, err = GetTechs2("1:2:3")GetResearch
They belong to the account, not to the celestial: no argument.
GetResearch()
// returns: 1: your researchesGetProduction
Ships and defences at the shipyard.
GetProduction(celestial)
// returns: 3: the queue, the seconds left, an error
queue, left, err = GetProduction("1:2:3")ConstructionsBeingBuilt
The building and the research under way.
ConstructionsBeingBuilt(celestial)
// returns: 4: building, seconds, research, seconds
bID, bSec, rID, rSec = ConstructionsBeingBuilt("1:2:3")GetResourceSettings
The seven output sliders.
GetResourceSettings(planet)
// returns: 2: the settings and an error
settings, err = GetResourceSettings("1:2:3")GetFields
GetFields(celestial)
// returns: 1: the fields, `Built` and `Total`
f = GetFields("1:2:3")GetDiameter
The diameter, in kilometres.
GetDiameter(celestial)
// returns: 1: an integer
Print("radius:", GetDiameter("1:2:3") / 2)Build
Building, technology, ship or defence.
Build(celestial, what, count)
// returns: 1: an error
err = Build(c.GetID(), LIGHTFIGHTER, 5)BuildBuilding
Refuses anything that is not a building.
BuildBuilding(celestial, building)
// returns: 1: an error
BuildBuilding(c.GetID(), METALMINE)BuildTechnology
Refuses anything that is not a technology.
BuildTechnology(celestial, technology)
// returns: 1: an error
BuildTechnology(c.GetID(), ENERGYTECHNOLOGY)TearDown
Tears one level down.
TearDown(celestial, building)
// returns: 1: an error
TearDown(c.GetID(), SOLARPLANT)CancelBuilding
Cancels the construction under way.
CancelBuilding(celestial)
// returns: 1: an error
CancelBuilding(c.GetID())CancelResearch
Cancels the research under way.
CancelResearch(celestial)
// returns: 1: an error
CancelResearch(c.GetID())GetLfBuildings
One request per call.
GetLfBuildings(celestial)
// returns: 2: the buildings and an error
b, err = GetLfBuildings(c.GetID())GetLfResearch
One request per call.
GetLfResearch(celestial)
// returns: 2: the researches and an error
res, err = GetLfResearch(c.GetID())GetLfBonuses
Reads the bonuses from the game.
GetLfBonuses()
// returns: 2: the bonuses and an error
fresh, err = GetLfBonuses()GetCachedLfBonuses
What the bot already knows. No request.
GetCachedLfBonuses()
// returns: 2: the bonuses and an error
bonus, err = GetCachedLfBonuses()GetPlanetLifeformType
One request. No error: see below.
GetPlanetLifeformType(planet)
// returns: 1: the lifeform
if GetPlanetLifeformType(p) != KAELESH {
return // this script only handles Kaelesh
}CancelLfBuilding
Cancels the lifeform building under way.
CancelLfBuilding(celestial)
// returns: 1: an errorGetLfResearchDetails
Costs, durations and what is unlocked.
GetLfResearchDetails(celestial)
// returns: 2: the details and an errorGetChapter
Its tasks, and the state of each.
GetChapter(chapter)
// returns: 2: the chapter and an errorChapterCollectReward
Collects the reward of one task.
ChapterCollectReward(task)
// returns: 1: an errorChapterClaimAll
Collects everything collectable.
ChapterClaimAll(chapter)
// returns: 1: an error
err = ChapterClaimAll(4006) // ← yours: the chapter idSelectLfResearchSelect
Accepts the research on offer.
SelectLfResearchSelect(planet, slot)
// returns: 1: an errorSelectLfResearchRandom
Draws another one at random.
SelectLfResearchRandom(planet, slot)
// returns: 1: an errorSelectLfResearchArtifacts
Trades artifacts for it.
SelectLfResearchArtifacts(planet, slot, tech)
// returns: 1: an errorFreeResetTree
Wipes a whole tier. Free, but limited in number.
FreeResetTree(planet, tier)
// returns: 1: an error
err = FreeResetTree(p, 1) // tier 1, blank againNewResourceSettings
Composes the seven sliders.
NewResourceSettings(metal, crystal, deuterium, solar, fusion, satellite, crawler)
// returns: 1: settings
after = NewResourceSettings(before.MetalMine, before.CrystalMine, 100,
before.SolarPlant, before.FusionReactor, before.SolarSatellite, before.Crawler)SetResourceSettings
Applies them.
SetResourceSettings(planet, settings)
// returns: 1: an error
err = SetResourceSettings(c.GetID(), after)TechnologyDetails
Price, duration and level, on that celestial.
TechnologyDetails(celestial, what)
// returns: 2: the details and an errorFleets
GetFleets
Your fleets in the air, not the ones aimed at you.
GetFleets()
// returns: 2: the flights and the slots
fleets, slots = GetFleets() // TWO targetsGetAttacks
The hostile fleets on their way to your account.
GetAttacks()
// returns: 1: a list
for a in GetAttacks() {
Print(a.AttackerName, "arriving at", a.DestinationName, "in", a.ArriveIn, "s")
if a.Ships == nil { Print(" composition unknown") }
}Distance
The distance in the game's unit. No request.
Distance(origin, target)
// returns: 1: an integer
Print(Distance(origin, "1:2:4")) // the celestial is enough, no need for .GetCoordinate()FlightTime
One request per call.
FlightTime(origin, target, speed, fleet, mission, [holdingTime])
// returns: 2: the seconds and the deuterium
secs, fuel = FlightTime(origin, target, HUNDRED_PERCENT, fleet, TRANSPORT)FindDebrisFieldWithMinimumTravelTime
A debris field.
FindDebrisFieldWithMinimumTravelTime(origin, fleet, minimum)
// returns: 4
dest, secs, deut, err = FindDebrisFieldWithMinimumTravelTime(p.GetCoordinate(),
fleet, 7 * time.Hour)FindEmptyPlanetWithMinimumTravelTime
An empty slot.
FindEmptyPlanetWithMinimumTravelTime(origin, fleet, minimum)
// returns: 4
dest, secs, deut, err = FindEmptyPlanetWithMinimumTravelTime(c.GetCoordinate(),
fleet, HOURS * 3600)FindInactivePlanetWithMinimumTravelTime
An inactive player.
FindInactivePlanetWithMinimumTravelTime(origin, fleet, minimum, withMoon)
// returns: 4FindAbandonedPlanetWithMinimumTravelTime
A destroyed planet.
FindAbandonedPlanetWithMinimumTravelTime(origin, fleet, minimum, withMoon)
// returns: 4Speed
The speed of the slowest ship, the one that dictates the flight.
Speed(fleet)
// returns: 1: an integer
Print(Speed(f), Cargo(f))Cargo
The total cargo capacity, all resources together.
Cargo(fleet)
// returns: 1: an integer
Print(Speed(f), Cargo(f))ShipFuel
Its reference consumption, the one that enters the fuel calculation. Never less than 1.
ShipFuel(id)
// returns: 1: an integerShipCargo
Its hold.
ShipCargo(id)
// returns: 1: an integer
Print(ShipCargo(LARGECARGO)) // 25000 at base, more with hyperspaceCalcCargo
Two separate solutions, not the two halves of one fleet.
CalcCargo(total)
// returns: 2: large cargos, OR small ones
lc, sc = CalcCargo(res.Total())CalcFastCargo
The composition your ships allow.
CalcFastCargo(lcAvail, scAvail, total)
// returns: 3: large ones, small ones, and the cargo obtained
lc, sc, capacity = CalcFastCargo(10, 8, res.Total())AttackStrength
Firepower, plus 10% of the base value per weapons level.
AttackStrength(id, researches)
// returns: 1: an integer
Print(AttackStrength(LIGHTFIGHTER, nil)) // with your researchesShieldPower
Shield, plus 10% per shielding level.
ShieldPower(id, researches)
// returns: 1: an integerStructuralIntegrity
Structure, plus 10% per armour level.
StructuralIntegrity(id, researches)
// returns: 1: an integerGetPrice
n is a level for a building or a research, a number of units for a ship or a defence.
GetPrice(id, n)
// returns: 1: resources
p = GetPrice(METALMINE, 20)ConstructionTime
Construction time, from the facilities supplied.
ConstructionTime(id, n, facilities)
// returns: 1: a duration
Print(ShortDur(ConstructionTime(LARGECARGO, 20, fac)))TechnologyConstructionTime
Time for a research, with the lab level given plainly.
TechnologyConstructionTime(id, level, lab)
// returns: 1: a duration
Print(ShortDur(TechnologyConstructionTime(ESPIONAGETECHNOLOGY, 10, fac.ResearchLab)))Phalanx
Reads what flies around a position.
Phalanx(moon, target)
// returns: 2: the flights and an error
flights, err = Phalanx(moon.GetID(), "1:2:8")CancelFleet
Turns a flight in progress around.
CancelFleet(fleet)
// returns: 1: an error
err = CancelFleet(flight.ID)JumpGate
Jumps ships from one moon to another.
JumpGate(origin, destination, ships)
// returns: 1: an error
err = JumpGate(moon.GetID(), destinations[0], ships)JumpGateDestinations
What can be reached, and in how long.
JumpGateDestinations(origin)
// returns: 3: the moons, the recharge, an error
destinations, recharge, err = JumpGateDestinations(moon.GetID())JumpGate2
The same jump, with the delay as a number.
JumpGate2(origin, destination, ships)
// returns: 3: success, the recharge, an error
sent, recharge, err = JumpGate2(moon.GetID(), destinations[0], ships)SendDiscoveryFleet
One expedition to ONE position.
SendDiscoveryFleet(origin, destination)
// returns: 1: an error
err = SendDiscoveryFleet("1:64:8", "1:64:12")GetDepartureTime
When to leave to arrive at the stated time.
GetDepartureTime(arrival, origin, destination, ships, speed, mission)
// returns: 1: a time
departure = GetDepartureTime("08:00:00", "1:64:8", "1:64:12", ships, TEN_PERCENT, TRANSPORT)LowestSpeed
The cheapest speed that can still leave.
LowestSpeed(arrival, origin, destination, ships)
// returns: 4: the speed, the fuel, the departure time, an error
speed, deut, departure, err = LowestSpeed("08:00:00", "1:64:8", "1:64:12", ships)StartPhalanxSession
Sets up the watch on a position and turns it on.
StartPhalanxSession(moon, target, interval)
// returns: 2: an id and an error
id, err = StartPhalanxSession(moon.GetID(), "1:2:8", 300) // every 5 minStopPhalanxSession
Turns it off.
StopPhalanxSession(id)
// returns: 1: an error
StopPhalanxSession(id)CalcPreferredCargo
Composes a transport serving the wanted type first.
CalcPreferredCargo(preferred, probes, pathfinders, large, small, total, roundUp)
// returns: 5: probes, pathfinders, large, small, the cargo
probes, pathfinders, lc, sc, cargo = CalcPreferredCargo(LARGECARGO, 0, 0, 50, 20, 5000000, true)CreateUnion
Opens a joint attack around a fleet.
CreateUnion(fleet, players)
// returns: 2: the union number and an errorWorkers
StartFarmingBot
Farming. StartFarmingBot() gives the farmer a session when it has none.
StartFarmingBot()
// returns: 1: an error
StartFarmingBot()StopFarmingBot
Farming. StartFarmingBot() gives the farmer a session when it has none.
StopFarmingBot()
// returns: 1: an error
err = StopFarmingBot()StartFarmSession
Starts one named session, like the ▶ on its row.
StartFarmSession(session)
// returns: 1: an error
StartFarmSession(session.ID)IsRunningBrainBot
True if Brain is on.
IsRunningBrainBot()
// returns: 1: a boolean
Print(IsRunningBrainBot(), IsRunningExpeditionsBot(), IsRunningColonizerBot())IsRunningFarmingBot
True if farming is on.
IsRunningFarmingBot()
// returns: 1: a boolean
if IsRunningFarmingBot() {
Print("farming is running")
}IsRunningExpeditionsBot
IsRunningExpeditionsBot()
// returns: 1: a boolean
Print(IsRunningBrainBot(), IsRunningExpeditionsBot(), IsRunningColonizerBot())IsRunningColonizerBot
IsRunningColonizerBot()
// returns: 1: a boolean
Print(IsRunningBrainBot(), IsRunningExpeditionsBot(), IsRunningColonizerBot())IsRunningDiscoveryBot
IsRunningDiscoveryBot()
// returns: 1: a boolean
Print(IsRunningDiscoveryBot(), IsRunningDefenderBot())IsRunningDefenderBot
IsRunningDefenderBot()
// returns: 1: a boolean
Print(IsRunningDiscoveryBot(), IsRunningDefenderBot())StartWorker
Switches the named worker on.
StartWorker(name)
// returns: 1: an error
err = StartWorker("timer")IsWorkerRunning
Says whether it is on.
IsWorkerRunning(name)
// returns: 1: a boolean
Print(name, IsWorkerRunning(name))ListWorkers
The accepted names, in English.
ListWorkers()
// returns: 1: a list
for name in ListWorkers() {
Print(name, IsWorkerRunning(name))
}NewFarmSession
To chain, then BuildFarmSession().
NewFarmSession()
// returns: 1: a builder
f = NewFarmSession()GetExpeditionsStrategynot shipped yet
Documented here, but not in the published build yet: it comes with the next bot version.
"majority", "all" or "never".
GetExpeditionsStrategy()
// returns: 1: a string
if GetExpeditionsStrategy() != "all" {
err = SetExpeditionsStrategy("all")
if err != nil { LogError("strategy:", err) }
}SetExpeditionsStrategynot shipped yet
Documented here, but not in the published build yet: it comes with the next bot version.
Changes it, setting saved.
SetExpeditionsStrategy(name)
// returns: 1: an error
err = SetExpeditionsStrategy("all")GetFleetSlotsReserved
How many slots are kept free.
GetFleetSlotsReserved()
// returns: 1: an integer
kept = GetFleetSlotsReserved()SetFleetSlotsReserved
Changes that number, setting saved.
SetFleetSlotsReserved(n)
// returns: 1: an errorIgnorePlayer
Spares a player. Name or id.
IgnorePlayer(player)
// returns: 1: an error
IgnorePlayer("Xylo") // by name, as on screenIgnorePlanet
Spares a position, moon included.
IgnorePlanet(coord)
// returns: 1: an error
IgnorePlanet("1:42:8") // the planet AND its moonIgnoreAlliance
Spares every known member of an alliance.
IgnoreAlliance(tag)
// returns: 1: an error
IgnoreAlliance("SLD") // every member the Scanner has seenUnignorePlanet
UnignorePlanet(coord)
// returns: 1: an errorUnignoreAlliance
UnignoreAlliance(tag)
// returns: 1: an errorIsPlayerIgnored
Whether it is on the list.
IsPlayerIgnored(player)
// returns: 1: a boolean
if IsPlayerIgnored("Xylo") {
Print("left alone")
}IsPlanetIgnored
IsPlanetIgnored(coord)
// returns: 1: a booleanIsAllianceIgnored
IsAllianceIgnored(tag)
// returns: 1: a booleanGetIgnored
The whole list, all three kinds together.
GetIgnored()
// returns: 2: the list and an error
list, err = GetIgnored()GetFarmBlacklist
The whole list, players and positions together.
GetFarmBlacklist()
// returns: 2: the list and an error
entries, err = GetFarmBlacklist()AddToFarmBlacklist
A player, by name or id, or a position.
AddToFarmBlacklist(target)
// returns: 1: an error
AddToFarmBlacklist("1:42:8") // by hand: the planet AND its moonRemoveFromFarmBlacklist
Removing what is not there is not an error; a name nothing knows is one.
RemoveFromFarmBlacklist(target)
// returns: 1: an error
RemoveFromFarmBlacklist(e.Key) // give back only the automatic entriesClearFarmBlacklist
Empties it, automatic entries included.
ClearFarmBlacklist()
// returns: 1: an error
ClearFarmBlacklist()GetHunterTargets
The players under watch.
GetHunterTargets()
// returns: 2: the list and an error
targets, err = GetHunterTargets()AddHunterTarget
Puts a player under watch.
AddHunterTarget(player)
// returns: 1: an error
AddHunterTarget("Xylo") // by name, as on screenPauseHunterTarget
Suspends them without losing their history.
PauseHunterTarget(player, paused)
// returns: 1: an errorIsScriptRunning
Is that one running.
IsScriptRunning(name)
// returns: 1: a boolean
if IsScriptRunning(WATCH) {
LogInfo("the watch is already running")
return
}IsPausedScript
Is that one paused.
IsPausedScript(name)
// returns: 1: a boolean
if IsPausedScript(WATCH) {
ResumeScript(WATCH)
}StartScript
Starts it and returns at once.
StartScript(name)
// returns: 1: an error
StartScript("night-watch")IsFarmSessionOngoing
Is a campaign working right now.
IsFarmSessionOngoing()
// returns: 1: a boolean
if IsFarmSessionOngoing() {
PauseFarmingBot() // giving the slots back to the Defender
SleepMin(30)
ResumeFarmingBot() // and back to where we left off
}FarmingBotSessionsCount
How many campaigns are running.
FarmingBotSessionsCount()
// returns: 1: an integerPauseFarmingBot
Suspends the running campaign.
PauseFarmingBot()
// returns: 1: an error
PauseFarmingBot() // giving the slots back to the DefenderResumeFarmingBot
Resumes it where it stopped.
ResumeFarmingBot()
// returns: 1: an error
ResumeFarmingBot() // and back to where we left offAbortAllFarmingSessions
Stops everything and removes every campaign, the running one and those from the Farmer tab included.
AbortAllFarmingSessions()
// returns: 1: an error
AbortAllFarmingSessions() // in the evening: nothing runs, nothing from yesterdayRepatriateNow
Runs a repatriation pass without waiting.
RepatriateNow()
// returns: 1: an error
RepatriateNow()RepatriateSetAllDestinations
That celestial receives, all the others feed it.
RepatriateSetAllDestinations(celestial)
// returns: 1: an error
RepatriateSetAllDestinations("1:64:8")ClearAllConstructionQueues
Empties the queue of every celestial in Queue mode.
ClearAllConstructionQueues()
// returns: 1: an error
ClearAllConstructionQueues()AddItemToQueue
Adds a line at the end of a celestial's queue.
AddItemToQueue(celestial, what, number)
// returns: 1: an error
err = AddItemToQueue(c.GetID(), METALMINE, 0)GetNextSleepTime
The next time it goes to sleep.
GetNextSleepTime()
// returns: 1: a time, or `nil`
end = GetNextSleepTime()SetDefenderCheckInterval
The round's interval, in seconds.
SetDefenderCheckInterval(min, max)
// returns: 1: an errorTriggerFleetSave
Sends the fleet out now, using the sleep-mode settings.
TriggerFleetSave()
// returns: 1: an error
err = TriggerFleetSave()Galaxy
GetCachedPlayer
PlayerID, PlayerName, Points, Rank, Total, HonourPoints.
GetCachedPlayer()
// returns: 1: your own record
me = GetCachedPlayer() // ONE target: this is a structGetSlots
InUse, Total, ExpInUse, ExpTotal.
GetSlots()
// returns: 1: your fleet slots
slots = GetSlots() // ONE target as wellServerURL
Your server's address, with no trailing slash. A Kepler addition.
ServerURL()
// returns: 2: an address and an error
addr, err = ServerURL() // TWO targetsGalaxyInfos
The fifteen positions of a system.
GalaxyInfos(galaxy, system)
// returns: 2: the reading and an error
sys, err = GalaxyInfos(1, 224) // TWO targetsGalaxyInfosUsing
The same, standing on a celestial.
GalaxyInfosUsing(galaxy, system, celestial)
// returns: 2: the reading and an error
sys, err = GalaxyInfosUsing(4, 116, c.GetID())GetPlanetInfo
A single position.
GetPlanetInfo(coordinate)
// returns: 2: the position and an error
p, err = GetPlanetInfo("4:116:6")GetPlanetInfoUsing
The same, standing on a celestial.
GetPlanetInfoUsing(coordinate, celestial)
// returns: 2: the position and an errorCoordinatesAvailableForDiscoveryFleet
The positions a lifeform expedition can be sent to, empty ones included. Empty list when there is none.
CoordinatesAvailableForDiscoveryFleet(origin, galaxy, system)
// returns: 2: the list and an error
coords, err = CoordinatesAvailableForDiscoveryFleet(origin, 1, 64)GetSystemsInRange
In order of number.
GetSystemsInRange(origin, radius)
// returns: 1: a list of systems
Print(GetSystemsInRange(3, 2)) // [1 2 3 4 5]GetSystemsInRangeAsc
Nearest to farthest.
GetSystemsInRangeAsc(origin, radius)
// returns: 1: a list of systems
Print(GetSystemsInRangeAsc(3, 2)) // [3 2 4 1 5]GetSystemsInRangeDesc
Farthest to nearest.
GetSystemsInRangeDesc(origin, radius)
// returns: 1: a list of systems
Print(GetSystemsInRangeDesc(3, 2)) // [5 1 4 2 3]PlayersData
Every player in the universe.
PlayersData()
// returns: 2: the list and an error
players, err = PlayersData() // TWO targetsPlayerDataByID
Clean error if the ID is unknown.
PlayerDataByID(id)
// returns: 2: a player and an error
p, err = PlayerDataByID(id)PlayerDataByName
Whole nickname, case is ignored.
PlayerDataByName(name)
// returns: 2: a player and an error
target, err = PlayerDataByName("Xylo")HighscoreData
Through the game's API. IDs, not names.
HighscoreData(category, typ)
// returns: 2: the whole highscore and an error
ranks, err = HighscoreData(1, 0) // players, general highscoreGetHighscore
No longer works in version 13.
GetHighscore(category, typ, page)
// returns: 2: a page and an errorPageContent
A game page, through the account's session.
PageContent(query)
// returns: 2: the text and an error
html, err = PageContent("page=ingame&component=overview")FetchURL
Any address, through the same session.
FetchURL(url)
// returns: 2: the text and an error
body, err = FetchURL("https://example.net/api")HttpRequest
A full request, through the same session.
HttpRequest(method, url, headers, body)
// returns: 3: the text, the code and an error
body, code, err = HttpRequest("POST", "https://example.net/api", headers, payload)SendMessage
A private message, through the game's chat.
SendMessage(playerID, message)
// returns: 1: an error
err = SendMessage(target.ID, "Hello, I come in peace.")GetEspionageReportMessages
The summary of each report on the first page.
GetEspionageReportMessages()
// returns: 2: the list and an error
summaries, err = GetEspionageReportMessages()GetEspionageReportMessagesPages
The same, across several pages.
GetEspionageReportMessagesPages(pages)
// returns: 2: the list and an error
older, err = GetEspionageReportMessagesPages(3)GetEspionageReport
The detailed report of a message.
GetEspionageReport(msgID)
// returns: 2: the report and an error
detail, err = GetEspionageReport(summaries[0].ID)GetEspionageReportFor
The latest report on that position.
GetEspionageReportFor(coordinate)
// returns: 2: the report and an error
report, err = GetEspionageReportFor("1:2:3")GetCombatReportSummaryFor
The latest fight at that position.
GetCombatReportSummaryFor(coordinate)
// returns: 2: the summary and an error
fight, err = GetCombatReportSummaryFor("1:2:3")DeleteMessage
Deletes one message.
DeleteMessage(msgID)
// returns: 1: an error
DeleteMessage(summaries[0].ID)DeleteAllMessagesFromTab
Empties a whole tab.
DeleteAllMessagesFromTab(tab)
// returns: 1: an error
DeleteAllMessagesFromTab(20)CountColonies
What you have, what you may have.
CountColonies()
// returns: 2: the count and the maximum
count, possible = CountColonies()Toolbox
Floor
The integer below.
Floor(x)
// returns: 1: a number
Floor(o["planet_id"] / 2) == 16814034 // truePow
x to the power y.
Pow(x, y)
// returns: 1: a number
Print(Itoa(Pow(10, 7))) // ✓ 10000000: go through Itoa to printItoa
Writes an integer as text.
Itoa(n)
// returns: 1: a string
Print(Itoa(Pow(10, 7))) // ✓ 10000000: go through Itoa to printDotify
Formats a large number the way the game does: 1000000 gives 1.000.000.
Dotify(n)
// returns: 1: a stringBase64Decode
Decodes.
Base64Decode(text)
// returns: 2: the text and an error
plain, err = Base64Decode(code) // ← TWO targetsJsonDecode
Decodes JSON.
JsonDecode(data)
// returns: 2: the value and an error
o, err = JsonDecode(body) // ← TWO targets, againJsonEncode
Writes JSON.
JsonEncode(value)
// returns: 2: the text and an error
text, err = JsonEncode(payload) // ← TWO targetsJsonEncodeIndent
The same, laid out.
JsonEncodeIndent(value, indent)
// returns: 2: the text and an errorMapKeys
Sorted.
MapKeys(table)
// returns: 1: the list of keys
Print(MapKeys(cache)[i], MapValues(cache)[i])MapValues
In key order.
MapValues(table)
// returns: 1: the list of values
Print(MapKeys(cache)[i], MapValues(cache)[i])NewShipsInfos
To be filled with .Set(id, count), then passed to FlightTime, Speed or Cargo.
NewShipsInfos()
// returns: 1: an empty fleet
fleet = NewShipsInfos()NewResources
The three quantities in one go.
NewResources(metal, crystal, deut)
// returns: 1: resources
res = NewResources(10000, 20000, 30000)NewCoordinate
The type is PLANET_TYPE, MOON_TYPE or DEBRIS_TYPE.
NewCoordinate(galaxy, system, position, type)
// returns: 1: a coordinateParseCoord
Reads "1:2:3" or "M:1:2:3".
ParseCoord(string)
// returns: 2: the coordinate and an error
coord, err = ParseCoord("M:1:2:3") // TWO targetsID2Str
The readable name of a ship, a defence, a building or a technology.
ID2Str(id)
// returns: 1: a string
Print(ID2Str(204)) // LightFighterShortShipsInfos
Sums up a fleet: LightFighter: 120, SmallCargo: 40.
ShortShipsInfos(fleet)
// returns: 1: a string
LogInfof("%s : %s", planet.Coordinate, ShortShipsInfos(ships))VersionCompare
-1 if a is older, 0 if they are equal, 1 if a is newer.
VersionCompare(a, b)
// returns: 1: an integer
Print(VersionCompare("1.2", "1.2.0")) // 0: absent segments count as zeroGetItems
Every item on the celestial.
GetItems(celestial)
// returns: 2: the items and an error
items, err = GetItems(c.GetID())GetActiveItems
Only those currently in effect.
GetActiveItems(celestial)
// returns: 2: the items and an error
active, err = GetActiveItems(c.GetID())ActivateItem
Switches on an item from the inventory.
ActivateItem(reference, celestial)
// returns: 1: an error
err = ActivateItem(o.Ref, c.GetID())RecruitOfficer
Hires an officer. 2 commander, 3 admiral, 4 engineer, 5 geologist, 6 technocrat; 7 or 90 days.
RecruitOfficer(officer, days)
// returns: 1: an error
Print(RecruitOfficer(5, 7)) // a geologist for seven daysGetAuction
The auction under way.
GetAuction()
// returns: 2: the auction and an error
auction, err = GetAuction()BuyOfferOfTheDay
Buys the merchant's offer.
BuyOfferOfTheDay()
// returns: 1: an error
Print(BuyOfferOfTheDay())SendIPM
Fires missiles.
SendIPM(planet, target, count, defence)
// returns: 2: the missiles sent and an error
sent, err = SendIPM(c.GetID(), "1:1:1", 10, 0)DestroyRockets
Destroys missiles in your silo.
DestroyRockets(planet, abm, ipm)
// returns: 1: an errorShipsAttackStrength
The firepower of a whole fleet.
ShipsAttackStrength(ships, researches)
// returns: 1: an integerShipsAttackStrengthUsingOwnResearches
The same, with your own researches.
ShipsAttackStrengthUsingOwnResearches(ships)
// returns: 1: an integer
Print("firepower:", ShipsAttackStrengthUsingOwnResearches(ships))NewTemperature
Both bounds, as the game shows them.
NewTemperature(min, max)
// returns: 1: a temperature
temp = NewTemperature(-12, 40)SolarSatelliteProduction
The energy satellites produce.
SolarSatelliteProduction(temperature, count)
// returns: 1: an integer
Print("energy:", SolarSatelliteProduction(temp, 123))GetRequirements
The direct requirements of a build.
GetRequirements(id)
// returns: 1: a map
Print(GetRequirements(LIGHTLASER)) // shipyard 2, laser technology 3ConvertIntoCoordinate
Normalises anything naming a position.
ConvertIntoCoordinate(what)
// returns: 2: the coordinate and an errorGetPlayerCoordinates
The scanned positions of a player.
GetPlayerCoordinates(player)
// returns: 1: a list of coordinatesConstants and values
Reacting to an event
OnAttackCha channel of attacksOnAttackGoneCha channel of attacksOnStateChangeCha channel of statesOnChatMessageReceivedCha channel of messagesOnFleetCha channel of fleetsOnHunterTargetActiveCha channel of changesOnHunterTargetIdleCha channel of changesThe four id arrays
ShipsArr16 idsDefencesArr10 idsTechnologiesArr16 idsBuildingsArr23 idsThe id names
SMALLCARGOLARGECARGOLIGHTFIGHTERHEAVYFIGHTERCRUISERBATTLESHIPCOLONYSHIPRECYCLERESPIONAGEPROBEBOMBERDESTROYERDEATHSTARBATTLECRUISERCRAWLERREAPERPATHFINDERROCKETLAUNCHERLIGHTLASERHEAVYLASERGAUSSCANNONIONCANNONPLASMATURRETSMALLSHIELDDOMELARGESHIELDDOMEANTIBALLISTICMISSILESINTERPLANETARYMISSILESESPIONAGETECHNOLOGYCOMPUTERTECHNOLOGYWEAPONSTECHNOLOGYSHIELDINGTECHNOLOGYARMOURTECHNOLOGYENERGYTECHNOLOGYHYPERSPACETECHNOLOGYCOMBUSTIONDRIVEIMPULSEDRIVEHYPERSPACEDRIVELASERTECHNOLOGYIONTECHNOLOGYPLASMATECHNOLOGYINTERGALACTICRESEARCHNETWORKASTROPHYSICSGRAVITONTECHNOLOGYMETALMINECRYSTALMINEDEUTERIUMSYNTHESIZERSOLARPLANTFUSIONREACTORSOLARSATELLITEMETALSTORAGECRYSTALSTORAGEDEUTERIUMTANKSHIELDEDMETALDENUNDERGROUNDCRYSTALDENSEABEDDEUTERIUMDENALLIANCEDEPOTROBOTICSFACTORYSHIPYARDRESEARCHLABMISSILESILONANITEFACTORYTERRAFORMERSPACEDOCKLUNARBASESENSORPHALANXJUMPGATEMissions
ATTACK1GROUPEDATTACK2TRANSPORT3PARK4PARKINTHATALLY5SPY6COLONIZE7RECYCLEDEBRISFIELD8DESTROY9MISSILEATTACK10EXPEDITION15SEARCHFORLIFEFORMS18Speeds
TEN_PERCENTTWENTY_PERCENTTHIRTY_PERCENTFORTY_PERCENTFIFTY_PERCENTSIXTY_PERCENTSEVENTY_PERCENTEIGHTY_PERCENTNINETY_PERCENTHUNDRED_PERCENTFIVE_PERCENTFIFTEEN_PERCENTTWENTY_FIVE_PERCENTTHIRTY_FIVE_PERCENTFORTY_FIVE_PERCENTFIFTY_FIVE_PERCENTSIXTY_FIVE_PERCENTSEVENTY_FIVE_PERCENTEIGHTY_FIVE_PERCENTNINETY_FIVE_PERCENTCelestial types, lifeforms, classes
PLANET_TYPE1DEBRIS_TYPE2MOON_TYPE3NONE_LF_TYPE0 to 4HUMANS0 to 4ROCKTAL0 to 4MECHAS0 to 4KAELESH0 to 4NO_CLASS0 to 3COLLECTOR0 to 3GENERAL0 to 3DISCOVERER0 to 3NO_ALLIANCE_CLASS0 to 3WARRIOR0 to 3TRADER0 to 3RESEARCHER0 to 3The dimensions of the universe
GALAXIESan integerSYSTEMSan integerThe file, the server, the version
FILEa string__FILE__a stringOGAME_SERVERa recordVERSIONa string__VERSION__a stringWaiting for the stop: OnQuitCh
OnQuitCha channelThe stub values
LICENSE_UUIDthe empty string__LICENSE_UUID__the empty stringLICENSE_USERNAMEthe empty string__LICENSE_USERNAME__the empty stringLICENSE_EMAILthe empty string__LICENSE_EMAIL__the empty stringLICENSE_BOTS_ALLOWED0__LICENSE_BOTS_ALLOWED__0IS_CLOUDfalse__IS_CLOUD__falseIS_SELF_HOSTtrue__IS_SELF_HOST__trueCookieDomainthe empty stringDISCORD_WEBHOOKthe Discord webhook from the Notifications pageTELEGRAM_CHAT_IDthe Telegram chat from the Notifications page