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.
fazan
@fazan
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