After I put a flag in simulation room at 500% speed, messages like that appeared in the console for a few seconds from one of my modules where Game.rooms
was used in a function.
Posts made by fazan
-
Game is not defined
-
RE: universal getUsedCpu
var usedOnStart = 0; usedOnStart = getUsedCpu (); function getUsedCpu () { return Game.rooms.sim ? performance.now () - usedOnStart : Game.getUsedCpu (); }
-
universal getUsedCpu
Put this in the beginning of your script to have a getUsedCpu function which works in the simulation mode:
```javascript
var usedOnStart = 0;
usedOnStart = getUsedCpu ();function getUsedCpu ()
{
return Game.rooms.sim ? performance.now () - usedOnStart : Game.getUsedCpu ();
}
``` -
RE: Recommend a lightweight pathfinding library
Great! Very helpful. But one question: how do you deal with moving targets, like creeps? I didn't see that handled in the code.
-
Recommend a lightweight pathfinding library
So, I need to optimize my pathfinding, and I'd like to get to that from both ends (both the algorithm and caching), so I've been looking for a good library to do the thing for some time, unsucessfully. So, can anyone recommend a small (a file or two) and fast js pathfinding library with support of movement costs?
-
RE: A potential very fast js pathfinder algorithm
@Actium What algorithm did you use for your pathfinder?
-
RE: Cache results
Ohh... markdown
javascript
var Foo = function (room)
{
global.Cache = global.Cache || {};
global.Cache.rooms = global.Cache.rooms || {};
global.Cache.rooms [room] = global.Cache.rooms [room] || {};
global.Cache.rooms [room].FunctionName = global.Cache.rooms [room].FunctionName || FunctionCode;
return global.Cache.rooms[room].FunctionName;
}
-
RE: Cache results
Like this?
javascript
Function = function (room)
{
global.Cache = global.Cache || {};
global.Cache.rooms = global.Cache.rooms || {};
global.Cache.rooms [room] = global.Cache.rooms [room] || {};
global.Cache.rooms [room].FunctionName = global.Cache.rooms [room].FunctionName || FunctionCode;
return global.Cache.rooms[room].FunctionName;
}
-
RE: RoomPosition.findClosestByRange () filtering broken?
@chris Sorry, but there are no calls of 'filter' in the first example. There I pass an object with a property called 'filter' which holds a function definition. Do I miss something?
-
RE: What happens when a creep is not on path specified by moveByPath?
Oh, thanks, it wasn't in the documentation yesterday
-
RE: RoomPosition.findClosestByRange () filtering broken?
P.S - It happens only when passing an array of objects. And creep.room.myCreeps is a defined property of Room, which returns an Array of me creeps.
-
RoomPosition.findClosestByRange () filtering broken?
I had this kind of code (creeps is an Array):
var courier = creep.room.findClosestByRange (creeps, { filter: function (possibleTarget) { debugger; return ( possibleTarget !== creep && possibleTarget.memory.role === creep.memory.role && possibleTarget.carry.energy < possibleTarget.carryCapacity && creep.pos.getDirectionTo (possibleTarget) !== directionAway ); } })
The
filter
function was never called and thus no filtering occured. I changed the code for a test, and the following worked fine:var courier = creep.pos.findClosestByRange (creep.room.myCreeps.filter (function (possibleTarget) { debugger; return possibleTarget !== creep && possibleTarget.memory.role === creep.memory.role && possibleTarget.carry.energy < possibleTarget.carryCapacity && creep.pos.getDirectionTo (possibleTarget) !== directionAway; }));
-
What happens when a creep is not on path specified by moveByPath?
I have a predefined path from a spawn to an energy source. Also there is a creep standing to the right from the spawn, but not on the path. What happens if a command it to
moveByPath (path)
? Will it try to move to path and then follow it or throw an error? I'm kind of afk so can't test it myself. -
RE: Recomended IDEs
I use Visual Studio Code. The main reasons to use it were intuitive interface and git integration.
-
Game.creeps.filter vs. room.find (FIND_MY_CREEPS)
Which is a more effective way to find all creeps in a room: filtering
Game.creeps
or usingroom.find (FIND_MY_CREEPS)
? -
What was findNearest returning
Hi, I'm refactoring some old code, and would like to now what was the return value of findNearest: a nearest object or a sortet array of those?
-
RE: Twitter promo finally here, but...
Sorry, I still don't get it. Twitter promo has nothing to do with protection walls. Doy you mean people with multiple screeps accounts blocking rooms with 3-day protection? If so, that can be done even without cpu credist at all, as far as I know.
-
RE: Twitter promo finally here, but...
And I don't quite understand the point of that "at least 10 followers" requirement. Creating several twitter accounts to earn lots of credits just wouldn't work since your screeps account cannot get those 600 credits from twitter promo more than once a month anyway, right?
-
Twitter promo finally here, but...
That's just great. Especially for those who didn't have a twitter account and now have to get 10 followers out of nowhere