diff --git a/dist/index.d.ts b/dist/index.d.ts index bd2f784..6ebdb23 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1199,7 +1199,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no ATTACK body parts in this creep’s body. */ - attack(target: AnyCreep | Structure): CreepActionReturnCode; + attack(target: AnyCreep | Structure): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Attack a controller. * @@ -1217,7 +1217,7 @@ interface Creep extends RoomObject { * - ERR_TIRED: You have to wait until the next attack is possible. * - ERR_NO_BODYPART: There are not enough CLAIM body parts in this creep’s body. */ - attackController(target: StructureController): CreepActionReturnCode; + attackController(target: StructureController): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_TIRED | ERR_NO_BODYPART; /** * Build a structure at the target construction site using carried energy. * @@ -1234,7 +1234,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - build(target: ConstructionSite): CreepActionReturnCode | ERR_NOT_ENOUGH_RESOURCES | ERR_RCL_NOT_ENOUGH; + build(target: ConstructionSite): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Cancel the order given during the current game tick. * @param methodName The name of a creep's method to be cancelled. @@ -1262,7 +1262,7 @@ interface Creep extends RoomObject { * - ERR_NO_BODYPART: There are no CLAIM body parts in this creep’s body. * - ERR_GCL_NOT_ENOUGH: Your Global Control Level is not enough. */ - claimController(target: StructureController): CreepActionReturnCode | ERR_FULL | ERR_GCL_NOT_ENOUGH; + claimController(target: StructureController): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_NO_BODYPART | ERR_GCL_NOT_ENOUGH; /** * Dismantles any structure that can be constructed (even hostile) returning 50% of the energy spent on its repair. * @@ -1278,7 +1278,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - dismantle(target: Structure): CreepActionReturnCode; + dismantle(target: Structure): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Drop this resource on the ground. * @@ -1291,7 +1291,7 @@ interface Creep extends RoomObject { * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of resources. * - ERR_INVALID_ARGS: The resourceType is not a valid RESOURCE_* constants. */ - drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES; + drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS; /** * Add one more available safe mode activation to a room controller. * @@ -1305,7 +1305,7 @@ interface Creep extends RoomObject { * - ERR_INVALID_TARGET: The target is not a valid controller object. * - ERR_NOT_IN_RANGE: The target is too far away. */ - generateSafeMode(target: StructureController): CreepActionReturnCode; + generateSafeMode(target: StructureController): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE; /** * Get the quantity of live body parts of the given type. * @@ -1333,7 +1333,7 @@ interface Creep extends RoomObject { * - ERR_TIRED: The extractor or the deposit is still cooling down. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - harvest(target: Source | Mineral | Deposit): CreepActionReturnCode | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES; + harvest(target: Source | Mineral | Deposit): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_TIRED | ERR_NO_BODYPART; /** * Heal self or another creep. * @@ -1351,7 +1351,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no HEAL body parts in this creep’s body. */ - heal(target: AnyCreep): CreepActionReturnCode; + heal(target: AnyCreep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Move the creep one square in the specified direction or towards a creep that is pulling it. * @@ -1367,7 +1367,7 @@ interface Creep extends RoomObject { * - ERR_TIRED: The fatigue indicator of the creep is non-zero. * - ERR_NO_BODYPART: There are no MOVE body parts in this creep’s body. */ - move(direction: DirectionConstant): CreepMoveReturnCode; + move(direction: DirectionConstant): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_ARGS | ERR_TIRED | ERR_NO_BODYPART; move(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Move the creep using the specified predefined path. @@ -1427,7 +1427,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CARRY body parts in this creep’s body. */ - pickup(target: Resource): CreepActionReturnCode | ERR_FULL; + pickup(target: Resource): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Allow another creep to follow this creep. * @@ -1461,7 +1461,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no RANGED_ATTACK body parts in this creep’s body. */ - rangedAttack(target: AnyCreep | Structure): CreepActionReturnCode; + rangedAttack(target: AnyCreep | Structure): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Heal another creep at a distance. * @@ -1477,7 +1477,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no HEAL body parts in this creep’s body. */ - rangedHeal(target: AnyCreep): CreepActionReturnCode; + rangedHeal(target: AnyCreep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * A ranged attack against all hostile creeps or structures within 3 squares range. * @@ -1503,7 +1503,9 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - repair(target: Structure): CreepActionReturnCode | ERR_NOT_ENOUGH_RESOURCES; + repair( + target: Structure, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Temporarily block a neutral controller from claiming by other players. * @@ -1521,7 +1523,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CLAIM body parts in this creep’s body. */ - reserveController(target: StructureController): CreepActionReturnCode; + reserveController(target: StructureController): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Display a visual speech balloon above the creep with the specified message. * @@ -1578,7 +1580,11 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ - transfer(target: AnyCreep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + transfer( + target: AnyCreep | Structure, + resourceType: ResourceConstant, + amount?: number, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Upgrade your controller to the next level using carried energy. * @@ -1600,7 +1606,9 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - upgradeController(target: StructureController): ScreepsReturnCode; + upgradeController( + target: StructureController, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Withdraw resources from a structure, a tombstone or a ruin. * @@ -1623,7 +1631,11 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ - withdraw(target: Structure | Tombstone | Ruin, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + withdraw( + target: Structure | Tombstone | Ruin, + resourceType: ResourceConstant, + amount?: number, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; } interface CreepConstructor extends _Constructor, _ConstructorById {} @@ -3443,7 +3455,7 @@ interface Market { * - OK: The operation has been scheduled successfully. * - ERR_INVALID_ARGS: The order ID is not valid. */ - cancelOrder(orderId: string): ScreepsReturnCode; + cancelOrder(orderId: string): OK | ERR_INVALID_ARGS; /** * Change the price of an existing order. * @@ -3456,7 +3468,7 @@ interface Market { * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ - changeOrderPrice(orderId: string, newPrice: number): ScreepsReturnCode; + changeOrderPrice(orderId: string, newPrice: number): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS; /** * Create a market order in your terminal. * @@ -3499,7 +3511,11 @@ interface Market { * - ERR_INVALID_ARGS: The arguments provided are invalid. * - ERR_TIRED: The target terminal is still cooling down. */ - deal(orderId: string, amount: number, yourRoomName?: string): ScreepsReturnCode; + deal( + orderId: string, + amount: number, + yourRoomName?: string, + ): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL | ERR_INVALID_ARGS | ERR_TIRED; /** * Add more capacity to an existing order. * @@ -3513,7 +3529,7 @@ interface Market { * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ - extendOrder(orderId: string, addAmount: number): ScreepsReturnCode; + extendOrder(orderId: string, addAmount: number): OK | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS; /** * Get other players' orders currently active on the market. * @param filter (optional) An object or function that will filter the resulting list using the lodash.filter method. @@ -3901,7 +3917,7 @@ interface CostMatrix { * @param y Y position in the room. * @param cost Cost of this position. Must be a whole number. A cost of 0 will use the terrain cost for that tile. A cost greater than or equal to 255 will be treated as unwalkable. */ - set(x: number, y: number, cost: number): undefined; + set(x: number, y: number, cost: number): void; /** * Get the cost of a position in this CostMatrix. * @param x X position in the room. @@ -4055,7 +4071,7 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of energy. * - ERR_INVALID_ARGS: The resourceType is not a valid {@link ResourceConstant RESOURCE_*} constants. */ - drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES; + drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS; /** * Enable power usage in this room. * @@ -4080,7 +4096,7 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_IN_RANGE: The target creep is too far away * - ERR_INVALID_ARGS: The provided direction is incorrect. */ - move(direction: DirectionConstant): CreepMoveReturnCode; + move(direction: DirectionConstant): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; move(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Move the creep using the specified predefined path. @@ -4094,7 +4110,7 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_FOUND: The specified path doesn't match the creep's location. * - ERR_INVALID_ARGS: path is not a valid path array. */ - moveByPath(path: PathStep[] | RoomPosition[] | string): CreepMoveReturnCode | ERR_NOT_FOUND | ERR_INVALID_ARGS; + moveByPath(path: PathStep[] | RoomPosition[] | string): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_FOUND | ERR_INVALID_ARGS; /** * Find the optimal path to the target within the same room and move to it. * @@ -4117,7 +4133,7 @@ interface PowerCreep extends RoomObject { moveTo( target: RoomPosition | { pos: RoomPosition }, opts?: MoveToOpts, - ): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET | ERR_NOT_FOUND; + ): OK | ERR_NOT_OWNER | ERR_NO_PATH | ERR_BUSY | ERR_NOT_FOUND | ERR_INVALID_TARGET; /** * Toggle auto notification when the creep is under attack. * @@ -4143,7 +4159,7 @@ interface PowerCreep extends RoomObject { * - ERR_FULL: The creep cannot receive any more resource. * - ERR_NOT_IN_RANGE: The target is too far away. */ - pickup(target: Resource): CreepActionReturnCode | ERR_FULL; + pickup(target: Resource): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE; /** * Rename the power creep. * @@ -4221,7 +4237,11 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ - transfer(target: AnyCreep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + transfer( + target: AnyCreep | Structure, + resourceType: ResourceConstant, + amount?: number, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Upgrade the creep, adding a new power ability to it or increasing the level of the existing power. * @@ -4252,7 +4272,20 @@ interface PowerCreep extends RoomObject { * - ERR_TIRED: The power ability is still on cooldown. * - ERR_NO_BODYPART: The creep doesn't have the specified power ability. */ - usePower(power: PowerConstant, target?: RoomObject): ScreepsReturnCode; + usePower( + power: PowerConstant, + target?: RoomObject, + ): + | OK + | ERR_NOT_OWNER + | ERR_BUSY + | ERR_NOT_ENOUGH_RESOURCES + | ERR_INVALID_TARGET + | ERR_FULL + | ERR_NOT_IN_RANGE + | ERR_INVALID_ARGS + | ERR_TIRED + | ERR_NO_BODYPART; /** * Withdraw resources from a structure, tombstone, or ruin. * @@ -4274,7 +4307,11 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ - withdraw(target: Structure | Tombstone | Ruin, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + withdraw( + target: Structure | Tombstone | Ruin, + resourceType: ResourceConstant, + amount?: number, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; } interface PowerCreepConstructor extends _Constructor, _ConstructorById { @@ -4368,7 +4405,7 @@ interface RawMemory { * @param ids An array of segment IDs. * @throws if `ids` isn't an array, more than 10 segments are active, or the ids aren't all integers. */ - setActiveSegments(ids: number[]): undefined; + setActiveSegments(ids: number[]): void; /** * Request a memory segment of another user. * @@ -4546,7 +4583,9 @@ interface RoomPosition { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(structureType: BuildableStructureConstant): ScreepsReturnCode; + createConstructionSite( + structureType: BuildableStructureConstant, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create a new {@link ConstructionSite} at the specified location. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. @@ -4559,7 +4598,10 @@ interface RoomPosition { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; + createConstructionSite( + structureType: STRUCTURE_SPAWN, + name?: string, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create a new {@link Flag} at the specified location. * @param name The name of a new flag. @@ -5093,7 +5135,11 @@ interface Room { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(x: number, y: number, structureType: BuildableStructureConstant): ScreepsReturnCode; + createConstructionSite( + x: number, + y: number, + structureType: BuildableStructureConstant, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create new {@link ConstructionSite} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. @@ -5106,7 +5152,10 @@ interface Room { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(pos: RoomPosition | _HasRoomPosition, structureType: StructureConstant): ScreepsReturnCode; + createConstructionSite( + pos: RoomPosition | _HasRoomPosition, + structureType: StructureConstant, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create new {@link ConstructionSite} at the specified location. * @param x The X position @@ -5120,7 +5169,12 @@ interface Room { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(x: number, y: number, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; + createConstructionSite( + x: number, + y: number, + structureType: STRUCTURE_SPAWN, + name?: string, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create new {@link ConstructionSite} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. @@ -5133,7 +5187,11 @@ interface Room { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(pos: RoomPosition | _HasRoomPosition, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; + createConstructionSite( + pos: RoomPosition | _HasRoomPosition, + structureType: STRUCTURE_SPAWN, + name?: string, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create new {@link Flag} at the specified location. * @param x The X position. @@ -5158,7 +5216,7 @@ interface Room { name?: string, color?: ColorConstant, secondaryColor?: ColorConstant, - ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; + ): ERR_NAME_EXISTS | ERR_FULL | ERR_INVALID_ARGS | string; /** * Create new {@link Flag} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. @@ -5181,7 +5239,7 @@ interface Room { name?: string, color?: ColorConstant, secondaryColor?: ColorConstant, - ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; + ): ERR_NAME_EXISTS | ERR_FULL | ERR_INVALID_ARGS | string; /** * Find all objects of the specified type in the room. * @param type One of the {@link FindConstant FIND_*} constants. @@ -5256,13 +5314,13 @@ interface Room { * @param y The Y position. * @returns An array of objects of the requested type at the given position, or ERR_INVALID_ARGS. */ - lookForAt(type: T, x: number, y: number): Array; + lookForAt(type: T, x: number, y: number): Array | ERR_INVALID_ARGS; /** * Get the objects at the given position. * * @param type One of the {@link LookConstant LOOK_*} constants. * @param target A RoomPosition. Its room name will be ignored. - * @returns An array of objects of the requested type at the given position, or ERR_INVALID_ARGS. + * @returns An array of objects of the requested type at the given position. */ lookForAt(type: T, target: RoomPosition | _HasRoomPosition): Array; /** @@ -5476,7 +5534,10 @@ interface StructureSpawn extends OwnedStructure { * - ERR_INVALID_ARGS: Body is not properly described. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ - canCreateCreep(body: BodyPartConstant[], name?: string): ScreepsReturnCode; + canCreateCreep( + body: BodyPartConstant[], + name?: string, + ): OK | ERR_NOT_OWNER | ERR_NAME_EXISTS | ERR_BUSY | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Start the creep spawning process. * @@ -5504,7 +5565,12 @@ interface StructureSpawn extends OwnedStructure { * - ERR_INVALID_ARGS: Body is not properly described. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is not enough to use this spawn. */ - createCreep(body: BodyPartConstant[], name?: string, memory?: CreepMemory): ScreepsReturnCode | string; + createCreep( + body: BodyPartConstant[], + name?: string, + memory?: CreepMemory, + ): string | ERR_NOT_OWNER | ERR_NAME_EXISTS | ERR_BUSY | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; + /** * Start the creep spawning process. The required energy amount can be withdrawn from all spawns and extensions in the room. * @@ -5550,7 +5616,9 @@ interface StructureSpawn extends OwnedStructure { * - ERR_NOT_IN_RANGE: The target creep is too far away. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ - renewCreep(target: Creep): ScreepsReturnCode; + renewCreep( + target: Creep, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_RCL_NOT_ENOUGH; /** * Kill the creep and drop up to 100% of resources spent on its spawning and boosting depending on remaining life time. * @@ -5564,7 +5632,7 @@ interface StructureSpawn extends OwnedStructure { * - ERR_NOT_IN_RANGE: The target creep is too far away. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ - recycleCreep(target: Creep): ScreepsReturnCode; + recycleCreep(target: Creep): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_RCL_NOT_ENOUGH; } interface StructureSpawnConstructor extends _Constructor, _ConstructorById { @@ -5613,7 +5681,7 @@ interface Spawning { * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn. */ - cancel(): ScreepsReturnCode & (OK | ERR_NOT_OWNER); + cancel(): OK | ERR_NOT_OWNER; /** * Set allowed directions the creep can move when spawned. @@ -5624,7 +5692,7 @@ interface Spawning { * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_INVALID_ARGS: The directions is array is invalid. */ - setDirections(directions: DirectionConstant[]): ScreepsReturnCode & (OK | ERR_NOT_OWNER | ERR_INVALID_ARGS); + setDirections(directions: DirectionConstant[]): OK | ERR_NOT_OWNER | ERR_INVALID_ARGS; } /** @@ -5789,7 +5857,7 @@ interface Structure extends Roo * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_BUSY: Hostile creeps are in the room. */ - destroy(): ScreepsReturnCode; + destroy(): OK | ERR_NOT_OWNER | ERR_BUSY; /** * Check whether this structure can be used. If the room controller level is not enough, then this method will return false, and the structure will be highlighted with red in the game. */ @@ -5802,7 +5870,7 @@ interface Structure extends Roo * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_INVALID_ARGS: enable argument is not a boolean value. */ - notifyWhenAttacked(enabled: boolean): ScreepsReturnCode; + notifyWhenAttacked(enabled: boolean): OK | ERR_NOT_OWNER | ERR_INVALID_ARGS; } interface StructureConstructor extends _Constructor, _ConstructorById {} @@ -5907,14 +5975,14 @@ interface StructureController extends OwnedStructure { * - ERR_NOT_ENOUGH_RESOURCES: There is no safe mode activations available. * - ERR_TIRED: The previous safe mode is still cooling down, or the controller is upgradeBlocked, or the controller is downgraded for 50% plus 5000 ticks or more. */ - activateSafeMode(): ScreepsReturnCode; + activateSafeMode(): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_TIRED; /** * Make your claimed controller neutral again. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this controller. */ - unclaim(): ScreepsReturnCode; + unclaim(): OK | ERR_NOT_OWNER; } interface StructureControllerConstructor extends _Constructor, _ConstructorById {} @@ -5995,7 +6063,7 @@ interface StructureLink extends OwnedStructure { * - ERR_TIRED: The link is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this link. */ - transferEnergy(target: StructureLink, amount?: number): ScreepsReturnCode; + transferEnergy(target: StructureLink, amount?: number): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; } interface StructureLinkConstructor extends _Constructor, _ConstructorById {} @@ -6039,7 +6107,7 @@ interface StructureObserver extends OwnedStructure { * - ERR_INVALID_ARGS: roomName argument is not a valid room name value. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - observeRoom(roomName: string): ScreepsReturnCode; + observeRoom(roomName: string): OK | ERR_NOT_OWNER | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; } interface StructureObserverConstructor extends _Constructor, _ConstructorById {} @@ -6112,7 +6180,7 @@ interface StructurePowerSpawn extends OwnedStructure { * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have enough energy or power resource units. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - processPower(): ScreepsReturnCode; + processPower(): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_RCL_NOT_ENOUGH; } interface StructurePowerSpawnConstructor extends _Constructor, _ConstructorById {} @@ -6148,7 +6216,7 @@ interface StructureRampart extends OwnedStructure { * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. */ - setPublic(isPublic: boolean): undefined; + setPublic(isPublic: boolean): OK | ERR_NOT_OWNER; } interface StructureRampartConstructor extends _Constructor, _ConstructorById {} @@ -6232,7 +6300,7 @@ interface StructureTower extends OwnedStructure { * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - attack(target: AnyCreep | Structure): ScreepsReturnCode; + attack(target: AnyCreep | Structure): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_RCL_NOT_ENOUGH; /** * Remotely heal any creep in the room. * @@ -6245,7 +6313,7 @@ interface StructureTower extends OwnedStructure { * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - heal(target: AnyCreep): ScreepsReturnCode; + heal(target: AnyCreep): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_RCL_NOT_ENOUGH; /** * Remotely repair any structure in the room. * @@ -6258,7 +6326,7 @@ interface StructureTower extends OwnedStructure { * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - repair(target: Structure): ScreepsReturnCode; + repair(target: Structure): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_RCL_NOT_ENOUGH; } interface StructureTowerConstructor extends _Constructor, _ConstructorById {} @@ -6352,7 +6420,7 @@ interface StructureLab extends OwnedStructure { * - ERR_NOT_IN_RANGE: The targets are too far away. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - boostCreep(creep: Creep, bodyPartsCount?: number): ScreepsReturnCode; + boostCreep(creep: Creep, bodyPartsCount?: number): OK | ERR_NOT_OWNER | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_RCL_NOT_ENOUGH; /** * Unboost a creep. * @@ -6369,7 +6437,7 @@ interface StructureLab extends OwnedStructure { * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - unboostCreep(creep: Creep): ScreepsReturnCode; + unboostCreep(creep: Creep): OK | ERR_NOT_OWNER | ERR_NOT_FOUND | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_TIRED | ERR_RCL_NOT_ENOUGH; /** * Breaks mineral compounds back into reagents. * @@ -6387,7 +6455,7 @@ interface StructureLab extends OwnedStructure { * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - reverseReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; + reverseReaction(lab1: StructureLab, lab2: StructureLab): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; /** * Produce mineral compounds using reagents from two another labs. * @@ -6405,7 +6473,7 @@ interface StructureLab extends OwnedStructure { * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - runReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; + runReaction(lab1: StructureLab, lab2: StructureLab): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; } interface StructureLabConstructor extends _Constructor, _ConstructorById {} @@ -6443,7 +6511,7 @@ interface StructureTerminal extends OwnedStructure { * - ERR_INVALID_ARGS: The arguments provided are incorrect. * - ERR_TIRED: The terminal is still cooling down. */ - send(resourceType: ResourceConstant, amount: number, destination: string, description?: string): ScreepsReturnCode; + send(resourceType: ResourceConstant, amount: number, destination: string, description?: string): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS | ERR_TIRED; } interface StructureTerminalConstructor extends _Constructor, _ConstructorById {} @@ -6530,13 +6598,18 @@ interface StructureNuker extends OwnedStructure { * - ERR_TIRED: This structure is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - launchNuke(pos: RoomPosition): ScreepsReturnCode; + launchNuke(pos: RoomPosition): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; } interface StructureNukerConstructor extends _Constructor, _ConstructorById {} declare const StructureNuker: StructureNukerConstructor; +interface PortalDestination { + shard: string; + room: string +} + /** * A non-player structure. * @@ -6552,7 +6625,7 @@ interface StructurePortal extends Structure { * If this is an inter-shard portal, then this property contains an object with shard and room string properties. * Exact coordinates are undetermined, the creep will appear at any free spot in the destination room. */ - destination: RoomPosition | { shard: string; room: string }; + destination: RoomPosition | PortalDestination; /** * The amount of game ticks when the portal disappears, or undefined when the portal is stable. */ @@ -6599,7 +6672,7 @@ interface StructureFactory extends OwnedStructure { * - ERR_TIRED: The factory is still cooling down. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use the factory. */ - produce(resource: CommoditiesTypes): ScreepsReturnCode; + produce(resource: CommoditiesTypes): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; } interface StructureFactoryConstructor extends _Constructor, _ConstructorById {} diff --git a/dist/screeps-tests.ts b/dist/screeps-tests.ts index ef86142..282d319 100644 --- a/dist/screeps-tests.ts +++ b/dist/screeps-tests.ts @@ -609,7 +609,7 @@ function resources(o: GenericStore): ResourceConstant[] { const exits = room.find(FIND_EXIT); const creepsHere = room.lookForAt(LOOK_CREEPS, 10, 10); - creepsHere[0].getActiveBodyparts(ATTACK); + if (creepsHere !== ERR_INVALID_ARGS) creepsHere[0].getActiveBodyparts(ATTACK); const towers = room.find(FIND_MY_STRUCTURES, { filter: (structure) => { diff --git a/src/creep.ts b/src/creep.ts index b535ada..266c784 100644 --- a/src/creep.ts +++ b/src/creep.ts @@ -125,7 +125,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no ATTACK body parts in this creep’s body. */ - attack(target: AnyCreep | Structure): CreepActionReturnCode; + attack(target: AnyCreep | Structure): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Attack a controller. * @@ -143,7 +143,7 @@ interface Creep extends RoomObject { * - ERR_TIRED: You have to wait until the next attack is possible. * - ERR_NO_BODYPART: There are not enough CLAIM body parts in this creep’s body. */ - attackController(target: StructureController): CreepActionReturnCode; + attackController(target: StructureController): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_TIRED | ERR_NO_BODYPART; /** * Build a structure at the target construction site using carried energy. * @@ -160,7 +160,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - build(target: ConstructionSite): CreepActionReturnCode | ERR_NOT_ENOUGH_RESOURCES | ERR_RCL_NOT_ENOUGH; + build(target: ConstructionSite): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Cancel the order given during the current game tick. * @param methodName The name of a creep's method to be cancelled. @@ -188,7 +188,7 @@ interface Creep extends RoomObject { * - ERR_NO_BODYPART: There are no CLAIM body parts in this creep’s body. * - ERR_GCL_NOT_ENOUGH: Your Global Control Level is not enough. */ - claimController(target: StructureController): CreepActionReturnCode | ERR_FULL | ERR_GCL_NOT_ENOUGH; + claimController(target: StructureController): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_NO_BODYPART | ERR_GCL_NOT_ENOUGH; /** * Dismantles any structure that can be constructed (even hostile) returning 50% of the energy spent on its repair. * @@ -204,7 +204,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - dismantle(target: Structure): CreepActionReturnCode; + dismantle(target: Structure): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Drop this resource on the ground. * @@ -217,7 +217,7 @@ interface Creep extends RoomObject { * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of resources. * - ERR_INVALID_ARGS: The resourceType is not a valid RESOURCE_* constants. */ - drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES; + drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS; /** * Add one more available safe mode activation to a room controller. * @@ -231,7 +231,7 @@ interface Creep extends RoomObject { * - ERR_INVALID_TARGET: The target is not a valid controller object. * - ERR_NOT_IN_RANGE: The target is too far away. */ - generateSafeMode(target: StructureController): CreepActionReturnCode; + generateSafeMode(target: StructureController): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE; /** * Get the quantity of live body parts of the given type. * @@ -259,7 +259,7 @@ interface Creep extends RoomObject { * - ERR_TIRED: The extractor or the deposit is still cooling down. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - harvest(target: Source | Mineral | Deposit): CreepActionReturnCode | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES; + harvest(target: Source | Mineral | Deposit): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_TIRED | ERR_NO_BODYPART; /** * Heal self or another creep. * @@ -277,7 +277,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no HEAL body parts in this creep’s body. */ - heal(target: AnyCreep): CreepActionReturnCode; + heal(target: AnyCreep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Move the creep one square in the specified direction or towards a creep that is pulling it. * @@ -293,7 +293,7 @@ interface Creep extends RoomObject { * - ERR_TIRED: The fatigue indicator of the creep is non-zero. * - ERR_NO_BODYPART: There are no MOVE body parts in this creep’s body. */ - move(direction: DirectionConstant): CreepMoveReturnCode; + move(direction: DirectionConstant): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_ARGS | ERR_TIRED | ERR_NO_BODYPART; move(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Move the creep using the specified predefined path. @@ -353,7 +353,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CARRY body parts in this creep’s body. */ - pickup(target: Resource): CreepActionReturnCode | ERR_FULL; + pickup(target: Resource): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Allow another creep to follow this creep. * @@ -387,7 +387,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no RANGED_ATTACK body parts in this creep’s body. */ - rangedAttack(target: AnyCreep | Structure): CreepActionReturnCode; + rangedAttack(target: AnyCreep | Structure): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Heal another creep at a distance. * @@ -403,7 +403,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no HEAL body parts in this creep’s body. */ - rangedHeal(target: AnyCreep): CreepActionReturnCode; + rangedHeal(target: AnyCreep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * A ranged attack against all hostile creeps or structures within 3 squares range. * @@ -429,7 +429,9 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - repair(target: Structure): CreepActionReturnCode | ERR_NOT_ENOUGH_RESOURCES; + repair( + target: Structure, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Temporarily block a neutral controller from claiming by other players. * @@ -447,7 +449,7 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CLAIM body parts in this creep’s body. */ - reserveController(target: StructureController): CreepActionReturnCode; + reserveController(target: StructureController): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Display a visual speech balloon above the creep with the specified message. * @@ -504,7 +506,11 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ - transfer(target: AnyCreep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + transfer( + target: AnyCreep | Structure, + resourceType: ResourceConstant, + amount?: number, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Upgrade your controller to the next level using carried energy. * @@ -526,7 +532,9 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ - upgradeController(target: StructureController): ScreepsReturnCode; + upgradeController( + target: StructureController, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * Withdraw resources from a structure, a tombstone or a ruin. * @@ -549,7 +557,11 @@ interface Creep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ - withdraw(target: Structure | Tombstone | Ruin, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + withdraw( + target: Structure | Tombstone | Ruin, + resourceType: ResourceConstant, + amount?: number, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; } interface CreepConstructor extends _Constructor, _ConstructorById {} diff --git a/src/market.ts b/src/market.ts index 5dd7de2..cd329a8 100644 --- a/src/market.ts +++ b/src/market.ts @@ -47,7 +47,7 @@ interface Market { * - OK: The operation has been scheduled successfully. * - ERR_INVALID_ARGS: The order ID is not valid. */ - cancelOrder(orderId: string): ScreepsReturnCode; + cancelOrder(orderId: string): OK | ERR_INVALID_ARGS; /** * Change the price of an existing order. * @@ -60,7 +60,7 @@ interface Market { * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ - changeOrderPrice(orderId: string, newPrice: number): ScreepsReturnCode; + changeOrderPrice(orderId: string, newPrice: number): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS; /** * Create a market order in your terminal. * @@ -103,7 +103,11 @@ interface Market { * - ERR_INVALID_ARGS: The arguments provided are invalid. * - ERR_TIRED: The target terminal is still cooling down. */ - deal(orderId: string, amount: number, yourRoomName?: string): ScreepsReturnCode; + deal( + orderId: string, + amount: number, + yourRoomName?: string, + ): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL | ERR_INVALID_ARGS | ERR_TIRED; /** * Add more capacity to an existing order. * @@ -117,7 +121,7 @@ interface Market { * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ - extendOrder(orderId: string, addAmount: number): ScreepsReturnCode; + extendOrder(orderId: string, addAmount: number): OK | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS; /** * Get other players' orders currently active on the market. * @param filter (optional) An object or function that will filter the resulting list using the lodash.filter method. diff --git a/src/path-finder.ts b/src/path-finder.ts index 19799f1..6c376bd 100644 --- a/src/path-finder.ts +++ b/src/path-finder.ts @@ -155,7 +155,7 @@ interface CostMatrix { * @param y Y position in the room. * @param cost Cost of this position. Must be a whole number. A cost of 0 will use the terrain cost for that tile. A cost greater than or equal to 255 will be treated as unwalkable. */ - set(x: number, y: number, cost: number): undefined; + set(x: number, y: number, cost: number): void; /** * Get the cost of a position in this CostMatrix. * @param x X position in the room. diff --git a/src/power-creep.ts b/src/power-creep.ts index 9f80114..0c0f6ca 100644 --- a/src/power-creep.ts +++ b/src/power-creep.ts @@ -134,7 +134,7 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of energy. * - ERR_INVALID_ARGS: The resourceType is not a valid {@link ResourceConstant RESOURCE_*} constants. */ - drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES; + drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS; /** * Enable power usage in this room. * @@ -159,7 +159,7 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_IN_RANGE: The target creep is too far away * - ERR_INVALID_ARGS: The provided direction is incorrect. */ - move(direction: DirectionConstant): CreepMoveReturnCode; + move(direction: DirectionConstant): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; move(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Move the creep using the specified predefined path. @@ -173,7 +173,7 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_FOUND: The specified path doesn't match the creep's location. * - ERR_INVALID_ARGS: path is not a valid path array. */ - moveByPath(path: PathStep[] | RoomPosition[] | string): CreepMoveReturnCode | ERR_NOT_FOUND | ERR_INVALID_ARGS; + moveByPath(path: PathStep[] | RoomPosition[] | string): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_FOUND | ERR_INVALID_ARGS; /** * Find the optimal path to the target within the same room and move to it. * @@ -196,7 +196,7 @@ interface PowerCreep extends RoomObject { moveTo( target: RoomPosition | { pos: RoomPosition }, opts?: MoveToOpts, - ): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET | ERR_NOT_FOUND; + ): OK | ERR_NOT_OWNER | ERR_NO_PATH | ERR_BUSY | ERR_NOT_FOUND | ERR_INVALID_TARGET; /** * Toggle auto notification when the creep is under attack. * @@ -222,7 +222,7 @@ interface PowerCreep extends RoomObject { * - ERR_FULL: The creep cannot receive any more resource. * - ERR_NOT_IN_RANGE: The target is too far away. */ - pickup(target: Resource): CreepActionReturnCode | ERR_FULL; + pickup(target: Resource): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE; /** * Rename the power creep. * @@ -300,7 +300,11 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ - transfer(target: AnyCreep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + transfer( + target: AnyCreep | Structure, + resourceType: ResourceConstant, + amount?: number, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Upgrade the creep, adding a new power ability to it or increasing the level of the existing power. * @@ -331,7 +335,20 @@ interface PowerCreep extends RoomObject { * - ERR_TIRED: The power ability is still on cooldown. * - ERR_NO_BODYPART: The creep doesn't have the specified power ability. */ - usePower(power: PowerConstant, target?: RoomObject): ScreepsReturnCode; + usePower( + power: PowerConstant, + target?: RoomObject, + ): + | OK + | ERR_NOT_OWNER + | ERR_BUSY + | ERR_NOT_ENOUGH_RESOURCES + | ERR_INVALID_TARGET + | ERR_FULL + | ERR_NOT_IN_RANGE + | ERR_INVALID_ARGS + | ERR_TIRED + | ERR_NO_BODYPART; /** * Withdraw resources from a structure, tombstone, or ruin. * @@ -353,7 +370,11 @@ interface PowerCreep extends RoomObject { * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ - withdraw(target: Structure | Tombstone | Ruin, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + withdraw( + target: Structure | Tombstone | Ruin, + resourceType: ResourceConstant, + amount?: number, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; } interface PowerCreepConstructor extends _Constructor, _ConstructorById { diff --git a/src/raw-memory.ts b/src/raw-memory.ts index 6b9ba86..8a46a2a 100644 --- a/src/raw-memory.ts +++ b/src/raw-memory.ts @@ -56,7 +56,7 @@ interface RawMemory { * @param ids An array of segment IDs. * @throws if `ids` isn't an array, more than 10 segments are active, or the ids aren't all integers. */ - setActiveSegments(ids: number[]): undefined; + setActiveSegments(ids: number[]): void; /** * Request a memory segment of another user. * diff --git a/src/room-position.ts b/src/room-position.ts index bcfc2da..afa7834 100644 --- a/src/room-position.ts +++ b/src/room-position.ts @@ -31,7 +31,9 @@ interface RoomPosition { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(structureType: BuildableStructureConstant): ScreepsReturnCode; + createConstructionSite( + structureType: BuildableStructureConstant, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create a new {@link ConstructionSite} at the specified location. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. @@ -44,7 +46,10 @@ interface RoomPosition { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; + createConstructionSite( + structureType: STRUCTURE_SPAWN, + name?: string, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create a new {@link Flag} at the specified location. * @param name The name of a new flag. diff --git a/src/room.ts b/src/room.ts index a6a2221..87bfdff 100644 --- a/src/room.ts +++ b/src/room.ts @@ -65,7 +65,11 @@ interface Room { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(x: number, y: number, structureType: BuildableStructureConstant): ScreepsReturnCode; + createConstructionSite( + x: number, + y: number, + structureType: BuildableStructureConstant, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create new {@link ConstructionSite} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. @@ -78,7 +82,10 @@ interface Room { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(pos: RoomPosition | _HasRoomPosition, structureType: StructureConstant): ScreepsReturnCode; + createConstructionSite( + pos: RoomPosition | _HasRoomPosition, + structureType: StructureConstant, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create new {@link ConstructionSite} at the specified location. * @param x The X position @@ -92,7 +99,12 @@ interface Room { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(x: number, y: number, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; + createConstructionSite( + x: number, + y: number, + structureType: STRUCTURE_SPAWN, + name?: string, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create new {@link ConstructionSite} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. @@ -105,7 +117,11 @@ interface Room { * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ - createConstructionSite(pos: RoomPosition | _HasRoomPosition, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; + createConstructionSite( + pos: RoomPosition | _HasRoomPosition, + structureType: STRUCTURE_SPAWN, + name?: string, + ): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Create new {@link Flag} at the specified location. * @param x The X position. @@ -130,7 +146,7 @@ interface Room { name?: string, color?: ColorConstant, secondaryColor?: ColorConstant, - ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; + ): ERR_NAME_EXISTS | ERR_FULL | ERR_INVALID_ARGS | string; /** * Create new {@link Flag} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. @@ -153,7 +169,7 @@ interface Room { name?: string, color?: ColorConstant, secondaryColor?: ColorConstant, - ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; + ): ERR_NAME_EXISTS | ERR_FULL | ERR_INVALID_ARGS | string; /** * Find all objects of the specified type in the room. * @param type One of the {@link FindConstant FIND_*} constants. @@ -228,13 +244,13 @@ interface Room { * @param y The Y position. * @returns An array of objects of the requested type at the given position, or ERR_INVALID_ARGS. */ - lookForAt(type: T, x: number, y: number): Array; + lookForAt(type: T, x: number, y: number): Array | ERR_INVALID_ARGS; /** * Get the objects at the given position. * * @param type One of the {@link LookConstant LOOK_*} constants. * @param target A RoomPosition. Its room name will be ignored. - * @returns An array of objects of the requested type at the given position, or ERR_INVALID_ARGS. + * @returns An array of objects of the requested type at the given position. */ lookForAt(type: T, target: RoomPosition | _HasRoomPosition): Array; /** diff --git a/src/spawn.ts b/src/spawn.ts index 3445ff3..3855020 100644 --- a/src/spawn.ts +++ b/src/spawn.ts @@ -81,7 +81,10 @@ interface StructureSpawn extends OwnedStructure { * - ERR_INVALID_ARGS: Body is not properly described. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ - canCreateCreep(body: BodyPartConstant[], name?: string): ScreepsReturnCode; + canCreateCreep( + body: BodyPartConstant[], + name?: string, + ): OK | ERR_NOT_OWNER | ERR_NAME_EXISTS | ERR_BUSY | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; /** * Start the creep spawning process. * @@ -109,7 +112,12 @@ interface StructureSpawn extends OwnedStructure { * - ERR_INVALID_ARGS: Body is not properly described. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is not enough to use this spawn. */ - createCreep(body: BodyPartConstant[], name?: string, memory?: CreepMemory): ScreepsReturnCode | string; + createCreep( + body: BodyPartConstant[], + name?: string, + memory?: CreepMemory, + ): string | ERR_NOT_OWNER | ERR_NAME_EXISTS | ERR_BUSY | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; + /** * Start the creep spawning process. The required energy amount can be withdrawn from all spawns and extensions in the room. * @@ -155,7 +163,9 @@ interface StructureSpawn extends OwnedStructure { * - ERR_NOT_IN_RANGE: The target creep is too far away. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ - renewCreep(target: Creep): ScreepsReturnCode; + renewCreep( + target: Creep, + ): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_RCL_NOT_ENOUGH; /** * Kill the creep and drop up to 100% of resources spent on its spawning and boosting depending on remaining life time. * @@ -169,7 +179,7 @@ interface StructureSpawn extends OwnedStructure { * - ERR_NOT_IN_RANGE: The target creep is too far away. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ - recycleCreep(target: Creep): ScreepsReturnCode; + recycleCreep(target: Creep): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_RCL_NOT_ENOUGH; } interface StructureSpawnConstructor extends _Constructor, _ConstructorById { @@ -218,7 +228,7 @@ interface Spawning { * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn. */ - cancel(): ScreepsReturnCode & (OK | ERR_NOT_OWNER); + cancel(): OK | ERR_NOT_OWNER; /** * Set allowed directions the creep can move when spawned. @@ -229,7 +239,7 @@ interface Spawning { * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_INVALID_ARGS: The directions is array is invalid. */ - setDirections(directions: DirectionConstant[]): ScreepsReturnCode & (OK | ERR_NOT_OWNER | ERR_INVALID_ARGS); + setDirections(directions: DirectionConstant[]): OK | ERR_NOT_OWNER | ERR_INVALID_ARGS; } /** diff --git a/src/structure.ts b/src/structure.ts index c523c83..adbc24c 100644 --- a/src/structure.ts +++ b/src/structure.ts @@ -36,7 +36,7 @@ interface Structure extends Roo * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_BUSY: Hostile creeps are in the room. */ - destroy(): ScreepsReturnCode; + destroy(): OK | ERR_NOT_OWNER | ERR_BUSY; /** * Check whether this structure can be used. If the room controller level is not enough, then this method will return false, and the structure will be highlighted with red in the game. */ @@ -49,7 +49,7 @@ interface Structure extends Roo * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_INVALID_ARGS: enable argument is not a boolean value. */ - notifyWhenAttacked(enabled: boolean): ScreepsReturnCode; + notifyWhenAttacked(enabled: boolean): OK | ERR_NOT_OWNER | ERR_INVALID_ARGS; } interface StructureConstructor extends _Constructor, _ConstructorById {} @@ -154,14 +154,14 @@ interface StructureController extends OwnedStructure { * - ERR_NOT_ENOUGH_RESOURCES: There is no safe mode activations available. * - ERR_TIRED: The previous safe mode is still cooling down, or the controller is upgradeBlocked, or the controller is downgraded for 50% plus 5000 ticks or more. */ - activateSafeMode(): ScreepsReturnCode; + activateSafeMode(): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_TIRED; /** * Make your claimed controller neutral again. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this controller. */ - unclaim(): ScreepsReturnCode; + unclaim(): OK | ERR_NOT_OWNER; } interface StructureControllerConstructor extends _Constructor, _ConstructorById {} @@ -242,7 +242,7 @@ interface StructureLink extends OwnedStructure { * - ERR_TIRED: The link is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this link. */ - transferEnergy(target: StructureLink, amount?: number): ScreepsReturnCode; + transferEnergy(target: StructureLink, amount?: number): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; } interface StructureLinkConstructor extends _Constructor, _ConstructorById {} @@ -286,7 +286,7 @@ interface StructureObserver extends OwnedStructure { * - ERR_INVALID_ARGS: roomName argument is not a valid room name value. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - observeRoom(roomName: string): ScreepsReturnCode; + observeRoom(roomName: string): OK | ERR_NOT_OWNER | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_RCL_NOT_ENOUGH; } interface StructureObserverConstructor extends _Constructor, _ConstructorById {} @@ -359,7 +359,7 @@ interface StructurePowerSpawn extends OwnedStructure { * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have enough energy or power resource units. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - processPower(): ScreepsReturnCode; + processPower(): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_RCL_NOT_ENOUGH; } interface StructurePowerSpawnConstructor extends _Constructor, _ConstructorById {} @@ -395,7 +395,7 @@ interface StructureRampart extends OwnedStructure { * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. */ - setPublic(isPublic: boolean): undefined; + setPublic(isPublic: boolean): OK | ERR_NOT_OWNER; } interface StructureRampartConstructor extends _Constructor, _ConstructorById {} @@ -479,7 +479,7 @@ interface StructureTower extends OwnedStructure { * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - attack(target: AnyCreep | Structure): ScreepsReturnCode; + attack(target: AnyCreep | Structure): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_RCL_NOT_ENOUGH; /** * Remotely heal any creep in the room. * @@ -492,7 +492,7 @@ interface StructureTower extends OwnedStructure { * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - heal(target: AnyCreep): ScreepsReturnCode; + heal(target: AnyCreep): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_RCL_NOT_ENOUGH; /** * Remotely repair any structure in the room. * @@ -505,7 +505,7 @@ interface StructureTower extends OwnedStructure { * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - repair(target: Structure): ScreepsReturnCode; + repair(target: Structure): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_RCL_NOT_ENOUGH; } interface StructureTowerConstructor extends _Constructor, _ConstructorById {} @@ -599,7 +599,7 @@ interface StructureLab extends OwnedStructure { * - ERR_NOT_IN_RANGE: The targets are too far away. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - boostCreep(creep: Creep, bodyPartsCount?: number): ScreepsReturnCode; + boostCreep(creep: Creep, bodyPartsCount?: number): OK | ERR_NOT_OWNER | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_RCL_NOT_ENOUGH; /** * Unboost a creep. * @@ -616,7 +616,7 @@ interface StructureLab extends OwnedStructure { * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - unboostCreep(creep: Creep): ScreepsReturnCode; + unboostCreep(creep: Creep): OK | ERR_NOT_OWNER | ERR_NOT_FOUND | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_TIRED | ERR_RCL_NOT_ENOUGH; /** * Breaks mineral compounds back into reagents. * @@ -634,7 +634,7 @@ interface StructureLab extends OwnedStructure { * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - reverseReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; + reverseReaction(lab1: StructureLab, lab2: StructureLab): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; /** * Produce mineral compounds using reagents from two another labs. * @@ -652,7 +652,7 @@ interface StructureLab extends OwnedStructure { * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - runReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; + runReaction(lab1: StructureLab, lab2: StructureLab): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; } interface StructureLabConstructor extends _Constructor, _ConstructorById {} @@ -690,7 +690,7 @@ interface StructureTerminal extends OwnedStructure { * - ERR_INVALID_ARGS: The arguments provided are incorrect. * - ERR_TIRED: The terminal is still cooling down. */ - send(resourceType: ResourceConstant, amount: number, destination: string, description?: string): ScreepsReturnCode; + send(resourceType: ResourceConstant, amount: number, destination: string, description?: string): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_ARGS | ERR_TIRED; } interface StructureTerminalConstructor extends _Constructor, _ConstructorById {} @@ -777,13 +777,18 @@ interface StructureNuker extends OwnedStructure { * - ERR_TIRED: This structure is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ - launchNuke(pos: RoomPosition): ScreepsReturnCode; + launchNuke(pos: RoomPosition): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; } interface StructureNukerConstructor extends _Constructor, _ConstructorById {} declare const StructureNuker: StructureNukerConstructor; +interface PortalDestination { + shard: string; + room: string +} + /** * A non-player structure. * @@ -799,7 +804,7 @@ interface StructurePortal extends Structure { * If this is an inter-shard portal, then this property contains an object with shard and room string properties. * Exact coordinates are undetermined, the creep will appear at any free spot in the destination room. */ - destination: RoomPosition | { shard: string; room: string }; + destination: RoomPosition | PortalDestination; /** * The amount of game ticks when the portal disappears, or undefined when the portal is stable. */ @@ -846,7 +851,7 @@ interface StructureFactory extends OwnedStructure { * - ERR_TIRED: The factory is still cooling down. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use the factory. */ - produce(resource: CommoditiesTypes): ScreepsReturnCode; + produce(resource: CommoditiesTypes): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES | ERR_INVALID_TARGET | ERR_FULL | ERR_INVALID_ARGS | ERR_TIRED | ERR_RCL_NOT_ENOUGH; } interface StructureFactoryConstructor extends _Constructor, _ConstructorById {}