Kepler. Documentation · Scripts 508 functions available right now Français

Worker settings

Each worker screen reads and writes in one go, through a pair of functions: GetExpeditionsConfigs() returns every setting of the Expeditions page in a table, the script changes what it wants, and SetExpeditionsConfigs(cfg) saves it. This is Ninja's model, and for Expeditions its field names: a copied script that writes configs.Sheets[0].Origin runs. Six screens have their pair on this page: Expeditions, Sleep mode, night fleet save, Repatriation, Distribution, Rewards and booster.

c = GetExpeditionsConfigs()
c.MaxSlots = 6
c.Sheets[0].Duration = 4
err = SetExpeditionsConfigs(c)
if err != nil {
	LogWarn("expedition settings refused: " + err.Error())
}

What a Set does

It only changes the fields it is given. SetExpeditionsConfigs({"MaxSlots": 6}) changes the cap and nothing else. A nested table merges the same way: a sheet, a day of the schedule, the Booster tab. A script that reads, waits, then hands back the whole object therefore erases nothing you changed on screen meanwhile: a field handed back as it was read is not written.

It takes the same path as the screen's Save button. The setting applies at once, survives a restart, and follows the same rules: tool exclusivity, normalisation, refusals. Nothing is written when nothing changes.

An unknown field is refused, with the list of known fields; so is a value out of bounds, never brought back silently. The error names the function and the field: SetExpeditionsConfigs: Sheets[0].Duration: 20 refused: the bot would bring it back to 15. One refused field, and nothing is written. The bounds are the screen's; those the bot applies on its own say "the bot would bring it back to".

The switch is not a field. A worker is turned on and off with StartWorker, StopWorker and their Ninja names (see Workers): writing Enabled is refused.

A celestial can be written four ways: the object (GetCachedPlanets()[0]), its ID (planet.GetID(), as in Ninja), its coordinate ("1:105:8", "M:1:105:8" for the moon) or "home" where the field can follow the home planet set under Settings > General. While the bot is connected, it must be a celestial of the account. A read returns the coordinate, or "home".

A worker's slot cap is its MaxSlots field, the worker's line under Settings > Fleet slots, from 0 (no cap) to 100. For the sends of your own scripts, use SetMaxSlotsFor, below.

Expeditions

FunctionReturns
GetExpeditionsConfigs()1: a tableEvery setting of the Expeditions page, sheets included (Sheets).
SetExpeditionsConfigs(cfg)1: an errorSaves the fields given.
NewSheet()1: a tableA new sheet, to add to Sheets: configs.Sheets += *sheet.
SetActiveExpeditionsSheet(name)1: an errorPicks the sheet in use, by name or UUID, and unticks the others. "" leaves none.
FieldType and boundsOn screen
Strategy"majority", "all" or "never"Strategy
MajorityThresholdinteger, 0 and up; 0: half the slotsDeparture threshold
MajorityMaxWaitminutes, 0 to 1440Max wait
DelayMin, DelayMaxseconds, 1 and up, the first not greaterDelay between two fleets of a wave
WaveDelayMin, WaveDelayMaxseconds, 1 and up, the first not greaterDelay before relaunching after a return
LargeCargoHome, SmallCargoHome, PathfindersHomeinteger, 0 and upShips to keep
RecycleDebristrue or falseRecycle the debris at position 16
MinimumPathfindersinteger, 1 and upMinimum pathfinders per field
RecyclePathfindersHomeinteger, 0 and upPathfinders kept at home
MaxSlotsinteger, 0 to 100Settings > Fleet slots > Expeditions
Sheetslist of sheetsThe sheet tabs

A sheet:

FieldType and boundsOn screen
UUIDtext, returned by the readNames the sheet; missing or "": a new sheet
NametextName
Activetrue or false, one at a timeSheet in use
Multitrue or falseSingle or multi planets
Origincelestial or "home"Origin (single)
SystemFrom, SystemTosystems of the universe, the first not greaterSystem range (single)
Originslist of celestials, in sending orderDeparture positions (multi)
Rangeinteger, 0 to 499Range (multi)
ExpeditionsPerOrigininteger, 1 to 25Expeditions per position (multi)
OwnCountPerOrigintrue or falseOwn count (multi)
CountPerOrigintable {celestial: integer 1 to 25}; 0 or nil removesThe count of each position (multi)
ExpeditionSpeedinteger, 1 to 10Expedition speed
Durationhours, 1 to 15Duration
AutoFleettrue or falseAutomatic fleet
AutoCargoLARGECARGO, SMALLCARGO or PATHFINDERShip that carries
Growthtrue or falseGrowth
AutoCargo2, AutoCargo3the same, or 0 for noneSecond and third ship that carries
AutoCombatMax0 (the best available) or a combat shipCombat ship at most
LightFighter, HeavyFighter, Cruiser, Battleship, Battlecruiser, Bomber, Destroyer, SmallCargo, LargeCargo, EspionageProbe, Reaper, Pathfinderinteger, 0 and upPer expedition
LightFighterAuto ... PathfinderAutotrue or falseSplit
Deletetrue, write onlyDelete the sheet

