This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const detectSignal = (n) => { | |
const sg = $.getStateCompat("this", n, T.double); | |
const ky = `last_${n}`; | |
const lsg = $.getStateCompat("this", ky, T.double); | |
if (sg > lsg) { | |
$.setStateCompat("this", ky, sg); | |
return true; | |
} | |
return false; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pad = (n, l = 2) => { | |
return n.toString().padStart(l, "0"); | |
}; | |
const now = () => { | |
const d = new Date(); | |
const time = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad( | |
d.getSeconds() | |
)}.${pad(d.getMilliseconds(), 3)}`; | |
return time; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const intervalTask = (name, interval, deltaTime) => { | |
const key = `intervalTask_${name}}`; | |
$.state[key] = ($.state[key] ?? interval) + deltaTime; | |
if ($.state[key] < interval) return false; | |
$.state[key] = 0; | |
return true; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TIMER_KEY = (name) => `timer_${name}`; | |
const isTimerActive = (name) => $.state[TIMER_KEY(name)] >= 0; | |
const startTimer = (name, duration) => { | |
const key = TIMER_KEY(name); | |
if (isTimerActive(name)) return false; // この行を消すと再実行でタイマーを延長できる | |
$.state[key] = duration; | |
return true; | |
}; |
NewerOlder