echo ; library echos - Axel 2003-May-23 q enter ; in addition to the 'usual' variables which are imported by the ; enter event, following variables are set by the library code: ; ; (basically those which you see when you type /lib .. .. list ; ;--- we do not want to trigger on 'ourselves' i me=who q ; n data,err,quit,cookie,f,ok,dt ; ;--- get the 'flags' lib variables s f=$zmud(81,0,lib,"flags") ; ;--- if set, do not trigger if mobs enter i $f(f,"nomob"),$$isnpc^%char(who) q ; ;--- if set, do not trigger if the relating daytime is not set s ok=1 i $f(f,"sunset")!($f(f,"day"))!($f(f,"night"))!($f(f,"sunrise")) s ok=0 i $f(f,"day"),$$daytime^%comm()="day" s ok=1 i $f(f,"night"),$$daytime^%comm()="night" s ok=1 i $f(f,"sunrise"),$$daytime^%comm()="sunrise" s ok=1 i $f(f,"sunset"),$$daytime^%comm()="sunset" s ok=1 i 'ok q ; ;--- no multiple echos?! i '$f(f,"nomulti") g eskip s data=$zmud(78,0,me) i $$var^util(me,lib_"-no_multi")=1 q s err=$$var^util(me,lib_"-no_multi","1") s cookie=$$add^%sched(0,0,0,0,"enter2^"_$zn,0,0,data,lib) ; eskip ;--- remember? s quit=0 i +$g(remember)>0 d . i $$var^util(me,who_"-remember-"_lib)="1" s quit=1 q . s err=$$var^util(me,who_"-remember-"_lib,1) . s data=$zmud(78,0,me_"-"_who_"-"_lib) . s cookie=$$add^%sched(0,remember,0,0,"enter1^"_$zn,0,0,data,who,"enter-echo "_$$instance^%comm(me)_" remembers '"_$$name^%char(who)_"'") ; i quit q ; ;--- standard delay is 0 i $g(delay)="" s delay=+$g(delay) ;--- random chosen i $g(random)'="" i $r(random)>0 q ;--- allocate memory s data=$zmud(78,0,me_","_who_","_$$room^%char(who)) ;--- add to scheduler s cookie=$$add^%sched(0,delay,0,0,"enter0^"_$zn,0,0,data,lib,"enter-echo "_$$instance^%comm(me)_" exec-delay '"_$$name^%char(who)_"'") q enter0 ;--- something went wrong i ptr1=""!(ptr2="") q n ch,ro,data,me,who,err,room ;--- extract me and who from the allocated space s me=$p($zmud(78,2,ptr1),",") i '$$ischar^util(me) s me=0 s who=$p($zmud(78,2,ptr1),",",2) i '$$ischar^util(who) s who=0 s room=$p($zmud(78,2,ptr1),",",3) ;--- quit if player moved out i room'=$$room^%char(who) q ;--- get echos from the library template s ch=$zmud(81,0,ptr2,"to_char") s ro=$zmud(81,0,ptr2,"to_room") ;--- check if still in room i me'=0,who'=0,$$instroom^util(me)'=$$instroom^util(who) q ;--- do the acts! i ch'="" d char^%act($$format^%comm(ch),0,who,me) i ro'="" d room^%act($$format^%comm(ro),1,who,me) ;--- free memory and be done s err=$zmud(78,1,ptr1) q enter1 ;--- remove lock n err,data,in,who,me,lib s in=$zmud(78,2,ptr1) s err=$zmud(78,1,ptr1) s me=$p(in,"-"),who=$p(in,"-",2),lib=$p(in,"-",3) s err=$$vdel^util(me,who_"-remember-"_lib) q enter2 ;--- remove multi-echo lock n err,me s me=$zmud(78,2,ptr1) s err=$zmud(78,1,ptr1) s err=$$vdel^util(me,ptr2_"-no_multi") q enterC ;--- checks q