Only one sheet is in use at a time, as on screen: ticking one unticks the others, and two ticked in the same call are refused. SetActiveExpeditionsSheet("Night") is the shortcut, to switch sheets by the hour.

A sheet missing from the list is not deleted: you delete by writing {"UUID": "...", "Delete": true}. A new sheet, without UUID, is added at the end and takes the name "Config N" when it gives none, like the screen's "+"; it is not in use until Active says so. Choosing an origin without a range sets five systems on either side, like the screen's menu.

Where it differs from Ninja. Strategy is a word, not a number; DelayMin and DelayMax are the gap between two fleets of a wave, WaveDelayMin and WaveDelayMax the wait after a return before relaunching; Origin reads as a coordinate, not an ID; the ...Auto fields are the "Split" box. What Kepler does not have is accepted at zero and refused otherwise: EarlyPathfinders, EarlyPFSecsMin, EarlyPFSecsMax, MinSpeedEarlyPathfinders, and in a sheet IgnoreMinimumDeuterium, SlotsAllowed, ColonyShip, Recycler, Deathstar and their ...Auto.

configs = GetExpeditionsConfigs()
celestial = GetCachedPlanets()[0]
sheet = NewSheet()
sheet.Name = "Night"
sheet.Origin = celestial.GetID()
sheet.Duration = 8
sheet.LargeCargo = 300
sheet.Pathfinder = 1
configs.Sheets += *sheet
err = SetExpeditionsConfigs(configs)
if err != nil {
	LogWarn("sheet refused: " + err.Error())
}
CronExec("0 23 * * *", func() { SetActiveExpeditionsSheet("Night") })

Sleep mode

FunctionReturns
GetSleepModeConfigs()1: a tableThe settings of the Sleep mode page: schedule, and what fleets do during sleep.
SetSleepModeConfigs(cfg)1: an errorSaves the fields given.
SetSleepSchedule(day, from, to, from2, to2)1: an errorThe two ranges of a day, like a line of the schedule table; from2 and to2 are optional.
FieldType and boundsOn screen
Mode"manual" or "auto"Mode
WakeHour, WakeMinute0 to 23, 0 to 59Wake up at (manual mode)
Daystable of one day per name, "monday" to "sunday"Schedule
SleepJitter, WakeJitterminutes: 0, 5, 10, 15, 20, 30, 45, 60, 90 or 120Random offset of bedtime, of waking
BeforeSleep"skip", "ignore" or "returnwindow"Fleets that would return during sleep: do not send, send anyway, bring back within the return window
AnticipateDelaystrue or falseAnticipate expedition delays
HandleNightReturnstrue or falseHandle fleet returns during sleep
StayAwakeIfMainFleetHometrue or falseDo not sleep if the main fleet stayed at home (Fleet save tab)
Timezone"machine", "game" or a time zone like "Europe/Paris"Bot time zone

A day:

FieldType and boundsOn screen
From, Totime, "23:30"First range
From2, To2time, or "" for none; both togetherSecond range (optional)
ReturnFrom, ReturnTotime, or ""; both togetherFleet back between (sleep range 1), Fleet save tab
ReturnFrom2, ReturnTo2time, or ""; both togetherFleet back between (sleep range 2)

SetSleepSchedule sets the ranges, not the mode. The day is written in English ("monday"), by its rank from Now().Weekday() (0 for Sunday), or "everyday" for all seven days, like "Same every day": each day's return windows stay as they are. Without a second range, the day no longer has one. The schedule only applies in automatic mode: SetSleepModeConfigs({"Mode": "auto"}).

SetSleepSchedule("everyday", "23:30", "07:00")
SetSleepSchedule("saturday", "01:30", "10:00")
err = SetSleepModeConfigs({"Mode": "auto", "SleepJitter": 15, "BeforeSleep": "returnwindow"})
if err != nil {
	LogWarn("sleep refused: " + err.Error())
}

Night fleet save

FunctionReturns
GetFleetSaveConfigs()1: a tableThe settings of the night fleet save and its table of celestials.
SetFleetSaveConfigs(cfg)1: an errorSaves the fields given.
FieldType and boundsOn screen
OnSleeptrue or falseSend the fleet out at bedtime
From, Totime, "08:00"Fixed window, or return time
From2, To2time, or "" for none; both togetherFleet back between (sleep range 2)
AtWaketrue or falseReturn at wake-up
WakeFrom, WakeTominutes after waking, 0 to 1440, the first smallerBetween ... and ... minutes after waking
DeuteriumToLeaveinteger, 0 and up; nil: never set, 10,000Deuterium to leave behind
ProductionMinutesMin, ProductionMinutesMaxminutes, 0 to 1440, the first not greaterMinutes of production left on planets
SplitDelayMin, SplitDelayMaxseconds, 1 to 600; 0 and 0: five to tenGap between two departures of a split
MainFleetAlwaystrue or falseFleet save the main fleet in any case
Celestialslist of linesCelestials tab

