Difference between revisions of "Private Server Common Tasks"

From Screeps Wiki
Jump to navigation Jump to search
(section remove invader cores)
(Refactored sections and added more commands)
Line 1: Line 1:
 
[[Category:Private Server|Common Tasks]]
 
[[Category:Private Server|Common Tasks]]
= Server CLI =
+
= Server CLI Commands =
   
  +
Run these commands in the screeps server CLI to perform various tasks.
== Changing & Checking Tick-Rate ==
 
In server CLI
 
<code>system.setTickDuration(1000)</code>
 
Will set the tick-duration to 1000 milliseconds per tick, default is 1000.
 
<code>system.getTickDuration()</code>
 
Will print the current tick duration.
 
   
== Pausing and Resuming ticks ==
+
== Getting Started ==
  +
In server CLI
 
  +
=== Commands List ===
  +
  +
Get the list of supported commands. When using server mods, there can be additional commands available that are not listed.
  +
<code>help()</code>
  +
  +
=== Command Details ===
  +
  +
Describe commands available for each command prefix: storage, map, bots, strongholds, system.
  +
<code>help(bots)</code>
  +
  +
== Manage Server ==
  +
  +
=== Pause Server Ticks ===
  +
  +
Pause the server to prevent ticks from running.
 
<code>system.pauseSimulation()</code>
 
<code>system.pauseSimulation()</code>
  +
Will pause the simulation ticking
 
  +
=== Resume Server Ticks ===
  +
  +
Resume the server to allow ticks to run.
 
<code>system.resumeSimulation()</code>
 
<code>system.resumeSimulation()</code>
Will resume the server ticking
 
   
== Setting GCL ==
+
=== Tick Rate ===
   
  +
Get the current tick duration.
In server CLI
 
  +
<code>system.getTickDuration()</code>
<code>storage.db['users'].update({ username: 'username' },{ $set: { gcl: 65000000000 }})</code>
 
   
== Setting RCL ==
+
=== Change Tick Rate ===
   
  +
Set the server tick duration to 1000 milliseconds per tick, default is 1000.
In server CLI
 
  +
<code>system.setTickDuration(1000)</code>
<code>storage.db['rooms.objects'].update({ _id: 'idOfController' },{ $set: { level: 8 }})</code>
 
   
== Setting Credits ==
+
== User Settings ==
   
  +
=== Global Control Level ===
In server CLI
 
<code>storage.db['users'].update({ username: 'username' },{ $set: { money: 2000000 }})</code>
 
   
  +
Change the GCL of a user.
== Setting Power ==
 
<code>storage.db['users'].update({ username: 'username' },{ $set: { power: 540000 }})</code>
+
<code>storage.db.users.update({ username: 'username' },{ $set: { gcl: 38000000 } })</code>
   
== Setting User CPU Limit ==
+
=== Global Power Level ===
   
  +
Change the GPL of a user.
In server CLI
 
<code>storage.db['users'].update({ username: 'username' },{ $set: { cpu: 500 }})</code>
+
<code>storage.db.users.update({ username: 'username' },{ $set: { power: 540000 } })</code>
   
== Adding a new room ==
+
=== Market Credits ===
   
  +
Change the credits of a user.
In server CLI
 
  +
<code>storage.db.users.update({ username: 'username' },{ $set: { money: 2000000 } })</code>
<code>map.generateRoom(roomName, options)</code>
 
   
  +
=== CPU Limit ===
for options use "help(map)" this will display the help data for map editing stuff
 
   
  +
Change the CPU limit of a user.
<code>map.generateRoom("W11N11", {sources: 13, controller: false})</code>
 
  +
<code>storage.db.users.update({ username: 'username' },{ $set: { cpu: 500 } })</code>
The above code for example will generate a room with 13 sources & no controller.
 
   
== Opening / closing a room ==
+
== Room Settings ==
   
  +
=== Controller Level ===
In server CLI
 
<code>map.openRoom("W5N1", [timestamp])</code>
 
   
  +
Change the room's controller level (RCL).
timestamp is optional<br>
 
  +
