The console allows you to issue any JavaScript command that you could usually use in a script, but allows you to do it interactively rather than having to quit, modify the script and run Oolite again. This means that you can fiddle with and examine the game state as it is in any give moment, rather than having to try to recreate the state each time. For instance, you can manipulate ships in the game world:
Code: Select all
player.target.call("becomeExplosion")
player.setPosition(player.position.add(0, 100, 0))
Spawn ships for testing:
Code: Select all
system.legacy_addSystemShips("myShipRole", 1, 1)
Examine mission state:
Code: Select all
missionVariables["trumbles"]
// Console prints "TRUMBLE_BOUGHT"
Write your own debug tools:
Code: Select all
:setM startLogging this.loggingTimer = new Timer(this, function() { Log("player position: " + player.position) } , 0, PARAM)
:setM stopLogging if (this.loggingTimer) { this.loggingTimer.stop(); delete this.loggingTimer }
:startLogging 1
// Player position is logged at one-second intervals
Make scripts do things:
Code: Select all
system.mainStation.script.doTestStuff()
Examine and modify the scripts of live objects:
Code: Select all
> systemScripts["oolite-cloaking-device"].willExitWitchSpace
// Console prints:
this.willExitWitchSpace = function()
{
if (galaxyNumber == 4)
{
if (missionVariables.cloak == null)
{
var cloakCounter = missionVariables.cloakcounter;
if (cloakCounter == null) cloakCounter = 1;
else cloakCounter++;
missionVariables.cloakcounter = cloakCounter;
if (cloakCounter > 6 && system.countShipsWithRole("asp-cloaked") == 0)
{
system.legacy_addShips("asp-cloaked", 1);
system.legacy_addShips("asp-pirate", 2);
}
}
}
}
> systemScripts["oolite-cloaking-device"].willExitWitchSpace = function() { player.credits += 5000 }
// Console prints:
function()
{
player.credits += 5000
}