A line of the celestials table:

FieldType and boundsOn screen
CelestialcelestialNames the line; a celestial without a line gets one
Activetrue or false, with a destinationSend out
Destination"park", "emptytomoon", "spy16", "spy16recall", "expedition", "expeditions", "colonize", "debris" or ""Destination: park, empty the planet onto its moon, spy position 16, the same recalled in flight, expedition, expeditions (all slots), colonise, harvest a debris field
Targetcelestial, or nil: the bot chooses; with "park"Targeted celestial
Remainder"park", "spy16", "spy16recall", "colonize", "debris" or ""; after an expeditionRest of the fleet
RemainderTargetcelestial, or nil; with Remainder "park"Celestial targeted by the rest
Expeditionsinteger, 0 to 25Number of expeditions
ExpeditionSheetUUID of a sheet, or ""Expedition sheet
KeepShipstable {ship: count}; with "emptytomoon"Kept at home
Splittrue or falseSplit

DeuteriumToLeave keeps its zero: 0 leaves zero behind, nil resets the box to "never set", which reads 10,000. A line of the table is named by its celestial, and lines the list does not name stay as they are. GetFleetSaveReturn and its two neighbours (see Workers) set the same return times.

f = GetFleetSaveConfigs()
for line in f.Celestials {
	if line.Destination == "spy16" {
		line.Destination = "spy16recall"
	}
}
f.DeuteriumToLeave = 0
err = SetFleetSaveConfigs(f)
if err != nil {
	LogWarn("night fleet save refused: " + err.Error())
}

Repatriation

FunctionReturns
GetRepatriateConfigs()1: a tableThe settings of the Repatriation tab.
SetRepatriateConfigs(cfg)1: an errorSaves the fields given.
SetRepatriateDestinations(celestials)1: an errorThe banks, several at once, without touching the celestials to empty.
FieldType and boundsOn screen
Mode"direct", "moon" or "collect"Mode: normal, moon, collection
EveryHourshours, 1 to 168Repatriate every
SendDelayMin, SendDelayMaxseconds, 2 and up, the first not greaterDelay between two transports
Destinationslist of celestialsDestinations (the banks)
Originslist of celestialsPlanets and moons to repatriate
Resources, Shipstrue or falseWhat to repatriate: resources, ships
KeepShipsPlanet, KeepShipsMoontable {ship: count}; 0 removesShips to keep on the planet, on the moon
LeavePlanet, LeaveMoontable Metal, Crystal, Deuterium, 0 and upLeave on the planet, on the moon
Cargo"LargeCargo", "SmallCargo" or "Pathfinder"Cargo ship
Cargo2, Cargo3the same, or "" for noneSecond and third type
RoundShips0, 10, 100, 1000 or 10000Round ships to
MinResourcesinteger, 0 and upMinimum resources to repatriate
MaxSlotsinteger, 0 to 100Settings > Fleet slots > Repatriation

The screen's refusals, worker on: at least one bank, at least one celestial to empty, and resources, ships or both. A ship table merges ship by ship: {LARGECARGO: 100} only changes large cargoes, {LARGECARGO: 0} removes them.

SetRepatriateDestinations(["M:1:105:8", "M:4:220:9"])
err = SetRepatriateConfigs({"Mode": "moon", "KeepShipsPlanet": {LARGECARGO: 100}, "LeaveMoon": {"Deuterium": 2000000}})
if err != nil {
	LogWarn("repatriation refused: " + err.Error())
}

Distribution

FunctionReturns
GetDistributionConfigs()1: a tableThe settings of the Distribution tab.
SetDistributionConfigs(cfg)1: an errorSaves the fields given.
FieldType and boundsOn screen
Bankslist of celestialsBanks that send
Destinationslist of celestialsDestinations that receive
Metal, Crystal, Deuteriuminteger, 0 and up, per destinationAllocation
FillUptrue or falseFill each destination up to these amounts, instead of sending them
MinSendinteger, 0 and upMinimum send
Cargo"LargeCargo" or "SmallCargo"Cargo ship
ShipsToStationinteger, 0 and upShips to station per destination
Autotrue or falseFill up automatically
BelowMetal, BelowCrystal, BelowDeuteriuminteger, 0 and up, under its amount when Auto is tickedBelow
CheckEveryMin, CheckEveryMaxminutes, 10 to 240, the first not greaterCheck every
MaxSlotsinteger, 0 to 100The Repatriation cap, shared

