automt: add .mtq to quit
This commit is contained in:
parent
2b7b53da89
commit
bb0d7c1e66
21
automt
21
automt
@ -10,6 +10,7 @@ chatlogdir=~/.wschat
|
||||
mtpid=0
|
||||
mtpath=$(dirname $0)
|
||||
dbg=1
|
||||
quit=1
|
||||
if [ ! -z $4 ]; then dbg=0; fi
|
||||
mkdir -p $chatlogdir
|
||||
if [ -f $pwf ]; then pas=$(cat $pwf); fi
|
||||
@ -22,21 +23,31 @@ check_host() {
|
||||
|
||||
startmt() {
|
||||
$mtpath/bin/minetest --go --address $srv --port $prt --name $usr --password $passwd 2>&1 | while read l; do
|
||||
if [ "$(echo $l |grep '\[cchat\]')" != "" ]; then
|
||||
if [ "$(echo $l |grep '\[cchat\]')" != "" ]; then
|
||||
srvstr=$(echo $l|cut -d ' ' -f 5)
|
||||
lgstr=$(echo $l|sed 's/ACTION\[Main\]: \[cchat\] //'|sed "s/$srvstr//")
|
||||
if [ "$(echo $l |grep '\[sent\]')" != "" ]; then continue; fi
|
||||
echo $lgstr >> $chatlogdir/$srvstr.txt
|
||||
else echo $l >> $logfile; fi
|
||||
|
||||
else
|
||||
echo $l >> $logfile;
|
||||
if [ "$(echo $l|grep 'AUTOMT Actually Quit')" != "" ]; then
|
||||
quit=0;
|
||||
kill $mtpid
|
||||
fi
|
||||
fi
|
||||
if [ $dbg -eq 0 ]; then echo $l; fi
|
||||
done &
|
||||
mtpid=$!
|
||||
}
|
||||
|
||||
while true; do
|
||||
if [ $quit -eq 0 ]; then
|
||||
kill -9 $mtpid
|
||||
exit
|
||||
fi
|
||||
sleep 1
|
||||
if check_host $srv $prt; then
|
||||
if ! ps $mtpid >/dev/null 2>&1; then startmt; fi
|
||||
else echo host is down. waiting 10...; sleep 10; fi
|
||||
if ! ps $mtpid >/dev/null 2>&1 && [ $quit -eq 1 ]; then startmt; fi
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
7
clientmods/automt/init.lua
Normal file
7
clientmods/automt/init.lua
Normal file
@ -0,0 +1,7 @@
|
||||
minetest.register_chatcommand('mtq', {
|
||||
description = 'automt-quit',
|
||||
func = function(param)
|
||||
minetest.log("AUTOMT Actually Quit")
|
||||
minetest.disconnect()
|
||||
end
|
||||
})
|
@ -36,3 +36,4 @@ load_mod_speedlimit = true
|
||||
load_mod_frenemies = true
|
||||
load_mod_autocraft = true
|
||||
load_mod_quint = true
|
||||
load_mod_automt = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user