I'm using ROT.Scheduler.Speed in my web game. I'm running into a few problems.
Scheduler.next() is not returning the proper item. It only returns the first object added, in this case the player.
I found a fix for this by replacing ROT.Scheduler.prototype.next() with this
ROT.Scheduler.prototype.next = function() { this._current = {} Object.assign(this._current, this._queue.get()) return this._current; };
With the above I can move down my scheduler but the actors aren't repeating so it will go down my list of Scheduler actors and then return undefined
Notes:
The webapp is built in React.
I want to add and remove actors at any point in time.
I want to dispatch the this._current actor for all React components to see
I only want the Scheduler to know the ActorsID and their speed so I replaced the add function with this
ROT.Scheduler.Speed.prototype.add = function(item, repeat, time) { function CreateSchedulerObject(actor) { let speedInt = actor .CharacterSheet .getAttribute('Agility') return { id: actor.getID(), getSpeed: function () { return speedInt } } } let newObj = CreateSchedulerObject(item) console.log(newObj) this._queue.add(newObj, time !== undefined ? time : 1/newObj.getSpeed()); return ROT.Scheduler.prototype.add.call(this, newObj, repeat); };
Hi all,
I'm using ROT.Scheduler.Speed in my web game. I'm running into a few problems.
ROT.Scheduler.prototype.next = function() { this._current = {} Object.assign(this._current, this._queue.get()) return this._current; };
undefined
Notes: The webapp is built in React. I want to add and remove actors at any point in time. I want to dispatch the this._current actor for all React components to see I only want the Scheduler to know the ActorsID and their speed so I replaced the
add
function with thisROT.Scheduler.Speed.prototype.add = function(item, repeat, time) { function CreateSchedulerObject(actor) { let speedInt = actor .CharacterSheet .getAttribute('Agility') return { id: actor.getID(), getSpeed: function () { return speedInt } } } let newObj = CreateSchedulerObject(item) console.log(newObj) this._queue.add(newObj, time !== undefined ? time : 1/newObj.getSpeed()); return ROT.Scheduler.prototype.add.call(this, newObj, repeat); };
Thanks