@program libAlynna.muf.i386.so.1.0 1 1000 d i ( Alynna's MUF function library v5.1 ) ( Last updated November 19, 2001 ) ( Someday hopefully we wont need this ) ( for FB5 old shit ) ( these defines ) $def ansi_notify notify $def ansi_notify_except notify_except $def ansi_strcut strcut $def ansi_strlen strlen : toint ( ? -- i ) ( Unconditional convert to int ) dup int? if exit then dup dbref? if int exit then dup string? if atoi exit then ; PUBLIC toint : tostr ( ? -- s ) ( Unconditional convert to str ) dup int? if intostr exit then dup dbref? if intostr exit then dup string? if exit then ; PUBLIC tostr : todbref ( ? -- d ) ( Unconditional convert to dbref ) dup int? if dbref exit then dup dbref? if exit then dup string? if match exit then ; PUBLIC todbref : capitalize ( s -- s ) ( Capitalise this string, making the first character uppercase ) 1 strcut swap toupper swap strcat ; PUBLIC capitalize : tellhere ( s -- ) ( tell here the string ) me @ location swap #-1 swap notify_except ; PUBLIC tellhere : tellme ( s -- ) ( tell me the string ) me @ swap ansi_notify ; PUBLIC tellme : here ( -- d ) ( return my location ) me @ location ; PUBLIC here lvar nstrcount : nstrcat ( si .. s1 n -- s ) ( strcat a stackrange ) 1 - nstrcount ! begin strcat nstrcount @ 1 - nstrcount ! nstrcount @ 1 < until ; PUBLIC nstrcat : strcatall ( si .. s1 -- s ) ( cats all strings till a non-string datatype is reached ) begin over string? if strcat else exit then depth 0 = until ; PUBLIC strcatall : str ( -- #-4 ) ( begins string compaction ) #-4 ; PUBLIC str : cat ( #-4 ?n .. ?1 -- s ) ( foolproof cat, ends string compaction section and converts all datatypes to strings, then strcats all strings ) ( Check first string ) dup dbref? if dup #-4 dbcmp if pop "" exit else name then else dup int? if intostr else dup string? if then then then ( Start cycling ) begin over dbref? if over #-4 dbcmp if swap pop exit else swap name swap strcat then else over int? if swap intostr swap strcat else over string? if strcat then then then depth 0 = until ; PUBLIC cat : prop? ( d s -- i ) ( returns true if the prop exists, and false if not ) getprop dup int? if 0 = if 0 exit else 1 exit then else pop 1 exit then ; PUBLIC prop? : wassup? ( ? -- i ) ( returns false if the argument is 0, "", or #-1, and true otherwise ) dup string? if "" stringcmp 0 = if 0 exit then then dup int? if 0 = if 0 exit then then dup dbref? if #-1 dbcmp if 0 exit then then 1 ; PUBLIC wassup? : lj ( s i -- s ) ( format to x characters left justified ) swap " " strcat swap ansi_strcut pop ; PUBLIC lj : rj ( s i -- s ) ( format to x characters right justified ) swap " " swap strcat dup ansi_strlen 3 pick - ansi_strcut swap pop swap pop ; PUBLIC rj : ulj ( s i -- s ) ( format to x characters left justified ) swap "______________________________________________________________________________" strcat swap ansi_strcut pop ; PUBLIC ulj : urj ( s i -- s ) ( format to x characters right justified ) swap "______________________________________________________________________________" swap strcat dup ansi_strlen 3 pick - ansi_strcut swap pop swap pop ; PUBLIC urj : popn ( i -- xxx ) dup 1 < if pop exit then begin swap pop 1 - not until ; PUBLIC popn lvar emS lvar emE lvar emX lvar emI lvar emT : ematch ( s3 s2 s1 -- s ) ( Explode match ) ( s3 = "Source string S" s2 = "Explode argument E" s1 = "Match string X" -- "Match found" ) ( Very complex function that matches an stack for the characters in s ) ( Returns s with a match or null, leaves the stack without exploded arguments ) emX ! emE ! emS ! ( Store it all ) emS @ emE @ explode emI ! ( explode on stack, save the count ) emI @ 0 = if "" exit then ( n = 0 ? nothing to explode. Leave. ) begin ( should have string on the stack ) dup emX @ stringpfx if ( Does this string have the first same chars as our search string? ) emS ! emI @ 1 - popn emS @ exit ( if so, return it ) else pop ( remove it from the stack ) then emI @ 1 - emI ! ( decrement emI ) emI @ 0 = until ( until 0 ) "" ( Didnt match, return null, and book it ) ; PUBLIC ematch : eselect ( s2 s1 i -- s ) ( Selects i in explode ) ( s1 = explode seperator s2 = explode string i = number in list to return ) emX ! emE ! emS ! ( Store it all ) emS @ emE @ explode emI ! ( explode on stack, save the count ) 1 emT ! ( initialize emX ) emI @ 1 < if "" exit then ( n < 1 ? nothing to explode. Leave. ) begin ( should have string on the stack ) emT @ emX @ = if ( does emT = emX? ) emS ! emI @ emT @ - popn emS @ exit ( if so, return it ) else pop ( remove it from the stack ) then emT @ 1 + emT ! ( increment emI ) emT @ emI @ > until ( until > emT ) "" ( Didnt match, return null, and book it ) ; PUBLIC eselect : erand ( s2 s1 -- s ) ( Selects a random member of the explode ) ( s1 = explode seperator s2 = explode string ) emE ! emS ! ( Store it all ) emS @ emE @ explode emI ! ( explode on stack, save the count ) random emI @ % 1 + emX ! ( Select a random member of the list ) 1 emT ! ( initialize emT ) emI @ 1 < if "" exit then ( n < 1 ? nothing to explode. Leave. ) begin ( should have string on the stack ) emT @ emX @ = if ( does emT = emX? ) emS ! emI @ emT @ - popn emS @ exit ( if so, return it ) else pop ( remove it from the stack ) then emT @ 1 + emT ! ( increment emI ) emT @ emI @ > until ( until > emT ) ; PUBLIC erand : ecount ( s2 s1 -- i ) ( Returns number of items in the explode ) ( s1 = explode seperator s2 = explode string ) emE ! emS ! ( Store it all ) emS @ emE @ explode emI ! ( explode on stack, save the count ) emI @ popn emI @ exit ( clear the stack, return the count and leave ) ; PUBLIC ecount lvar ipD lvar ipS lvar ipO : invprop ( d s ? -- s ) ( search propdir s on d for value ?, returns prop s, or "" if not found ) ipO ! ipS ! ipD ! ipD @ ipS @ nextprop ipS ! begin ipS @ "" stringcmp if ipD @ ipS @ getprop dup dup string? if ipO @ stringcmp not if pop ipS @ exit then then dup int? if ipO @ = if pop ipS @ exit then then dup dbref? if ipO @ dbcmp if pop ipS @ exit then then pop then ipD @ ipS @ nextprop ipS ! ipS @ "" stringcmp not until "" ; PUBLIC invprop : header ( s -- s ) ( Place string into a header block ) "-[ " swap strcat " ]----------------------------------------------------------------------------^ ^" strcat 78 ansi_strcut pop ; PUBLIC header : footer ( s -- s ) ( Place string into a footer block ) "-----------------------------------------------------------------------------[ " swap strcat " ]-" strcat dup ansi_strlen 78 - ansi_strcut swap pop ; PUBLIC footer : pretty ( s s -- s ) ( Prefix string with colorized, official prefix ) str swap "<" swap "> " cat swap strcat ; PUBLIC pretty lvar temp : timex ( i -- s ) ( translate i seconds to long time string ) temp ! str temp @ 31536000 >= if temp @ 31536000 / 999 % tostr " years, " then temp @ 86400 >= if temp @ 86400 / 365 % tostr " days, " then temp @ 3600 >= if temp @ 3600 / 24 % tostr " hours, " then temp @ 60 >= if temp @ 60 / 60 % tostr " minutes, " then temp @ 60 % tostr " seconds" cat ; PUBLIC timex : dhm ( i -- s ) ( translate i minutes into xxd mm:ss ) dup 60 % swap 60 / dup 24 % swap 24 / dup if intostr "d " strcat else pop "" then swap intostr dup strlen 1 = if "0" swap strcat then ":" strcat strcat swap intostr dup strlen 1 = if "0" swap strcat then strcat ; PUBLIC dhm : numplayers ( d -- i ) ( return the number of players at the current location ) 0 swap contents begin dup ok? while dup player? if dup awake? if swap 1 + swap then then next repeat pop ; PUBLIC numplayers : main ( -- ) ( installer ) prog "/_defs/str" "\"$lib/alynna\" match \"str\" call" setprop prog "/_defs/cat" "\"$lib/alynna\" match \"cat\" call" setprop prog "/_defs/ecount" "\"$lib/alynna\" match \"ecount\" call" setprop prog "/_defs/ematch" "\"$lib/alynna\" match \"ematch\" call" setprop prog "/_defs/erand" "\"$lib/alynna\" match \"erand\" call" setprop prog "/_defs/eselect" "\"$lib/alynna\" match \"eselect\" call" setprop prog "/_defs/footer" "\"$lib/alynna\" match \"footer\" call" setprop prog "/_defs/header" "\"$lib/alynna\" match \"header\" call" setprop prog "/_defs/here" "\"$lib/alynna\" match \"here\" call" setprop prog "/_defs/invprop" "\"$lib/alynna\" match \"invprop\" call" setprop prog "/_defs/lj" "\"$lib/alynna\" match \"lj\" call" setprop prog "/_defs/lju" "" setprop prog "/_defs/nstrcat" "\"$lib/alynna\" match \"nstrcat\" call" setprop prog "/_defs/pretty" "\"$lib/alynna\" match \"pretty\" call" setprop prog "/_defs/prop?" "\"$lib/alynna\" match \"prop?\" call" setprop prog "/_defs/rj" "\"$lib/alynna\" match \"rj\" call" setprop prog "/_defs/rju" "" setprop prog "/_defs/tellhere" "\"$lib/alynna\" match \"tellhere\" call" setprop prog "/_defs/tellme" "\"$lib/alynna\" match \"tellme\" call" setprop prog "/_defs/timex" "\"$lib/alynna\" match \"timex\" call" setprop prog "/_defs/todbref" "\"$lib/alynna\" match \"todbref\" call" setprop prog "/_defs/toint" "\"$lib/alynna\" match \"toint\" call" setprop prog "/_defs/tostr" "\"$lib/alynna\" match \"tostr\" call" setprop prog "/_defs/ulj" "\"$lib/alynna\" match \"ulj\" call" setprop prog "/_defs/urj" "\"$lib/alynna\" match \"urj\" call" setprop prog "/_defs/wassup?" "\"$lib/alynna\" match \"wassup?\" call" setprop prog "/_defs/dhm" "\"$lib/alynna\" match \"dhm\" call" setprop prog "/_defs/numplayers" "\"$lib/alynna\" match \"numplayers\" call" setprop prog "/_defs/capitalize" "\"$lib/alynna\" match \"capitalize\" call" setprop prog "/_defs/popn" "\"$lib/alynna\" match \"popn\" call" setprop prog "L" set prog "V" set "libLoxorion v5.1.20011119" header tellhere "The library is installed properly" "TEST" pretty tellhere "LINK_OK VIEWABLE" "REQUIRES" pretty tellhere "str cat ecount ematch erand eselect fchop footer fstatbar header dhm" "PROVIDES" pretty tellhere "invprop lj lju mpi mpime nstrcat pretty prop? rj rju statbar tellhere" "PROVIDES" pretty tellhere "tellme timex todbref toint tostr ulj urj wassup? debug stimestr" "PROVIDES" pretty tellhere "dhm onlinetime idletime numplayers capitalize" "PROVIDES" pretty tellhere "Loxorion's MUFInstaller" footer tellhere ; . c q