@prog autosweep.muf 1 99999 d i ( Autosweep.muf... by Wog A program that players can set up on themselve with a visual interface to automatically sweep them home when they disconnect. {With a delay.} --- Change History ---------------------------------- v 1.0 02/24/00 Assignment of version number to programs. v 1.01 02/26/00 Modified program not to do anything when they are already home. --- Distrubution Information ------------------------ Copyright {C} Charles "Wog" Reiss This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or {at your option} any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GPL: a> see: http://www.gnu.org/copyleft/gpl.html b> write to: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA ) $def HEADER "--- Autosweep by Wog ---------------------------------------" "green,bold" textattr : isSetup? ( d -- i ) "_prefs/asweep/setup?" getpropstr .yes? ; : getMesg ( -- s ) me @ "_prefs/asweep/mesg" "(autosweep)" 1 parseprop dup strlen 0 = if pop "is automatically sent home." then me @ swap pronoun_sub me @ name " " strcat swap strcat ; : do-disconnect me @ isSetup? not if exit then me @ awake? if exit then (Ignore if still awake...) me @ "_prefs/asweep/time" getpropval sleep me @ awake? if exit then (Don't do it if they are awake now...) me @ getlink me @ location dbcmp if exit then getMesg .otell me @ dup getlink moveto ; : cmdRepl command @ "CMD" subst ; : doSetMesg "Type in the message you wish to show when you are autoswept." "cyan" textattr .tell "The current message will show as: " "cyan" textattr getMesg "cyan,bold" textattr strcat .tell me @ "_prefs/asweep/mesg" getpropstr dup not if pop "[This is the default message.]" "green" textattr .tell else me @ name " " strcat swap strcat dup getMesg strcmp not if "[This parsed from: " swap strcat "]" strcat "cyan" textattr .tell else pop then then "Pronoun subutitions and MPI will be parsed. The text \"" me @ name " \" will" strcat strcat "magenta,bold" textattr .tell "prepended automatically." "magenta,bold" textattr .tell "Enter '.' to not change the messsage or the new text for it." "yellow,bold" textattr .tell read dup "." strcmp not if exit then me @ "_prefs/asweep/mesg" rot setprop ; : timeToStr "" swap dup 60 / intostr "m" strcat rot strcat swap 60 % intostr "s" strcat strcat ; lvar tmp $def DIGITS "0123456789" : extractTime -1 tmp ! dup "m" instr if "m" .split (before minutes, after minutes) swap atoi 60 * tmp ! then dup "s" instr if "s" .split (before seconds, after seconds) swap atoi tmp @ dup -1 = if pop 0 then + tmp ! (after seonds left, get rid of it.) pop else pop then tmp @ -1 = if (Unset, so far...) atoi 60 * tmp ! (Store the string that isn't processed in tmp) then tmp @ ; : doSetTime "Enter the amount of time you wish the program to wait after" "cyan" textattr .tell "you disconnect in minutes and/or seconds." "cyan" textattr .tell "Examples: '1m30s', '1' (for one minute), '3m'" "cyan" textattr .tell me @ "_prefs/asweep/time" getpropval timeToStr "cyan,bold" textattr "Current value: " "cyan" textattr swap strcat .tell "Enter '.' to leave unchanged, anything else to set." "yellow,bold" textattr .tell read dup "." strcmp not if exit then extractTime "Time set to: " "cyan" textattr over timeToStr "cyan,bold" textattr strcat .tell me @ "_prefs/asweep/time" rot setprop ; : doSetup HEADER .tell me @ isSetup? not if doSetTime doSetMesg me @ "_prefs/asweep/setup?" "yes" setprop me @ "_disconnect/autosweeper" prog setprop ">> Autosweep setup." "green,bold" textattr .tell then begin "1)" "cyan,bold" textattr " Waiting time is: " "cyan" textattr strcat me @ "_prefs/asweep/time" getpropval timeToStr "cyan,bold" textattr strcat .tell "2)" "cyan,bold" textattr " Message will show as: " "cyan" textattr strcat getMesg "cyan,bold" textattr strcat .tell me @ "_prefs/asweep/mesg" getpropstr dup not if pop " [Default message.]" "green" textattr .tell else me @ name " " strcat swap strcat dup getMesg strcmp if " [Without MPI/Pronoun subs it's: " swap strcat "]" strcat "magenta" textattr .tell else pop then then "Choose an option (1 or 2) or 0 to quit: " "yellow,bold" textattr .tell read atoi dup 0 = if "Done." "green,bold" textattr .tell exit then dup 1 = if doSetTime then dup 2 = if doSetMesg then repeat ; : main "me" match me ! dup "Disconnect" strcmp not if do-disconnect exit then dup not if HEADER .tell me @ isSetup? if "Autosweep is setup on you." "green" textattr .tell "Timeout: " "cyan" textattr me @ "_prefs/asweep/time" getpropval timeToStr "cyan,bold" textattr strcat .tell "Message parses to: " "cyan" textattr getMesg "cyan,bold" textattr strcat .tell me @ "_prefs/asweep/mesg" getpropstr dup not if pop " [Default message.]" "green" textattr .tell else me @ name " " strcat swap strcat dup getMesg strcmp if " [Without MPI/Pronoun subs it's: " swap strcat "]" strcat "magenta" textattr .tell else pop then then else "Autosweep is NOT setup on you." "red,bold" textattr .tell then "Type CMD #help for help." cmdRepl "magenta,bold" textattr .tell exit then dup "#h" stringpfx if HEADER .tell " This program will allow you to setup your charactor to be" "cyan,bold" textattr .tell "automatically sent home after you disconnect with an optional" "cyan,bold" textattr .tell "time delay and customizable messages." "cyan,bold" textattr .tell "Commands: " "magenta,bold" textattr .tell " CMD #help " "white,bold" textattr "-- This screen." "cyan" textattr strcat cmdRepl .tell " CMD #setup " "white,bold" textattr "-- Setup autosweep on you or edit your settings." "cyan" textattr strcat cmdRepl .tell " CMD #remove " "white,bold" textattr "-- Remove autosweep from you." "cyan" textattr strcat cmdRepl .tell " CMD " "white,bold" textattr "-- Tells how/if you have autosweep setup." "cyan" textattr strcat cmdRepl .tell exit then dup "#s" stringpfx if doSetup exit then dup "#r" stringpfx if "Remove? Confirm, please. (y/" "yellow" textattr "N" "yellow,bold" textattr strcat ")" "yellow" textattr strcat .tell read .yes? if me @ "_prefs/asweep" remove_prop me @ "_disconnect/autosweeper" remove_prop ">> Reset." "red,bold" textattr .tell else ">> Reset cancelled." "green,bold" textattr .tell then exit then ; . c q @action autosweep;asweep=#0 @link asweep=autosweep.muf @set autosweep.muf=L