@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ Paradox's Multi-Channel Communicator Parent @@ Version 1.0 @@ @@ INSTALLATION: Quote this file into your MUSH using your SPACE wizard character. @@ @@ Email: wayne@paradox.nashlink.net @@ MUSH: paradox.nashlink.net:1701 (@mail Wayne) @@ @@ Feel free to change the code to suit your MUSH's needs but please do NOT @@ redistribute without my permission. @@ @@ ATTRIBUTES TO CUSTOMISE: @@ RANGE - sets the transmission range in SUs (default: 100) @@ CHANNELS - sets the number of channels (default: 3) @@ BANDWITH - sets the bandwith for each channel frequency (default: 0.05) @@ DEVICENAME - sets the name of the device (default: Communicator) @@ SHORT_DESC - a short description of the device @create $MASTER: Communicator Parent v1.0 @set $MASTER: Communicator Parent v1.0 = WIZARD @set $MASTER: Communicator Parent v1.0 = NO_COMMAND @DESCRIBE $MASTER: Communicator Parent v1.0=[u(short_desc)] @ADROP $MASTER: Communicator Parent v1.0=@lock/use me==me @ASUCCESS $MASTER: Communicator Parent v1.0=@lock/use me==%# &CREDITS $MASTER: Communicator Parent v1.0=Created By Wayne @ Paradox (paradox.nashlink.net:1701) &HELP_MSG $MASTER: Communicator Parent v1.0=[u(header_l,[v(devicename)] Help,79)]%r%rcd on[space(27)]Turns the device on.%rcd off[space(26)]Turns the device off.%rcd tran [space(18)]Sets the transponder frequency.%rcd name =[space(7)]Sets the name for a channel.%rcd alias =[space(5)]Sets the alias for a channel.%rcd freq =[space(7)]Sets the frequency for a channel.%rcd enc =[space(2)]Sets the encryption for a channel.%rcd tog [space(15)]Toggles a channel on/off.%rcd stat[space(25)]Brings up device information.%rcd help[space(25)]Shows this help file.%rp2p \[=\][space(8)]Sends message to player.%r- [space(12)]Sends message over channel.%r- [space(21)]Sends message over last used channel.%r%r[repeat([ansi(bh,-)],79)] &CMD_COMM_HELP $MASTER: Communicator Parent v1.0=$cd hel*:@pemit %#=[u(help_msg)] @STARTUP $MASTER: Communicator Parent v1.0=th [iter([lnuma([v(channels)])],[switch([v(CHAN_##)],,[set(me,CHAN_##:1)])][switch([v(CHANNAME_##)],,[set(me,CHANNAME_##:Unused Channel)])][switch([v(CHANALIAS_##)],,[set(me,CHANALIAS_##:CH##)])])];@switch [v(status)]=1,{th [cdb(a)][cdb(s,1,1000)][cdb(s,1,1000)];@switch [cdb(c)]=#-*,{@emit [v(devicename)] error.;&status me=0)]}} &HEADER_L $MASTER: Communicator Parent v1.0=[switch([lt(%1,[add([strlen(%0)],6)])],#-*,[switch(%1,,#-1 FUNCTION \(HEADER_L\) EXPECTS 2-4 ARGUMENTS,#-1 INVALID LENGTH)],1,#-1 INVALID LENGTH,[ansi([switch(%2,,bh,%2)],--)][ansi([switch(%2,,bh,%2)],\[)][ansi([switch(%3,,yh,%3)],%0)][ansi([switch(%2,,bh,%2)],\])][ansi([switch(%2,,bh,%2)],--)][repeat([ansi([switch(%2,,bh,%2)],-)],[sub([sub(%1,6)],[strlen(%0)])])])] &INC_GENMSG $MASTER: Communicator Parent v1.0=[switch([or(hastype(loc(me),player),hastype(loc(me),thing))],1,[switch([words([setr(0,[iter([lnuma([v(channels)])],[switch([v(CHANSTATUS_##)],1,[switch([and([lte(%0,add(v(chan_##),v(bandwith)))],[gte(%0,sub(v(chan_##),v(bandwith)))])],1,##)])])])])],0,,[pemit(loc(me),[ansi(b,\[)][ansi(ch,COMM:[v(CHANALIAS_[first(%q0)])])][ansi(b,\])] [ansi(wh,[name(%1)]:)] [switch([last(%8,|)],1,[decrypt(%9,[v(CHANENC_[first(%q0)])])],%9)])])] &INC_P2PMSG $MASTER: Communicator Parent v1.0=[switch([last(%8,|)],[loc(me)],[pemit([loc(me)],[ansi(b,\[)][ansi(ch,P2P->[name(loc(me))])][ansi(b,\])] [ansi(wh,[name(%1)]:)] %9)][oemit([loc(me)],[name([loc(me)])]'s [v(devicename)] chirps followed by a voice saying\, "%9")])] &EXECUTE $MASTER: Communicator Parent v1.0=[switch([first(%8,|)],GEN,[u(me/inc_genmsg,%0,%1,%2,%3,%4,%5,%6,%7,%8,%9)],P2P,[u(me/inc_p2pmsg,%0,%1,%2,%3,%4,%5,%6,%7,%8,%9)])] &CMD_COMM_TRAN $MASTER: Communicator Parent v1.0=$cd tra* *:@switch [and([gte(%1,1)],[lte(%1,1000)])]=0,{@pemit %#=Invalid frequency.},{&TRANSPONDER me=[round(%1,3)];@pemit %#=You remove your [v(devicename)] and set the transponder to [round(%1,3)].;@oemit %#=%n removes %p [v(devicename)] and changes something on it.} &CMD_COMM_NAME $MASTER: Communicator Parent v1.0=$cd nam* *=*:@switch [and([gte(%1,0)],[lte(%1,[v(channels)])])]=0,{@pemit %#=Invalid channel.},{&CHANNAME_%1 me=[switch(%2,,[pemit(%#,You remove your [v(devicename)] and reset the name on channel %1.)]Unnamed Channel[oemit(%#,%n removes %p [v(devicename)] and changes something on it.)],[left(%2,30)][pemit(%#,You remove your [v(devicename)] and set the name on channel %1 to [left(%2,30)].)][oemit(%#,%n removes %p [v(devicename)] and changes something on it.)])]} &CMD_COMM_ALIAS $MASTER: Communicator Parent v1.0=$cd ali* *=*:@switch [and([gte(%1,0)],[lte(%1,[v(channels)])])]=0,{@pemit %#=Invalid channel.},{&CHANALIAS_%1 me=[switch(%2,,[pemit(%#,You remove your [v(devicename)] and reset the alias on channel %1.)]CH%1[oemit(%#,%n removes %p [v(devicename)] and changes something on it.)],[left(%2,4)][pemit(%#,You remove your [v(devicename)] and set the alias on channel %1 to [left(%2,4)].)][oemit(%#,%n removes %p [v(devicename)] and changes something on it.)])]} &CMD_COMM_INFO $MASTER: Communicator Parent v1.0=$cd sta*:@pemit %#=[u(header_l,[v(devicename)] Status,79)]%r[rjust([ansi(c,Status:)],17)]%b[ljust([switch([v(status)],1,Active,Inactive)],20)][rjust([ansi(c,Channels:)],17)]%b[val([v(channels)])]%r[rjust([ansi(c,Range:)],17)]%b[ljust([round([v(range)],2)],20)][rjust([ansi(c,Bandwith:)],17)]%b+/-[v(bandwith)]%bGHz%r[rjust([ansi(c,Transponder:)],17)]%b[round([v(TRANSPONDER)],3)] GHz%r[repeat([ansi(b,-)],79)]%r[ansi(c,\#)][ansi(c,\#)]%b[ansi(c,Frequency)]%b[ljust([ansi(c,Channel Name)],35)]%b[ljust([ansi(c,Encryption)],26)]%b[ansi(c,Sta)]%r[ansi(b,[repeat(-,2)]%b[repeat(-,9)]%b[repeat(-,35)]%b[repeat(-,26)]%b[repeat(-,3)])][iter([lnuma([v(channels)])],%r[rjust(#@,2)]%b[ljust([round([v(CHAN_##)],3)],9)]%b[ljust([v(CHANNAME_##)][switch([v(CHANALIAS_##)],,,%b\([v(CHANALIAS_##)]\))],35)]%b[ljust([switch([v(CHANENC_##)],,,[v(CHANENC_##)])],26)]%b[switch([v(CHANSTATUS_##)],1,ON,OFF)])]%r[repeat([ansi(bh,-)],79)] &CMD_COMM_FREQ $MASTER: Communicator Parent v1.0=$cd fre* *=*:@switch [and([gte(%1,0)],[lte(%1,[v(channels)])])]=0,{@pemit %#=Invalid channel.},{@switch [and([gte(%2,1)],[lte(%2,1000)])]=0,{@pemit %#=Invalid frequency.},{&CHAN_%1 me=[round(%2,3)];@pemit %#=You remove your [v(devicename)] and set the frequency on channel %1 to [round(%2,3)].;@oemit %#=%n removes %p [v(devicename)] and changes something on it.}} &CMD_P2P $MASTER: Communicator Parent v1.0=$p2p *:@switch [and([switch([setr(4,[before(%0,=)])],,0,1)],[switch([setr(5,[after(%0,=)])],,0,1)])]=1,{@switch [v(status)]=1,{@switch [setr(2,[pmatch(%q4)])]=#-*,{@pemit %#=Invalid player.},{&last_p2p me=%q4;@switch [or([not([hasflag([setr(1,[zone(loc(%q2))])],space-object)])],[not([hasflag([setr(0,[zone(loc(%#))])],space-object)])])]=1,{@Pemit %#=[ansi(b,\[)][ansi(ch,P2P->[name(%q2)])][ansi(b,\])] [ansi(wh,%n:)] %q5 [ansi(rh,\(FAILED\))];@oemit %#=%n taps %p [v(devicename)] and says, "%q5", but it is followed by a tone indicating it failed to send.},{@switch [lte([setr(4,[switch(left(setr(3,[sdb(f,[get(%q0/sdb)],r,[get(%q1/sdb)])]),1),\[,[pc2su([val([mid(%q3,1,5)])])],%q3)])],[v(range)])]=0,{@pemit %#=[ansi(b,\[)][ansi(ch,P2P->[name(%q2)])][ansi(b,\])] [ansi(wh,%n:)] %q5 [ansi(rh,\(FAILED\))];@oemit %#=%n taps %p [v(devicename)] and says, "%q5", but it is followed by a tone indicating it failed to send.},{@switch [words([iter([lcon(%q2)],[switch([get(##/COMMDEVICE)][get(##/STATUS)],11,##)])])]=0,{@Pemit %#=[ansi(b,\[)][ansi(ch,P2P->[name(%q2)])][ansi(b,\])] [ansi(wh,%n:)] %q5 [ansi(rh,\(FAILED\))];@oemit %#=%n taps %p [v(devicename)] and says, "%q5", but it is followed by a tone indicating it failed to send.},{@Pemit %#=[ansi(b,\[)][ansi(ch,P2P->[name(%q2)])][ansi(b,\])] [ansi(wh,%n:)] %q5;th cdb(t,1,[v(range)],P2P|%q2,%q5);@oemit %#=%n taps %p [v(devicename)] and says, "%q5"}}}}},{@pemit %#=You tap your [v(devicename)] and notice it's not active.;@oemit %#=%n taps %p [v(devicename)] and notices it's not active.}},{th [setq(4,[v(last_p2p)])][setq(5,%0)];@switch [v(status)]=1,{@switch [setr(2,[pmatch(%q4)])]=#-*,{@pemit %#=Invalid player.},{&last_p2p me=%q4;@switch [or([not([hasflag([setr(1,[zone(loc(%q2))])],space-object)])],[not([hasflag([setr(0,[zone(loc(%#))])],space-object)])])]=1,{@Pemit %#=[ansi(b,\[)][ansi(ch,P2P->[name(%q2)])][ansi(b,\])] [ansi(wh,%n:)] %q5 [ansi(rh,\(FAILED\))];@oemit %#=%n taps %p [v(devicename)] and says, "%q5", but it is followed by a tone indicating it failed to send.},{@switch [lte([setr(4,[switch(left(setr(3,[sdb(f,[get(%q0/sdb)],r,[get(%q1/sdb)])]),1),\[,[pc2su([val([mid(%q3,1,5)])])],%q3)])],[v(range)])]=0,{@pemit %#=[ansi(b,\[)][ansi(ch,P2P->[name(%q2)])][ansi(b,\])] [ansi(wh,%n:)] %q5 [ansi(rh,\(FAILED\))];@oemit %#=%n taps %p [v(devicename)] and says, "%q5", but it is followed by a tone indicating it failed to send.},{@switch [words([iter([lcon(%q2)],[switch([get(##/COMMDEVICE)][get(##/STATUS)],11,##)])])]=0,{@Pemit %#=[ansi(b,\[)][ansi(ch,P2P->[name(%q2)])][ansi(b,\])] [ansi(wh,%n:)] %q5 [ansi(rh,\(FAILED\))];@oemit %#=%n taps %p [v(devicename)] and says, "%q5", but it is followed by a tone indicating it failed to send.},{@Pemit %#=[ansi(b,\[)][ansi(ch,P2P->[name(%q2)])][ansi(b,\])] [ansi(wh,%n:)] %q5;th cdb(t,1,[v(range)],P2P|%q2,%q5);@oemit %#=%n taps %p [v(devicename)] and says, "%q5"}}}}},{@pemit %#=You tap your [v(devicename)] and notice it's not active.;@oemit %#=%n taps %p [v(devicename)] and notices it's not active.}} &CMD_COMM_OFF $MASTER: Communicator Parent v1.0=$cd off:@switch [v(status)]=0,{@pemit %#=Your [v(devicename)] is already off.},{@pemit %#=You tap your [v(devicename)] and it deactivates with a chirp.;@oemit %#=%n taps %p [v(devicename)] and it deactivates with a chirp.;&status me=0;th cdb(d)} &CMD_COMM_ON $MASTER: Communicator Parent v1.0=$cd on:@switch [v(status)]=1,{@pemit %#=Your [v(devicename)] is already on.},{@pemit %#=You tap your [v(devicename)] and it activates with a chirp.;@oemit %#=%n taps %p [v(devicename)] and it activates with a chirp.;&status me=1;@trig me/startup} &CMD_SENDMSG_LASTCHAN $MASTER: Communicator Parent v1.0=$- *:@switch [and([gte([val([setr(0,[v(lastchan)])])],0)],[lte(%q0,[v(channels)])])]=0,{@pemit %#=Invalid channel.},{@switch [v(status)]=0,{@pemit %#=You tap your [v(devicename)] and notice it's not active.;@oemit %#=%n taps %p [v(devicename)] and notices it's not active.},{@switch [t([v(chanstatus_%q0)])]=0,{@pemit %#=Channel %q0 is not active.},{&lastchan me=%q0;th cdb(t,[v(chan_%q0)],[v(range)],GEN|[switch([v(chanenc_%q0)],,0,1)],[encrypt(%0,[v(chanenc_%q0)])]);@oemit %#=%n taps %p [v(devicename)] and says, "%0"}}} &CMD_SENDMSG_CHAN $MASTER: Communicator Parent v1.0=$-? *:@switch [and([gte(%0,0)],[lte(%0,[v(channels)])])]=0,{@pemit %#=Invalid channel.},{@switch [v(status)]=0,{@pemit %#=You tap your [v(devicename)] and notice it's not active.;@oemit %#=%n taps %p [v(devicename)] and notices it's not active.},{@switch [t([v(chanstatus_%0)])]=0,{@pemit %#=Channel %0 is not active.},{&lastchan me=%0;th cdb(t,[v(chan_%0)],[v(range)],GEN|[switch([v(chanenc_%0)],,0,1)],[encrypt(%1,[ v(chanenc_%0)])]);@oemit %#=%n taps %p [v(devicename)] and says, "%1"}}} &CMD_COMM_ENC $MASTER: Communicator Parent v1.0=$cd enc* *=*:@switch [and([gte(%1,0)],[lte(%1,[v(channels)])])]=0,{@pemit %#=Invalid channel.},{&CHANENC_%1 me=[switch(%2,,[pemit(%#,You remove your [v(devicename)] and clear the encryption on channel %1.)][oemit(%#,%n removes %p [v(devicename)] and changes something on it.)],%2[pemit(%#,You remove your [v(devicename)] and set the encryption on channel %1 to %2.)][oemit(%#,%n removes %p [v(devicename)] and changes something on it.)])]} &CMD_COMM_CHAN $MASTER: Communicator Parent v1.0=$cd tog* *:@switch [and([gte(%1,0)],[lte(%1,[v(channels)])])]=0,{@pemit %#=Invalid channel.},{&CHANSTATUS_%1 me=[switch([v(CHANSTATUS_%1)],0,1[pemit(%#,You remove your [v(devicename)] and set channel %1 on.)][oemit(%#,%n removes %p [v(devicename)] and changes something on it.)],0[pemit(%#,You remove your [v(devicename)] and set channel %1 off.)][oemit(%#,%n removes %p [v(devicename)] and changes something on it.)])]} &SHORT_DESC $MASTER: Communicator Parent v1.0=You see an ordinary [v(devicename)]. &RANGE $MASTER: Communicator Parent v1.0=100 &CHANNELS $MASTER: Communicator Parent v1.0=3 &DEVICENAME $MASTER: Communicator Parent v1.0=Communicator &BANDWITH $MASTER: Communicator Parent v1.0=0.05 &COMMDEVICE $MASTER: Communicator Parent v1.0=1 &TRANSPONDER $MASTER: Communicator Parent v1.0=1 &STATUS $MASTER: Communicator Parent v1.0=0 &LAST_P2P $MASTER: Communicator Parent v1.0=Noone &LASTCHAN $MASTER: Communicator Parent v1.0=1 &CHAN_1 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_1 $MASTER: Communicator Parent v1.0=CH1 &CHANENC_1 $MASTER: Communicator Parent v1.0= &CHANNAME_1 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_1 $MASTER: Communicator Parent v1.0=0 &CHAN_2 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_2 $MASTER: Communicator Parent v1.0=CH2 &CHANENC_2 $MASTER: Communicator Parent v1.0= &CHANNAME_2 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_2 $MASTER: Communicator Parent v1.0=0 &CHAN_3 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_3 $MASTER: Communicator Parent v1.0=CH3 &CHANENC_3 $MASTER: Communicator Parent v1.0= &CHANNAME_3 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_3 $MASTER: Communicator Parent v1.0=0 &CHAN_4 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_4 $MASTER: Communicator Parent v1.0=CH4 &CHANENC_4 $MASTER: Communicator Parent v1.0= &CHANNAME_4 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_4 $MASTER: Communicator Parent v1.0=0 &CHAN_5 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_5 $MASTER: Communicator Parent v1.0=CH5 &CHANENC_5 $MASTER: Communicator Parent v1.0= &CHANNAME_5 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_5 $MASTER: Communicator Parent v1.0=0 &CHAN_6 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_6 $MASTER: Communicator Parent v1.0=CH6 &CHANENC_6 $MASTER: Communicator Parent v1.0= &CHANNAME_6 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_6 $MASTER: Communicator Parent v1.0=0 &CHAN_7 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_7 $MASTER: Communicator Parent v1.0=CH7 &CHANENC_7 $MASTER: Communicator Parent v1.0= &CHANNAME_7 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_7 $MASTER: Communicator Parent v1.0=0 &CHAN_8 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_8 $MASTER: Communicator Parent v1.0=CH8 &CHANENC_8 $MASTER: Communicator Parent v1.0= &CHANNAME_8 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_8 $MASTER: Communicator Parent v1.0=0 &CHAN_9 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_9 $MASTER: Communicator Parent v1.0=CH9 &CHANENC_9 $MASTER: Communicator Parent v1.0= &CHANNAME_9 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_9 $MASTER: Communicator Parent v1.0=0 &CHAN_10 $MASTER: Communicator Parent v1.0=1.000 &CHANALIAS_10 $MASTER: Communicator Parent v1.0=CH10 &CHANENC_10 $MASTER: Communicator Parent v1.0= &CHANNAME_10 $MASTER: Communicator Parent v1.0=Unnamed Channel &CHANSTATUS_10 $MASTER: Communicator Parent v1.0=0 @@ Communicator Maker @@ @@ Set the D_PARENT attribute in the code below to reflect the DBref of your @@ Master Communicator Parent. @@ @@ INSTALLATION: @create a new Communicator Maker, parent it to the Communicator @@ Maker Parent and @set the object !NO_COMMAND and WIZARD. It should be owned by @@ your SPACE wizard character. Typing 'makecomm' will then issue the player with @@ a working Communicator @create $MASTER: Communicator Maker Parent @desc $MASTER: Communicator Maker Parent=Type 'makecomm'. &D_PARENT $MASTER: Communicator Maker Parent=#380 &CMD_MAKECOMM $MASTER: Communicator Maker Parent=$makecomm:@name [setr(0,[create(Communicator)])]=Communicator \([delete(%q0,0,1)]\);@set %q0=wizard;@set %q0=!no_command;@parent %q0=[v(D_PARENT)];@cpattr [v(D_PARENT)]/startup=%q0;@lock/use %q0==%#;@tel %q0=%#;@pemit %#=You have been issued with [name(%q0)].