@q
@program vsys-@vbcast
1 99999 d
i
( vsys-@vbcast v1.0 Jessy @ FurryMUCK 4/00
Part of the vsys vehicle system, this program handles messaging into
and out of vehicles.
INSTALLATION:
Port the program, set it Wizard and Link_OK. Create a global exit
with a name such as '@vbcast', and link it to the program. Type
'<action name> #install'.
Vsys-@vbcast requires lib-vsys and lib-reflist. See the header comment
of lib-vsys for more complete documentation on the vehicle system.
USE:
@vbcast #broadcast ........... Broadcast says/poses from room to ext
@vbcast #!broadcast .......... Don't broadcast to exterior
@vbcast #listen .............. Listen from ext to all !Q interior rooms
@vbcast #!listen ............. Do not listen in interior rooms
@vbcast #quiet ............... Don't broadcast or listen in current room
@vbcast #!quiet .............. Honor #broadcast and #listen settings
Each of these commands requires administrative privileges for the
current vehicle.
Vsys-@vbcast may be freely ported. Please comment any changes.
)
$include $lib/vsys
$include $lib/reflist
$define Tell me @ swap notify $enddef
lvar ourString
lvar ourVehicle
: DoInit ( -- ) (* ensure program is W and registerd *)
LibInit
prog "W" flag? if
#0 "_reg/vsys/vbcast-prog" prog setprop
#0 "_reg/vsys/vbcast-com" trig setprop
else
prog name " must be set Wizard." strcat me @ swap notify
pid kill
then
;
: DoInstall ( -- ) (* really doesn't do anything *)
DoInit
">> $prog installed." prog name "$prog" subst Tell
;
: DoHelp ( -- ) (* show help screen *)
" " Tell
prog name " (#" strcat prog intostr strcat ")" strcat Tell " " Tell
"This program manages broadcasts to and from vehicle rooms."
Tell " " Tell
" $com #broadcast ....... Broadcast says/poses from room to ext"
command @ "$com" subst Tell
" $com #!broadcast ...... Don't broadcast to exterior"
command @ "$com" subst Tell
" $com #listen .......... Listen from ext to all !Q interior rooms"
command @ "$com" subst Tell
" $com #!listen ......... Do not listen in interior rooms"
command @ "$com" subst Tell
" $com #quiet ........... Don't broadcast or listen in current room"
command @ "$com" subst Tell
" $com #!quiet .......... Honor #broadcast and #listen settings"
command @ "$com" subst Tell " " Tell
"Each of these commands requires Administrator privileges for the "
"current vehicle." strcat Tell " " Tell
"For complete information on the vehicle system, type '@view $lib/vsys' "
"(long)." strcat Tell
;
: DoOutToIn ( -- ) (* handle #listen output *)
trig "D" flag? if exit then (* darked vehicles can't listen *)
trig "@v/env" getprop dup if (* find env room *)
dup string? if "" "#" subst atoi dbref then (* set up prefix *)
trig name ">" strcat ourString @ strcat ourString !
contents
begin (* begin vehicle-room-getting loop *)
dup while
dup room? if
dup "@v/quiet" getpropstr not if (* ignore @v/quiet rooms *)
dup contents
begin (* begin vehicle-room-occupants-getting loop *)
dup while
dup ourString @ notify (* notify occupant *)
next
repeat (* end occupants-getting loop *)
pop
then
then
next
repeat (* end room-getting loop *)
pop
else
pop
then
;
: DoInToOut ( -- ) (* handle #broadcast output *)
(* ignore @v/quiet rooms *)
me @ location "@v/quiet" getpropstr if exit then
me @ GetVehicle dup if
dup "D" flag? if pop exit then (* darked vehicles can't broadcast *)
ourVehicle !
ourVehicle @ name "> " strcat ourString @ strcat ourString !
ourVehicle @ location contents
begin (* loop: notify all occupants of vehicle's location *)
dup while
dup ourString @ notify
next
repeat
pop
else
pop
then
;
: DoVbcast ( -- ) (* handle output picked up by _listen *)
me @ GetVehicleEnv if
DoInToOut
else
DoOutToIn
then
;
: DoSetBcast ( -- )
(* set: poses/says will be broadcast from vehicle *)
me @ GetVehicle dup if (* find vehicle *)
ourVehicle !
else
">> You are not in a vehicle." Tell
">> Unable to set broadcasts." Tell exit
then
VehicleAdmin? if (* check permission *)
me @ location "_listen/vsys" prog setprop (* set _listen/ *)
">> Set." Tell
">> Poses and says will be broadcast from this room to the location of"
Tell
">> the $vehicle." ourVehicle @ name "$vehicle" subst Tell
else
">> Permission denied." Tell
then
;
: DoSetNotBcast ( -- )
(* set: poses/says will not be broadcast from vehicle *)
me @ GetVehicle dup if (* find vehicle *)
ourVehicle !
else
">> You are not in a vehicle." Tell
">> Unable to reset broadcasts." Tell exit
then
VehicleAdmin? if (* check permission *)
me @ location "_listen/vsys" remove_prop (* reset _listen/ *)
">> Set." Tell
">> Poses and says will *not* be broadcast "
"from this room to the location" strcat Tell
">> of the $vehicle." ourVehicle @ name "$vehicle" subst Tell
else
">> Permission denied." Tell
then
;
: DoSetListen ( -- )
(* set: poses/says will be broadcast into vehicle *)
me @ GetVehicle dup if (* find vehicle *)
ourVehicle !
else
">> You are not in a vehicle." Tell
">> Unable to set listening." Tell exit
then
VehicleAdmin? if (* check permission *)
ourVehicle @ "_listen/vsys" prog setprop (* set _listen/ *)
">> Set." Tell
">> Poses and says will be broadcast from the location of the "
Tell
">> $vehicle to its listening interior rooms."
ourVehicle @ name "$vehicle" subst Tell
else
">> Permission denied." Tell
then
;
: DoSetNotListen ( -- )
(* set: poses/says will not be broadcast into vehicle *)
me @ GetVehicle dup if (* find vehicle *)
ourVehicle !
else
">> You are not in a vehicle." Tell
">> Unable to reset listening." Tell exit
then
VehicleAdmin? if (* check permission *)
ourVehicle @ "_listen/vsys" prog setprop (* reset _listen/ *)
">> Set." Tell
">> Poses and says will *not* be broadcast from the location of the "
Tell
">> $vehicle to its listening interior rooms."
ourVehicle @ name "$vehicle" subst Tell
else
">> Permission denied." Tell
then
;
: DoSetQuiet ( -- )
(* set: current room will not #listen or #broadcast *)
me @ GetVehicle dup if (* find vehicle *)
ourVehicle !
else
">> You are not in a vehicle." Tell
">> Unable to set room." Tell exit
then
VehicleAdmin? if (* check permission *)
me @ location "@v/quiet" "yes" setprop (* set @v/quiet *)
">> Set." Tell
">> This room will not receive or transmit vehicle broadcasts." Tell
else
">> Permission denied." Tell
then
;
: DoSetNotQuiet ( -- )
(* set: current room will honor #listen & #broadcast settings *)
me @ GetVehicle dup if (* find vehicle *)
ourVehicle !
else
">> You are not in a vehicle." Tell
">> Unable to reset room." Tell exit
then
VehicleAdmin? if (* check permission *)
me @ location "@v/quiet" remove_prop (* unset @v/quite *)
">> Set." Tell
">> This room will receive and transmit vehicle broadcasts according"
Tell
">> to #listen and #broadcast settings for the $vehicle."
ourVehicle @ name "$vehicle" subst Tell
else
">> Permission denied." Tell
then
;
: main
"me" match me !
DoInit
dup if
ourString !
then
trig exit? not if DoVbcast exit then
ourString @ if
"#broadcast" ourString @ stringpfx if DoSetBcast exit then
"#!broadcast" ourString @ stringpfx if DoSetNotBcast exit then
"#help" ourString @ stringpfx if DoHelp exit then
"#install" ourString @ stringpfx if DoInstall exit then
"#listen" ourString @ stringpfx if DoSetListen exit then
"#!listen" ourString @ stringpfx if DoSetNotListen exit then
"#quiet" ourString @ stringpfx if DoSetQuiet exit then
"#!quiet" ourString @ stringpfx if DoSetNotQuiet exit then
else
DoVbcast
then
;
.
c
q