@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 -------------------------------" : 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 (If they're there don't try!) getMesg .otell me @ dup getlink moveto ; : cmdRepl command @ "CMD" subst ; : doSetMesg "Type in the message you wish to show when you are autoswept." .tell "The current message will show as: " getMesg strcat .tell me @ "_prefs/asweep/mesg" getpropstr dup not if pop "[This is the default message.]" .tell else me @ name " " strcat swap strcat dup getMesg strcmp not if "[This parsed from: " swap strcat "]" strcat .tell else pop then then "Pronoun subutitions and MPI will be parsed. The text \"" me @ name " \" will" strcat strcat .tell "prepended automatically." .tell "Enter '.' to not change the messsage or the new text for it." .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" .tell "you disconnect in minutes and/or seconds." .tell "Examples: '1m30s', '1' (for one minute), '3m'" .tell me @ "_prefs/asweep/time" getpropval timeToStr "Current value: " swap strcat .tell "Enter '.' to leave unchanged, anything else to set." .tell read dup "." strcmp not if exit then extractTime "Time set to: " over timeToStr 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." .tell then begin "1) Waiting time is: " me @ "_prefs/asweep/time" getpropval timeToStr strcat .tell "2) Message will show as: " getMesg strcat .tell me @ "_prefs/asweep/mesg" getpropstr dup not if pop " [Default message.]" .tell else me @ name " " strcat swap strcat dup getMesg strcmp if " [Without MPI/Pronoun subs it's: " swap strcat "]" strcat .tell else pop then then "Choose an option (1 or 2) or 0 to quit: " .tell read atoi dup 0 = if "Done." .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." .tell "Timeout: " me @ "_prefs/asweep/time" getpropval timeToStr strcat " seconds." strcat .tell "Message parses to: " getMesg strcat .tell me @ "_prefs/asweep/mesg" getpropstr dup not if pop " [Default message.]" .tell else me @ name " " strcat swap strcat dup getMesg strcmp if " [Without MPI/Pronoun subs it's: " swap strcat "]" strcat .tell else pop then then else "Autosweep is NOT setup on you." .tell then "Type CMD #help for help." cmdRepl .tell exit then dup "#h" stringpfx if HEADER .tell " This program will allow you to setup your charactor to be" .tell "automatically sent home after you disconnect with an optional" .tell "time delay and customizable messages." .tell "Commands: " .tell " CMD #help -- This screen." cmdRepl .tell " CMD #setup -- Setup autosweep on you or edit your settings." cmdRepl .tell " CMD #remove -- Remove autosweep from you." cmdRepl .tell " CMD -- Tells how/if you have autosweep setup." cmdRepl .tell exit then dup "#s" stringpfx if doSetup exit then dup "#r" stringpfx if "Remove? Confirm, please. (y/N)" .tell read .yes? if me @ "_prefs/asweep" remove_prop me @ "_disconnect/autosweeper" remove_prop ">> Reset." .tell else ">> Reset cancelled." .tell then exit then ; . c q @action autosweep;asweep=#0 @link asweep=autosweep.muf @set autosweep.muf=L