; offline timer to check all remote scripts every minute
on *:start: .timerreloadmodscripts -o 0 60 reloadmodscripts
alias reloadmodscripts {
; loop all scripts
var %n = 1
while ($script(%n)) {
; store filehashes in a hash table (using the filenamehash as item to account for names with spaces)
var %nh = $md5($v1), %fh = $md5($v1,2)
; stored filehash is either different or nonexistent - file had been modified or new file
if ($hget(scripthashes,%nh) != %fh) {
; any hash stored - file had been modified: reload at same position
; (without the timer you won't be able to reload this very file too)
if ($v1 != $null) { .timer 1 0 reload -rs $+ %n $safe2($qt($script(%n))) }
; add/update filehash in hash table
hadd -m scripthashes %nh %fh
}
inc %n
}
}
alias -l safe2 { bset -t &a 1 $1 | return $!regsubex(safe, $bvar(&a,1-) ,/(\d+)(?: |$)/g,$chr(\1)) }