Virtual Item Comsystem 1.0

#27 should be your item system dbref.

+com/freq =
+comsys/remfreq
+com =
+comsys/transmit =
+comsys/broadcast
+com/on Turn on comsys
+com/off Turn off comsys

Instructions for installation are in old Comsys. Make a new item type in item database for type Comsys, make items of that type.

"&2_GENERAL =COMSYS" <--- Example

Just replace the old comsys with this one.

@create Comsys System
@set Comsys System = !no_command
@set Comsys System = WIZARD
&CMD Comsys System=
&CMD_ALIAS Comsys System=
&CMD_ALIAS`+COM Comsys System=$+com:@fo %#=+comsys
&CMD_ALIAS`+COM/BROADCAST Comsys System=$+com/broadcast *:@fo %#={+comsys/broadcast %0}
&CMD_ALIAS`+COM/FREQ Comsys System=$+com/freq *=*:@fo %#={+comsys/freq %0=%1}
&CMD_ALIAS`+COM/OFF Comsys System=$+com/off:@fo %#=+comsys/off
&CMD_ALIAS`+COM/ON Comsys System=$+com/on:@fo %#=+comsys/on
&CMD_ALIAS`+COM/REMFREQ Comsys System=$+com/remfreq *:@fo %#={+comsys/remfreq %0}
&CMD_ALIAS`+COM/TRANS Comsys System=$+com *=*:@fo %#={+comsys/transmit %0=%1}
&CMD_ALIAS`+COM/TRANSMIT Comsys System=$+com/transmit *=*:@fo %#={+comsys/transmit %0=%1}
&CMD`+COMSYS Comsys System=$+comsys:@pemit %#=[if([left([u(fun`uselock,%#)],1)],[ansi(g,[center(<%b[ansi(hg,Comsys Status)]%b>,50,-)])]%r[space(5)][ansi(hg,Transmit Name:)]%b[default(%#/comsys`name,name(%#))]%r[space(5)][ansi(hg,Comsys Power:)]%b[if(default(%#/comsys`power,0),ansi(hb,On),ansi(hr,Off))]%r[space(5)][ansi(hg,Frequencies:)]%b[iter(lattr(%#/comsys`freq`*,|),[last(%i0,`)]%b%b:%b%b[get(%#/%i0)]%r,|,[space(18)])][ansi(g,[repeat(-,50)])],[ansi(hr,-)]%bYou don't have a comsys.)]
&CMD`+COMSYS/BROADCAST Comsys System=$+comsys/broadcast *:@pemit %#=[switchall([u(fun`uselock,%#,1)],?1?,[u(fun`error_string,#$)],101,[u(fun`transmit,%0,0)],[ansi(hrf,Code Error)])]
&CMD`+COMSYS/FREQ Comsys System=$+comsys/freq *=*:@pemit %#=[switchall([u(fun`uselock,%#,%1)],*,[u(fun`error_string_off,#$)],101,[ansi(hg,-)]%bYou add [rjust(%1,8,0)] to the comsys frequency list.[attrib_set(%#/comsys`freq`[edit(%0,|,,:,,$,,\(,,\),,\[,,\],,*,,&,,^,,%%,,#,,@,,!,,;,)],[rjust(%1,8,0)])],[ansi(hrf,Code Error)])]
&CMD`+COMSYS/OFF Comsys System=$+comsys/off:@pemit %#=[switchall([u(fun`uselock,%#,1)],*,[u(fun`error_string_off,#$)],101,[ansi(hg,-)]%bThe comsys pops off.[attrib_set(%#/comsys`power,0)],[ansi(hrf,Code Error)])]
&CMD`+COMSYS/ON Comsys System=$+comsys/on:@pemit %#=[switchall([u(fun`uselock,%#,1)],*,[u(fun`error_string_on,#$)],111,[ansi(hg,-)]%bThe comsys crackles to life.[attrib_set(%#/comsys`power,1)],[ansi(hrf,Code Error)])]
&CMD`+COMSYS/REMFREQ Comsys System=$+comsys/remfreq *:@pemit %#=[switchall([u(fun`uselock,%#,1)][t(grab(lattr(%#/comsys`freq`*,|),comsys`freq`%0,|))],*,[u(fun`error_string,#$)],1011,[ansi(hg,-)]%bYou remove %0 \([get(%#/comsys`freq`%0)]\) from the comsys frequency list.[attrib_set(%#/comsys`freq`%0)],[ansi(hrf,Code Error)])]
&CMD`+COMSYS/TRANSMIT Comsys System=$+comsys/transmit *=*:@pemit %#=[switchall([u(fun`uselock,%#,1)][or(setr(9,grab(lattr(%#/comsys`freq`*,|),comsys`freq`%0,|)),setr(8,and(isnum(%0),eq(strlen(%0),8))))],*,[u(fun`error_string,#$)],1011,[u(fun`transmit,%1,if(%q8,%0,[last(get(%#/%q9),:)]))],[ansi(hrf,Code Error)])]
&FUN Comsys System=
&FUN`ERROR_STRING Comsys System=[switch(%0,0*,[ansi(hr,-)]%bYou don't have a comsys.,111?,[ansi(hr,-)]%bYour comsys is already off.,100?,[ansi(hr,-)]%bThat is not a valid number.,1010,[ansi(hr,-)]%bThat is not a valid channel.,)]
&FUN`ERROR_STRING_FREQ Comsys System=[switch(%0,0*,[ansi(hr,-)]%bYou don't have a comsys.,111?,[ansi(hr,-)]%bYour comsys is turned off.,100?,[ansi(hr,-)]%bThat is not a valid number.,1110,[ansi(hr,-)]%bThat number doesn't exist in your comsys frequency list.,)]
&FUN`ERROR_STRING_OFF Comsys System=[switch(%0,0*,[ansi(hr,-)]%bYou don't have a comsys.,111,[ansi(hr,-)]%bYour comsys is already off.,100,[ansi(hr,-)]%bThat is not a valid number.,)]
&FUN`ERROR_STRING_ON Comsys System=[switch(%0,0*,[ansi(hr,-)]%bYou don't have a comsys.,101,[ansi(hr,-)]%bYour comsys is already turned on.,)]
&FUN`SHORTCUT Comsys System=if(eq(if(isnum(%0),strlen(%0)),8),%0,default(%#/comsys`freq`%0,00000000))
&FUN`TRANSMIT Comsys System=localize([setq(1,if(t(%1),%1,iter(lattr(%#/comsys`freq`*,|),last(u(%i0),:),|,|)))][null(iter([squish(iter(lsearch(all,type,player),switch(u(fun`uselock,%i0,1),101,%i0:[lmath(or,iter(iter([lattr(%i0/comsys`freq`*,|)]|$^:00000000,u(%i1/%i0),|,|),[t(match(%q1,%i0,|))],|,:),:)],),,|),|)],if(eq(last(%i0,:),1),[pemit([first(%i0,:)],[ansi(hy,-Comsys)] [speak(%#,%0)])]),|))])
&FUN`USELOCK Comsys System=[lmath(or,[iter(setr(0,default(%0/list`inventory,)),match([u(#27/fun`itemres,%q0,%i0,GENERAL)],COMSYS),|,:)],:)][eq([default(%0/comsys`power,0)],0)][isnum(%1)]
&FUN`USELOCK_FREQ Comsys System=[lmath(or,[iter(setr(0,default(%0/list`inventory,)),match([u(#27/fun`itemres,%q0,%i0,GENERAL)],COMSYS),|,:)],:)][eq([default(%0/comsys`power,0)],0)][isnum(%1)][t([grab(default(%0/comsys`freq,00000000),%2,|)])]