The slot cap is the Repatriation's, the same tab: writing it here changes it there.

err = SetDistributionConfigs({"Deuterium": 20000000, "FillUp": true, "Auto": true, "BelowDeuterium": 5000000})
if err != nil {
	LogWarn("distribution refused: " + err.Error())
}

Rewards and booster

FunctionReturns
GetRewardsConfigs()1: a tableThe settings of the Rewards and booster page, one table per tab.
SetRewardsConfigs(cfg)1: an errorSaves the fields given.
FieldType and boundsOn screen
DailyMissionstrue or falseDo the daily missions
AllowDarkMattertrue or falseDark matter allowed for missions
MissionsCelestialcelestial, "home", or nil for allWhere the missions are done
Messageslist of one-line texts, 20 at most, 100 characters each; empty: the default listMessages of the "Send an in-game message" mission
Boostertable, belowBooster tab
Auctiontable, belowAuctioneer tab
OfferOfTheDaytable: Active, Origin, ResourceImport/export tab
Asteroidtable, belowFarm event P17 tab

Booster:

FieldType and boundsOn screen
Activetrue or falseKeep boosters active
Buytrue or falseBuy the missing booster with dark matter
Accounttable {kind: tier}: "booster:expedition", "computer:expedition"Account booster
Stackstable {kind: list of tiers}: "slots:expedition" (1, 2, 3), "slots:fleet" (2, 4, 6)Expedition and fleet slots, stacked tiers
AllPlanetstable {kind: tier}: "booster:metal", "booster:crystal", "booster:deuterium", "booster:energy", "booster:resources""All planets" line
Planetslist of {"Planet": planet, "Choices": {kind: tier}}; nil sets a kind back to "Same as all"One line per planet that is an exception
Daystable {kind: 7, 30 or 90}, what the shop sellsPurchase duration

A tier is the shop's (40 for +40%), 0 for none, -1 for "Best available" outside slots.

Auction:

FieldType and boundsOn screen
Activetrue or false, with an originBid at the auctioneer
Origincelestial or "home"Bid from
Resource"metal", "crystal" or "deuterium"Pay in
MaxBidstable {item: bid}; negative: item unticked, bid kept; 0 or nil removesMaximum bid per item
DelayMin, DelayMaxseconds, 1 and up, the first not greaterDelay before answering an outbid
OnlyAtEndtrue or falseBid only near the end
MinutesBeforeEndminutes, 1 to 30Enter the sale
LastSecondtrue or falseBid at the last second
SpareIgnoredtrue or falseNever outbid a spared player

The items of MaxBids are the screen's: "booster:metal:40", "booster:energy:80", "kraken:1d", "newtron:6h", "detroid:30m"...

Asteroid:

FieldType and boundsOn screen
Activetrue or false, with an originAttack the event asteroid
Origincelestial or "home"Leave from
Shipa ship that flies, except colony ship and deathstarShip sent
Slotsinteger, 1 to 20Fleet slots assigned

The two boxes that spend dark matter are written like the others: the bot never spends it on its own, a script may.

err = SetRewardsConfigs({
	"Booster": {"Active": true, "Stacks": {"slots:fleet": [2, 4]}, "AllPlanets": {"booster:metal": -1}},
	"Auction": {"MaxBids": {"kraken:1d": 9000}},
})
if err != nil {
	LogWarn("booster refused: " + err.Error())
}

Slots for script sends

FunctionReturns
SetMaxSlotsFor(initiator, n)1: an errorCaps the flights in the air of an initiator, a name the script chooses: from 0 (no cap of its own) to 100.
GetSlot(initiator)1: a channelWaits for a free fleet slot for the initiator, the account's reserve counted; the channel delivers a function to call with the fleet sent.
CreateFleet(fleet, initiator)1: an errorRegisters a fleet already sent under an initiator: it counts toward its cap until it returns.

As in Ninja, so that a script that sends on its own does not take all the account's slots. GetSlot waits while the initiator holds as many flights as its cap, or while the account has no free slot beyond the reserve (Settings > Fleet slots); the wait shows on that page, under the script's name. Give the delivered function the fleet sent, or its ID; an empty fleet, from a refused send, gives the slot back. A slot granted whose fleet is never given back is freed after five minutes.

An initiator is not a worker: a worker name is refused, its cap is the MaxSlots field of its settings. Caps live in memory, shared by the account's scripts, and are set again when the script starts.

SetMaxSlotsFor("raids", 3)
for target in ["2:40:6", "2:41:7", "2:43:4"] {
	slot = <-GetSlot("raids")
	f = NewFleet()
	f.SetOrigin("M:1:105:8")
	f.SetDestination(target)
	f.SetMission(ATTACK)
	f.AddShips(LARGECARGO, 200)
	fleet, err = f.SendNow()
	slot(fleet)
}