<code>storage.db['rooms.objects'].update({ _id: 'idOfController' },{ $set: { level: 8 } })</code>
e.g. on timestamp usage is to add: Date.now() + (300*1000)<br>
 
This will mean that the room will open in 5 minutes.
 
   
  +
=== Controller Progress ===
<code>map.closeRoom("W5N1")</code>
 
   
  +
Change the progress amount of a controller.
== Adding NPC Terminals ==
 
  +
<code>storage.db['rooms.objects'].update({ room: 'W7N3', type: 'controller' },{ $set: { progress: 10899000 } })</code>
   
  +
=== Remove Objects ===
In server CLI
 
<code>storage.db['rooms.objects'].insert({ type: 'terminal', room: 'W0N0', x: 0, y:0 })</code>
 
   
  +
Remove all [https://docs.screeps.com/api/#Ruin Ruins] from a room. This can be used to remove other game object types as well.
Repeat as many times as desired changing rooms (Use highway rooms or SK rooms)
 
  +
<code>storage.db['rooms.objects'].removeWhere({ type: 'ruin' })</code>
NPC orders should appear on the market automatically after a little while
 
   
== Adding PowerBank ==
+
== Resources ==
   
  +
=== Mineral Amount ===
In server CLI
 
<code>storage.db["rooms.objects"].insert({ room: "W4N10", type: "powerBank", x: 25, y: 25, store: {power: 4000}, hits: 10000, hitsMax: 10000, decayTime: 1000000 });</code>
 
   
  +
Change the available amount of a mineral.
== Manipulating Memory ==
 
  +
<code>storage.db['rooms.objects'].update({ type: 'mineral', room: 'W7N3' },{ $set: { mineralAmount: 250000 } })</code>
   
  +
=== Regenerate Mineral ===
In server CLI (you need the user id first)
 
<code>storage.env.get(storage.env.keys.MEMORY + '41dbd8207f1bf62');</code>
 
<code>storage.env.get('memory:41dbd8207f1bf62');</code>
 
   
  +
Reset the mineral regeneration time.
== Adding Portals ==
 
  +
<code>storage.db['rooms.objects'].update({ type: 'mineral' },{ $set: { nextRegenerationTime: 0 } })</code>
   
  +
=== Add Energy to Storage ===
Although it isn't required, it is likely that you will want to run this command at least twice to create a portal in each direction.
 
<code>storage.db["rooms.objects"].insert({ room: "W5N5", type: "portal", x: 25, y: 25, destination: { x: 25, y: 25, room: "E5N5" }, ticksToDecay: 100000 });</code>
 
   
  +
Add energy to a storage structure.
== Complete All Construction sites ==
 
  +
<code>storage.db['rooms.objects'].update({ type: 'storage', room: 'W7N3' },{ $set: { store: { energy: 100000 } } })</code>
   
  +
=== Add Minerals to Storage ===
This fills up the progress of all construction sites. As soon as a creep does any construction on them, they'll be done.
 
<code>storage.db['rooms.objects'].update({ type: 'constructionSite' },{ $set: { progress: 99999 }})</code>
 
   
  +
Add minerals to a storage structure.
== Add a Deposit ==
 
  +
<code>storage.db['rooms.objects'].update({ type: 'storage', room: 'W7N3' },{ $set: { store: { H: 25000, O: 25000, U: 25000, L: 25000, K: 25000, Z: 25000, X: 25000 } } })</code>
Add a [https://docs.screeps.com/api/#Deposit Deposit] into a room, change the depositType to change type of the deposit.
 
   
  +
== Construction Sites ==
<code>storage.db['rooms.objects'].insert({ type: 'deposit', room: 'W0N9', x: 16, y:26, depositType: 'mist' })</code>
 
== Reset The Server Data ==
 
Reset user data, rooms, GCL and PCL, server settings, etc.
 
   
  +
=== Max Construction Progress ===
  +
  +
Set max progress on all construction sites. As soon as a creep does any construction the structure will be built.
  +
<code>storage.db['rooms.objects'].update({ type: 'constructionSite' },{ $set: { progress: 99999 } })</code>
  +
  +
== Repair Structures ==
  +
  +
=== Repair Ramparts ===
  +
  +
Repair all rampart structures to 1M hit points.
  +
<code>storage.db['rooms.objects'].update({ type: 'rampart' },{ $set: { hits: 1000000 } })</code>
  +
  +
=== Repair a Rampart ===
  +
  +
Repair a single rampart structure by id.
  +
<code>storage.db['rooms.objects'].update({ _id: 'idOfRampart' },{ $set: { hits: 1000000 } })</code>
  +
  +
== Strongholds ==
  +
  +
=== Add Invader Core ===
  +
  +
Add an [https://docs.screeps.com/api/#StructureInvaderCore Invader Core] to a room. The number in the templateName is the stronghold level.
  +
<code>strongholds.spawn('W4N5', { templateName: 'bunker3' })</code>
  +
  +
=== Remove Invader Cores ===
  +
  +
Remove Invader Cores from all rooms.
  +
<code>storage.db['rooms.objects'].removeWhere({ type: 'invaderCore' })</code>
  +
  +
=== Add Invader Core Ruin ===
  +
  +
Add an Invader Core Ruin to a room. This can be used to prevent new invader cores from spawning in a room.
  +
<code>storage.db['rooms.objects'].insert({ room: 'W6N4', x: 25, y: 32, type: 'ruin', structure: { id: '652eb0d77373ad0040d22421', type: 'invaderCore', hits: 0, hitsMax: 100000, user: '2'}, user: '2', store: {}, destroyTime: 1, decayTime: 5000000 })</code>
  +
  +
== NPC Invaders ==
  +
  +
=== Spawn NPC Invader ===
  +
  +
Add a ranged attack NPC invader to a room.
  +
<code>storage.db['rooms.objects'].insert({ room: 'W6N3', x: 0, y: 11, type: 'creep', user: '2', name: 'invader_small_ranged', body: [{ type: 'tough', hits: 100 },{ type: 'tough', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'ranged_attack', hits: 100 },{ type: 'ranged_attack', hits: 100 },{ type: 'ranged_attack', hits: 100 },{ type: 'move', hits: 100 } ], hits: 1000, hitsMax: 1000, ticksToLive: 1500, fatigue: 0, store: {}, storeCapacity: 0 })</code>
  +
  +
Add a melee NPC invader to a room.
  +
<code>storage.db['rooms.objects'].insert({ room: 'W6N3', x: 1, y: 40, type: 'creep', user: '2', name: 'invader_small_melee', body: [{ type: 'tough', hits: 100 },{ type: 'tough', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'attack', hits: 100 },{ type: 'attack', hits: 100 },{ type: 'attack', hits: 100 },{ type: 'move', hits: 100 } ], hits: 1000, hitsMax: 1000, ticksToLive: 1500, fatigue: 0, store: {}, storeCapacity: 0 })</code>
  +
  +
Add a healer NPC invader to a room.
  +
<code>storage.db['rooms.objects'].insert({ room: 'W6N3', x: 1, y: 41, type: 'creep', user: '2', name: 'invader_small_healer', body: [{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'move', hits: 100 } ], hits: 1000, hitsMax: 1000, ticksToLive: 1500, fatigue: 0, store: {}, storeCapacity: 0 })</code>
  +
  +
== Map Commands ==
  +
  +
=== Insert New Room ===
  +
  +
Generate a new room and add it to the world.
  +
<code>map.generateRoom('W11N11', { sources: 2 })</code>
  +
  +
=== Open Room ===
  +
  +
Make a room available for use.
  +
<code>map.openRoom('W5N1')</code>
  +
  +
Open a room in 5 minutes.
  +
<code>map.openRoom('W5N1', Date.now() + 300 * 1000)</code>
  +
  +
=== Close Room ===
  +
  +
Make a room not available.
  +
<code>map.closeRoom('W5N1')</code>
  +
  +
=== Add NPC Terminals ===
  +
  +
Add a [https://docs.screeps.com/market.html#NPC-Terminals NPC Terminal] to a room. Repeat as many times as desired changing rooms (Use highway rooms or SK rooms). NPC orders should appear on the market automatically after a little while.
  +
<code>storage.db['rooms.objects'].insert({ room: 'W0N0', x: 0, y: 0, type: 'terminal' })</code>
  +
  +
=== Add Power Banks ===
  +
  +
Add a [https://docs.screeps.com/power.html#Power-Banks Power Bank] to a room.
  +
<code>storage.db['rooms.objects'].insert({ room: 'W4N10', x: 25, y: 25, type: 'powerBank', store: { power: 4000 }, hits: 10000, hitsMax: 10000, decayTime: 1000000 })</code>
  +
  +
=== Add Deposits ===
  +
  +
Add a [https://docs.screeps.com/api/#Deposit Deposit] to a room, change the depositType to change type of the deposit.
  +
<code>storage.db['rooms.objects'].insert({ room: 'W0N9', x: 16, y:26, type: 'deposit', depositType: 'mist' })</code>
  +
  +
=== Add Portals ===
  +
  +
Add a [https://docs.screeps.com/api/#StructurePortal Portal] to a room. Run this command twice and create portals going both directions for the best result.
  +
<code>storage.db['rooms.objects'].insert({ room: 'W5N5', x: 25, y: 25, type: 'portal', destination: { x: 25, y: 25, room: 'E5N5' }, ticksToDecay: 100000 })</code>
  +
  +
== Find Commands ==
  +
  +
=== Find Users ===
  +
  +
Find all users.
  +
<code>storage.db.users.find()</code>
  +
  +
=== Find a User ===
  +
  +
Find a user by their username to get data such as the user id.
  +
<code>storage.db.users.findOne({ username: 'username' })</code>
  +
  +
=== Find Room Objects ===
  +
  +
Find all room objects of a certain type.
  +
<code>storage.db['rooms.objects'].find({ room: 'W7N3', type: 'constructionSite' })</code>
  +
  +
== User Memory ==
  +
  +
=== Get User Memory ===
  +
  +
Get the memory of a user by their user id.
  +
<code>storage.env.get('memory:41dbd8207f1bf62')</code>
  +
  +
Alternatively you can find the user by their username and chain together the commands to get the memory.
  +
<code>storage.db.users.find({ username: 'username' }).then(([first]) => storage.env.get(storage.env.keys.MEMORY + first._id ))</code>
  +
  +
== Reset Server ==
  +
  +
=== Reset Server Data ===
  +
  +
Reset user data, rooms, GCL, GPL, server settings, etc.
 
<code>system.resetAllData()</code>
 
<code>system.resetAllData()</code>
== Disable Inactive Room Activity ==
 
Sometimes a server has an issue where all rooms are set as active for the system to process, instead of only those with player objects in them. It's unknown why this happens, and can result in the server running very slowly for no good reason. setting it as inactive will resolve the issue.
 
<nowiki>storage.db.rooms.update({ active: true }, { $set: { active: false }})</nowiki>
 
   
==Remove Invader Cores==
+
== Server Fixes ==
  +
Can also be used to delete <code>ruins</code> and other room objects
 
  +
=== Reset Room Activity ===
storage.db["rooms.objects"].removeWhere({type:"invaderCore"})
 
  +
  +
Occasionally, a server may encounter an issue where all rooms are set to active for processing, even those without player objects. The cause of this issue is unknown, but it can result in the server running slowly. By setting rooms to inactive, you can resolve this issue and improve server performance.
  +
<code>storage.db.rooms.update({ active: true }, { $set: { active: false } })</code>
  +
  +
=== Reset World Map Room Images ===
  +
  +
Regenerate room images for the world map.
  +
<code>storage.db.rooms.find().then(rooms => rooms.map(r => map.updateRoomImageAssets(r._id)))</code>

Revision as of 23:47, 20 April 2024

Server CLI Commands

Run these commands in the screeps server CLI to perform various tasks.

Getting Started

Commands List

Get the list of supported commands. When using server mods, there can be additional commands available that are not listed.

help()

Command Details

Describe commands available for each command prefix: storage, map, bots, strongholds, system.

help(bots)

Manage Server

Pause Server Ticks

Pause the server to prevent ticks from running.

system.pauseSimulation()

Resume Server Ticks

Resume the server to allow ticks to run.

system.resumeSimulation()

Tick Rate

Get the current tick duration.

system.getTickDuration()

Change Tick Rate

Set the server tick duration to 1000 milliseconds per tick, default is 1000.

system.setTickDuration(1000)

User Settings

Global Control Level

Change the GCL of a user.

storage.db.users.update({ username: 'username' },{ $set: { gcl: 38000000 } })

Global Power Level

Change the GPL of a user.

storage.db.users.update({ username: 'username' },{ $set: { power: 540000 } })

Market Credits

Change the credits of a user.

storage.db.users.update({ username: 'username' },{ $set: { money: 2000000 } })

CPU Limit

Change the CPU limit of a user.

storage.db.users.update({ username: 'username' },{ $set: { cpu: 500 } })

Room Settings

Controller Level

Change the room's controller level (RCL).

storage.db['rooms.objects'].update({ _id: 'idOfController' },{ $set: { level: 8 } })

Controller Progress

Change the progress amount of a controller.

storage.db['rooms.objects'].update({ room: 'W7N3', type: 'controller' },{ $set: { progress: 10899000 } })

Remove Objects

Remove all Ruins from a room. This can be used to remove other game object types as well.

storage.db['rooms.objects'].removeWhere({ type: 'ruin' })

Resources

Mineral Amount

Change the available amount of a mineral.

storage.db['rooms.objects'].update({ type: 'mineral', room: 'W7N3' },{ $set: { mineralAmount: 250000 } })

Regenerate Mineral

Reset the mineral regeneration time.

storage.db['rooms.objects'].update({ type: 'mineral' },{ $set: { nextRegenerationTime: 0 } })

Add Energy to Storage

Add energy to a storage structure.

storage.db['rooms.objects'].update({ type: 'storage', room: 'W7N3' },{ $set: { store: { energy: 100000 } } })

Add Minerals to Storage

Add minerals to a storage structure.

storage.db['rooms.objects'].update({ type: 'storage', room: 'W7N3' },{ $set: { store: { H: 25000, O: 25000, U: 25000, L: 25000, K: 25000, Z: 25000, X: 25000 } } })

Construction Sites

Max Construction Progress

Set max progress on all construction sites. As soon as a creep does any construction the structure will be built.

storage.db['rooms.objects'].update({ type: 'constructionSite' },{ $set: { progress: 99999 } })

Repair Structures

Repair Ramparts

Repair all rampart structures to 1M hit points.

storage.db['rooms.objects'].update({ type: 'rampart' },{ $set: { hits: 1000000 } })

Repair a Rampart

Repair a single rampart structure by id.

 storage.db['rooms.objects'].update({ _id: 'idOfRampart' },{ $set: { hits: 1000000 } })

Strongholds

Add Invader Core

Add an Invader Core to a room. The number in the templateName is the stronghold level.

strongholds.spawn('W4N5', { templateName: 'bunker3' })

Remove Invader Cores

Remove Invader Cores from all rooms.

storage.db['rooms.objects'].removeWhere({ type: 'invaderCore' })

Add Invader Core Ruin

Add an Invader Core Ruin to a room. This can be used to prevent new invader cores from spawning in a room.

storage.db['rooms.objects'].insert({ room: 'W6N4', x: 25, y: 32, type: 'ruin', structure: { id: '652eb0d77373ad0040d22421', type: 'invaderCore', hits: 0, hitsMax: 100000, user: '2'}, user: '2', store: {}, destroyTime: 1, decayTime: 5000000 })

NPC Invaders

Spawn NPC Invader

Add a ranged attack NPC invader to a room.

storage.db['rooms.objects'].insert({ room: 'W6N3', x: 0, y: 11, type: 'creep', user: '2', name: 'invader_small_ranged', body: [{ type: 'tough', hits: 100 },{ type: 'tough', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'ranged_attack', hits: 100 },{ type: 'ranged_attack', hits: 100 },{ type: 'ranged_attack', hits: 100 },{ type: 'move', hits: 100 } ], hits: 1000, hitsMax: 1000, ticksToLive: 1500, fatigue: 0, store: {}, storeCapacity: 0 })

Add a melee NPC invader to a room.

storage.db['rooms.objects'].insert({ room: 'W6N3', x: 1, y: 40, type: 'creep', user: '2', name: 'invader_small_melee', body: [{ type: 'tough', hits: 100 },{ type: 'tough', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'attack', hits: 100 },{ type: 'attack', hits: 100 },{ type: 'attack', hits: 100 },{ type: 'move', hits: 100 } ], hits: 1000, hitsMax: 1000, ticksToLive: 1500, fatigue: 0, store: {}, storeCapacity: 0 })

Add a healer NPC invader to a room.

storage.db['rooms.objects'].insert({ room: 'W6N3', x: 1, y: 41, type: 'creep', user: '2', name: 'invader_small_healer', body: [{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'move', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'heal', hits: 100 },{ type: 'move', hits: 100 } ], hits: 1000, hitsMax: 1000, ticksToLive: 1500, fatigue: 0, store: {}, storeCapacity: 0 })

Map Commands

Insert New Room

Generate a new room and add it to the world.

map.generateRoom('W11N11', { sources: 2 })

Open Room

Make a room available for use.

map.openRoom('W5N1')

Open a room in 5 minutes.

map.openRoom('W5N1', Date.now() + 300 * 1000)

Close Room

Make a room not available.

map.closeRoom('W5N1')

Add NPC Terminals

Add a NPC Terminal to a room. Repeat as many times as desired changing rooms (Use highway rooms or SK rooms). NPC orders should appear on the market automatically after a little while.

storage.db['rooms.objects'].insert({ room: 'W0N0', x: 0, y: 0, type: 'terminal' })

Add Power Banks

Add a Power Bank to a room.

storage.db['rooms.objects'].insert({ room: 'W4N10', x: 25, y: 25, type: 'powerBank', store: { power: 4000 }, hits: 10000, hitsMax: 10000, decayTime: 1000000 })

Add Deposits

Add a Deposit to a room, change the depositType to change type of the deposit.

storage.db['rooms.objects'].insert({ room: 'W0N9', x: 16, y:26, type: 'deposit', depositType: 'mist' })

Add Portals

Add a Portal to a room. Run this command twice and create portals going both directions for the best result.

storage.db['rooms.objects'].insert({ room: 'W5N5', x: 25, y: 25, type: 'portal', destination: { x: 25, y: 25, room: 'E5N5' }, ticksToDecay: 100000 })

Find Commands

Find Users

Find all users.

storage.db.users.find()

Find a User

Find a user by their username to get data such as the user id.

storage.db.users.findOne({ username: 'username' })

Find Room Objects

Find all room objects of a certain type.

storage.db['rooms.objects'].find({ room: 'W7N3', type: 'constructionSite' })

User Memory

Get User Memory

Get the memory of a user by their user id.

storage.env.get('memory:41dbd8207f1bf62')

Alternatively you can find the user by their username and chain together the commands to get the memory.

storage.db.users.find({ username: 'username' }).then(([first]) => storage.env.get(storage.env.keys.MEMORY + first._id ))

Reset Server

Reset Server Data

Reset user data, rooms, GCL, GPL, server settings, etc.

system.resetAllData()

Server Fixes

Reset Room Activity

Occasionally, a server may encounter an issue where all rooms are set to active for processing, even those without player objects. The cause of this issue is unknown, but it can result in the server running slowly. By setting rooms to inactive, you can resolve this issue and improve server performance.

storage.db.rooms.update({ active: true }, { $set: { active: false } })

Reset World Map Room Images

Regenerate room images for the world map.

storage.db.rooms.find().then(rooms => rooms.map(r => map.updateRoomImageAssets(r._id)))