Virtual Item Comsystem

Submitted by Reaver on Fri, 2009-12-04 05:23

#27 Should be the dbref of your Item System. This object needs to be in the Master Room.
You will need to create a new entry in your Item Database, as well.

&#_GENERAL Item Database=COMSYS

# can be replaced with any free database entries you have. (That is, if you're using the default database, you can just make it 2. Since the default database only has 1 entry (Food))

Any comsystems will need to be labeled with this new item. If you did go with 2, a comsys virtual item might be..

&list`inventory me=Nuka_Cola 1 100|Reaver's_Comsys 2 1

This code is still in Beta testing, I will update it as time goes along. It has been proven in basic testing to function correctly, however.

Your commands are...
+com or +comsys: Details on commlink.
+com/broadcast or +comsys/broadcast: Broadcast on all frequencies listed in +comsys. (Not finished)
+com/transmit (Non functional) or +comsys/transmit (Functional): +comsys/transmit Blah will (Currently) transmit to all added frequencies. Later this will become +comsys/transmit =Blah. Where is the code or name you have assigned to a certain frequency.
+com/on or +comsys/on: Turn on your comsys.
+com/off or +comsys/off: Turn off your comsys.
+com/freq or +comsys/freq: Add a frequency to comsys (Always numbers, under 8)
+com/remfreq or +comsys/remfreq: Remove a frequency from comsys.

@create Comsys System
@set Comsys System = WIZARD
@set Comsys System = !NO_COMMAND
&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/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(default(%#/comsys`freq,00000000),%i0%r,|,[space(18)])][ansi(g,[repeat(-,50)])],[ansi(hr,-)]%bYou don't have a comsys.)]
&CMD`+COMSYS/ADDFREQ Comsys System=$+comsys/addfreq *:@pemit %#=[switchall([u(fun`uselock,%#,%0)],*,[u(fun`error_string_off,#$)],101,[ansi(hg,-)]%bYou add [rjust(%0,8,0)] to the comsys frequency list.[attrib_set(%#/comsys`freq,[setunion([default(%#/comsys`freq,)],[rjust(%0,8,0)],|,|)])],[ansi(hrf,Code Error)])]
&CMD`+COMSYS/BROADCAST Comsys System=$+comsys/broadcast *:@pemit %#=[switchall([u(fun`uselock,%#,1)],?1?,[u(fun`error_string,#$)],101,[u(fun`transmit,%0,[default(%#/comsys`freq,00000000)])],[ansi(hrf,Code Error)])]
&CMD`+COMSYS/FREQ Comsys System=$+comsys/freq *=*:@pemit %#=[switchall([u(fun`uselock,%#,%0)],*,[u(fun`error_string_off,#$)],101,[ansi(hg,-)]%bYou add [rjust(%0,8,0)] to the comsys frequency list.[attrib_set(%#/comsys`freq,[setunion([default(%#/comsys`freq,)],[rjust(%0,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_freq,%#,%0)],*,[u(fun`error_string_off,#$)],101,[ansi(hg,-)]%bYou remove [rjust(%0,8,0)] from the comsys frequency list.[attrib_set(%#/comsys`freq,[setdiff([default(%#/comsys`freq,)],[rjust(%0,8,0)],|,|)])],[ansi(hrf,Code Error)])]
&CMD`+COMSYS/TRANSMIT Comsys System=$+comsys/transmit *:@pemit %#=[switchall([u(fun`uselock,%#,1)],*,[u(fun`error_string_off,#$)],101,[u(fun`transmit,%0)],[ansi(hrf,Code Error)])]
&FUN Comsys System=
&FUN`ERROR_STRING Comsys System=[switch(%0,0*,[ansi(hr,-)]%bYou don't have a comsys.,10*,[ansi(hr,-)]%bYour comsys is already turned on.,[ansi(hrf,Code Error)])]
&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=[null(iter([squish(iter(lsearch(all,type,player),switch(u(fun`uselock,%i0,1),101,%i0:[lmath(or,iter(default(%i0/comsys`freq,00000000),[t(match(default(%#/comsys`freq,00000000),%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,|)])]