Closed morko closed 5 years ago
Was trying to implement a MOTD plugin with help of the sav/cron plugin. Noticed that setting a new cron job with e.g. room.onCron3Seconds does not work inside a command handler.
sav/cron
room.onCron3Seconds
Happened in the testing environment of hhm-plugins.
testing
Here is the affected plugin (stripped):
let room = HBInit(); room.pluginSpec = { name: `bug/example`, author: `salamini`, version: `1.0.0`, config: { periodicalMessage: `Periodical Message.`, messageInterval: 5 }, dependencies: [`sav/cron`] }; if (room.pluginSpec.config.messageInterval > 0) { displayMessageOnceIn( room.pluginSpec.config.messageInterval, room.pluginSpec.config.periodicalMessage ); } function displayMessageOnceIn(interval, message) { room[`onCron${interval}Seconds`] = () => room.sendChat(message); } room.onConfigSet = ({paramName, newValue, oldValue}) => { if (paramName === `messageInterval`) { const periodicalMessage = room.pluginSpec.config.periodicalMessage; delete room[`onCron${oldValue}Seconds`]; displayMessageOnceIn(newValue, periodicalMessage); } } room.onCommand1_motd = (player, [interval]) => { room.setConfig('messageInterval', interval); }
Expected to be able to change the cron job with !motd [interval] in the room but it did not work.
!motd [interval]
Was trying to implement a MOTD plugin with help of the
sav/cron
plugin. Noticed that setting a new cron job with e.g.room.onCron3Seconds
does not work inside a command handler.Happened in the
testing
environment of hhm-plugins.Here is the affected plugin (stripped):
Expected to be able to change the cron job with
!motd [interval]
in the room but it did not work.