NTSL Scripts: Difference between revisions

From Yogstation-13
Jump to navigation Jump to search
imported>Kosmos
m (Undo revision 9612 by Kosmos (talk) No wait oh fuck, the scripts can be fixed.)
m (Indicates that the page needs revising due to being outdated.)
 
(42 intermediate revisions by 13 users not shown)
Line 1: Line 1:
Script repository. Place your [[NT Script|NT Scripts]] here.
{{Needs revision
|reason = Scripts are out of date compared to ingame.
|user = [[User:HauntedOwl28|HauntedOwl28]] ([[User talk:HauntedOwl28|talk]]) 07:14, 19 April 2022 (EST)
}}


More in [http://forums.nanotrasen.com/viewtopic.php?f=3&t=8147 this thread].
Most of these scripts are compatable, but there are conflicts. The sequence of things is important. Definitely room for improvement. All scripts need the global '''def process_signal(sig){''' as a header and '''return sig;}''' as a footer, unless specified otherwise. e.g.:


==Old Scripts Archive for Older Revisions==
<pre>
NOTE: These scripts don't work on the new telecommunications-code. They are archived here in case you are using an older revision of tgstation-code.
def process_signal(sig){ // Header.
{| class="mw-collapsible mw-collapsed wikitable"
|-
!
|-
| scope="row" |
===Less Annoying Job Indicator===
Only shows abbreviations of job titles instead of full titles.<br>


<pre>//code shamelessly copied and pasted from Giacom's pirate script
if(sig.source=="Zion Freeman"){ sig.job="Nerd"; } // Some script.


def Initialize() {
sig.source+=" ("+sig.job+")"; // More script.
$words = vector(
 
    "Assistant", "Assnt",
return sig;} // Footer.
    "Captain", "Capt",
</pre>
    "Head of Personnel", "HoP",
 
    "Bartender", "Bar",
'''[[NT_Script#Simple_Guide_to_Using_Scripts|For a guide how to use these scripts look here.]]'''
    "Chef", "Chef",
 
    "Botanist", "Hydro",
== Useful Scripts ==
    "Quartermaster", "QM",
=== Job Indicator ===
    "Cargo Technician", "Cargo",
Jobs will appear in brackets after names.
    "Shaft Miner", "Miner",
 
    "Clown", "Clown",
<pre>
    "Mime", "Mime",
sig.source+=" ("+sig.job+")";
    "Janitor", "Jan-r",
</pre>
    "Librarian", "Lib-n",
 
    "Lawyer", "Law",
=== Abbr. Job Indicator ===
    "Chaplain", "Chapl",
Gives abbreviations instead of full titles.
    "Chief Engineer", "CE",
 
    "Station Engineer", "Engi",
<pre>
    "Atmospheric Technician", "Atmos",
//Abbr. Job Indicator - by TheDL
    "Chief Medical Officer", "CMO",
 
    "Medical Doctor", "MD",
jobs=list("Admiral", "Adm", "Assistant", "Ass", "Atmospheric Technician", "Atmo", "Bartender", "Bar", "Botanist", "Hydr", "Captain", "Cap", "Cargo Technician", "Carg", "Chaplain", "Chap", "Chemist", "Chem", "Chief Engineer", "CE", "Chief Medical Officer", "CMO", "Clerk", "Clrk", "Clown", "Clwn", "Curator", "Cura", "Detective", "Det", "Geneticist", "Gene", "Head of Personnel", "HoP", "Head of Security", "HoS", "Janitor", "Jani", "Lawyer", "Law", "Librarian", "Lib", "Medical Doctor", "MD", "Mining Medic", "Medi", "Paramedic", "Para", "Psychiatrist", "Psyc", "Quartermaster", "QM", "Research Director", "RD", "Roboticist", "Robo", "Scientist", "Sci", "Security Officer", "Sec", "Shaft Miner", "Mine", "Signal Technician", "Sig", "Station Engineer", "Engi", "Tourist", "Tour", "Unassigned", "Unas", "Unknown", "Unkn", "Virologist", "Viro", "Warden", "Ward", "Personal AI", "pAI", "Default Cyborg", "DefB", "Engineering Cyborg", "EngB", "Janitor Cyborg", "JanB", "Medical Cyborg", "MedB", "Miner Cyborg", "MnrB", "Peacekeeper Cyborg", "PceB", "Security Cyborg", "SecB", "Service Cyborg", "SrvB", "Standard Cyborg", "StnB");
    "Chemist", "Chem",
 
    "Geneticist", "G-tic",
if(find(jobs,sig.job)){ sig.job=jobs[find(jobs,sig.job)+1]; }
    "Virologist", "Viro",
sig.source+="["+sig.job+"]";
    "Research Director", "RD",
</pre>
    "Scientist", "Sci",
 
    "Roboticist", "Robo",
=== Spam Jammer ===
    "Head of Security", "HoS",
Blocks hulkouts and tourettes ticks.
    "Warden", "Ward",
 
    "Detective", "D-tiv",
<pre>
    "Security Officer", "Sec",
if(find(list("RAAAAAAAARGH!!!", "HNNNNNNNNNGGGGGGH!!!",
    "AI", "AI",
"GWAAAAAAAARRRHHH!!!", "NNNNNNNNGGGGGGGGHH!!!",
    "Cyborg", "Borg",
"AAAAAAARRRGH!!!", "CUNT", "FUCK", "PISS", "SHIT", "TITS",
    "Personal AI", "pAI",
"COCKSUCKER", "MOTHERFUCKER"), sig.content)){ sig.pass=0;}
    );
</pre>
   
 
    $index = 1;
 
  while($index <= length($words))
=== Anonymous Messages ===
{
Messages starting with '''/anon''' will broadcast under the name "Anonymous".
  mem(at($words, $index), at($words, $index+1));
 
   $index += 2;
<pre>
  }
// Anonymous Messages - by TheDL
 
x=explode(sig.content," ");
if(x[1]=="/anon"){ sig.pass=0;
broadcast(signal(implode(x-x[1]," "), sig.freq, "Anonymous")); }
 
// This one preserves language...
 
x=explode(sig.content," ");
if(x[1]=="/anon"){ sig.pass=0;
anon=signal(implode(x-x[1]," "), sig.freq, "Anonymous");
anon.language=sig.language; broadcast(anon); }
 
// ...this one randomizes filters, too.
 
x=explode(sig.content," ");
if(x[1]=="/anon"){ sig.pass=0; a=list("italics", "robot", "sans", "yell");
anon=signal(implode(x-x[1]," "), sig.freq, "Anonymous");
n=1; while(n<length(a)){ if(prob(50)){ anon.filters+=a[n]; } n+=1; }
anon.language=sig.language; broadcast(anon); }
</pre>
 
=== Broadcast to All ===
Messages starting with '''/all''' will be broadcasted to all departments, and common. Admins hate this, though. Expect to get bwoinked.
 
<pre>
// Broadcast to All - by TheDL
 
x=explode(sig.content," ");
freqs=list( 1459, 1447, 1359, 1357, 1355, 1353, 1351, 1349, 1347);
if(x[1]=="/all"){ sig.pass=0; sig.content=implode(x-x[1]," "); n=1;
while(n<=length(freqs)){ sig.freq=freqs[n]; broadcast(sig); n+=1; } }
</pre>
 
=== Broadcast to Any or All ===
Messages starting with a channel code will be broadcast to the corresponding department. The channel codes are '''/c''' for command, '''/e''' for engineering, '''/m''' for medical, '''/n''' for science, '''/o''' for AI private, '''/s''' for security, '''/u''' for supply, and '''/v''' for service. As above, messages starting with '''/all''' will be broadcasted to all departments, and common. Again, admins hate this. Expect to get bwoinked.
 
<pre>
// Broadcast to Any or All - by TheDL
 
x=explode(sig.content," ");
freqs=list( 1459, 1447, 1359, 1357, 1355, 1353, 1351, 1349, 1347);
codes=list( "/all", "/o", "/s", "/e", "/m", "/c", "/n", "/v", "/u");
if(find(codes,x[1])){ n=find(codes,x[1]); sig.content=implode(x-x[1]," ");
if(codes[n]!="/all"){ sig.freq=freqs[n]; } else{ sig.pass=0; n=1;
   while(n<=length(freqs)){ sig.freq=freqs[n]; broadcast(sig); n+=1; } } }
</pre>
 
 
=== Phrase Toggle ===
Enable or disable a script using a phrase. Any phrase can be used. Add the script to be toggled where indicated. User restricted, message blocked. Remove '''&&sig.source=="Your Name"''' to let anyone use it. Remove '''sig.pass=0;''' to not block the message.
 
<pre>
// Phrase Toggle - By TheDL
 
toggle="Phrase"; if(find(sig.content,toggle)&& sig.source=="Your Name"){
  sig.pass=0; if(mem(toggle)!=1){ mem(toggle,1); } else{ mem(toggle,0); } }
if(mem(toggle)==1){
// Insert script here.
}
}
</pre>
=== Pun Pun Teller ===
Say '''/pun''' to have the Ghost of Pun Pun tell an awful pun!
<pre>
// Pun Pun Teller - by TheDL
exp=explode(sig.content," ");
if(exp[1]=="/pun"){ sig.pass=0;
broadcast(signal(pick("Did you hear about the guy that got cut in half? Don't worry, he's all right now.", "I started a business selling landmines disguised as prayer mats. Prophets are going through the roof!", "Why don't thieves get puns? Because they take things literally.", "My dog has no nose. How does he smell? Awful.", "A man entered ten puns in a pun contest, hoping that one would win. Unfortunately, no pun in ten did."),sig.freq,"The Ghost of Pun Pun"));}
</pre>
== Annoying and Malicious Scripts ==
=== _ the Hedgehog ===
_ the Hedgehog exclaims: "_ Gotta go fast!"
<pre>
sig.source+=" the Hedgehog";
sig.content+=" Gotta go fast!";
sig.filters=list("italics");
</pre>
=== Auto Tourettes ===
Two versions. First replaces all of a random word in every message. Second randomly replaces entire messages, '''prob()''' being the percent chance of this. Use '''prob(100)''' to replace all messages.
<pre>
// Auto Tourettes, for random words...
sig.content=replace(sig.content,pick(explode(sig.content," ")),pick("SHIT", "FUCK", "COCKSUCKER", "BULLSHIT", "CUNT", "MOTHERFUCKER"));
// ...or random messages.
if(prob(20)){ sig.content=pick("SHIT", "FUCK", "COCKSUCKER", "BULLSHIT", "CUNT", "MOTHERFUCKER");}
</pre>
=== HONK! ===
Replace every word of every message with HONK!
<pre>
sig.content=repeat("HONK! ",length(explode(sig.content," "))-1);
sig.content=substr(sig.content, 1, length(sig.content));
</pre>
=== La Revolution! ===
Prevents heads of staff from using the radio.
<pre>
if(find(list("Captain", "Chief Engineer", "Chief Medical Officer", "Head of Personnel", "Head of Security", "Research Director"), sig.job)){ sig.pass=0;}
</pre>
=== No Shuttle Calls ===
Blocks messages containing any of the words on the list.
<pre>
block=list("call", "shuttle", "rogue", "rouge", "malf");
n=1; while(n<=length(block)){ if(find(sig.content,block[n])){ sig.pass=0; } n+=1; }
</pre>
=== Forced Singing ===
Replaces messages with lyrics, in this case those of Always Look on the Bright Side of Life. Say '''/sing Full Name''' to toggle a specific person. Say '''/sing all''' to toggle everyone. Say '''/sing pause''' to pause or unpause the singing.
<pre>
// Forced Singing - by TheDL
song=list("Some things in life are bad,", "They can really make you mad.", "Other things just make you swear and curse.", "When you're chewing on life's gristle,", "Don't grumble, give a whistle!", "And this'll help things turn out for the best...", "And... always look on the bright side of life... tudum, tudu-tudu-tudum.", "Always look on the light side of life... tudum, tudu-tudu-tudum.", "If life seems jolly rotten,", "There's something you've forgotten,", "And that's to laugh and smile and dance and sing.", "When you're feeling in the dumps,", "Don't be silly, chumps!", "Just purse your lips and whistle -- that's the thing!", "And... always look on the bright side of life... tudum, tudu-tudu-tudum.", "Always look on the light side of life... tudum, tudu-tudu-tudum.", "For life is quite absurd,", "And death's the final word.", "You must always face the curtain with a bow.", "Forget about your sin, give the audience a grin.", "Enjoy it - it's your last chance anyhow!", "So... always look on the bright side of death, tudum, tudu-tudu-tudum.", "Just before you draw your terminal breath, tudum, tudu-tudu-tudum.", "Life's a piece of shit,", "When you look at it.", "Life's a laugh and death's a joke, it's true.", "You'll see it's all a show,", "Keep 'em laughing as you go.", "Just remember that the last laugh is on you.", "And, always look on the bright side of life... tudum, tudu-tudu-tudum.", "Always look on the right side of life... tudum tudu-tudu-tudum.", "Come on guys, cheer up!", "Always look on the bright side of life... tudum, tudu-tudu-tudum.", "Always look on the bright side of life... tudum, tudu-tudu-tudum.", "Worse things happen at sea, you know.", "Always look on the bright side of life... tudum, tudu-tudu-tudum.", "I mean, what you got to lose, you know? You come from nothing, you're going back to nothing. What you lost? Nothing!", "Always look on the right side of life... tudum, tudu-tudu-tudum.", "Nothing will come from nothing, you know what they say?", "Always look on the bright side of life... tudum, tudu-tudu-tudum...");
x=explode(sig.content," ");
y=mem("singers"); n=mem("lyrics");
if(y==null){ y=list(); y-=y[1]; mem("singers",y); }
if(n==null|| n>length(song)){ n=1; mem("lyrics",n); }
if(x[1]=="/sing"&& sig.source=="Your Name"){
sig.pass=0; x=implode(x-x[1]," ");
if(!find(y,x)){ y+=x; } else{ y-=x; } mem("singers",y); }
if(find(y,sig.source)|| find(y,"all")){ if(!find(y,"pause")){
  sig.pass=1; sig.content=song[n]; n+=1; mem("lyrics",n); } }
</pre>
=== Selective Mute ===
Say '''/mute Full Name''' to mute (or unmute) people. Use proper case and spelling. Say '''/muted''' to broadcast the list of people being muted. Should choose a channel other than '''1459''', though. Alternatively, omit broadcast entirely. Users restricted.
<pre>
// Selective Mute - by TheDL
x=explode(sig.content," ");
users=list("Your Name", "Zion Freeman", "Et Cetera");
if(mem("mute")==null){ m=list(); m-=m[1]; mem("mute",m); }
m=mem("mute"); if(find(users,sig.source)){
if(find(list("/mute", "/muted"),x[1])){ sig.pass=0;
  if(x[1]=="/mute"){ x=implode(x-x[1]," ");
  if(!find(m,x)){ m+=x; } else{ m-=x; } mem("mute",m); }
  else{ broadcast(signal(implode(m,", ")+".",1459)); } } }
if(find(m,sig.source)){ sig.pass=0; }
// Without broadcasting.
x=explode(sig.content," ");
users=list("Your Name", "Zion Freeman", "Et Cetera");
if(mem("mute")==null){ m=list(); m-=m[1]; mem("mute",m); }
m=mem("mute"); if(find(users,sig.source)&& x[1]=="/mute"){
sig.pass=0; x=implode(x-x[1]," ");
if(!find(m,x)){ m+=x; } else{ m-=x; } mem("mute",m); }
if(find(m,sig.source)){ sig.pass=0; }
</pre>


if(mem("initialized") != 1)
=== Simple Voice Synth ===
{
Say '''/voice N_ame J_ob Message''' to broadcast a message with a false identity. Use underscores for spaces in names or titles, and correct spelling and capitalization. Users restricted.
  Initialize();
<br>e.g.: Et Cetera exclaims: "/voice Is-a-Lizard Cargo_Technician I confess!"
  mem("initialized", 1);
<br>e.g.: [Common] Is-a-Lizard (Cargo Technician) exclaims: "I confess!"
}
<br>e.g.: Et Cetera says: "/voice Hugh_Man Head_of_Security Arrest the lizard."
<br>e.g.: [Common] Hugh Man (Head of Security) says: "Arrest the lizard."
 
<pre>
// Simple Voice Synth - by TheDL
 
x=explode(sig.content," ");
users=list("Your Name", "Zion Freeman", "Et Cetera");
if(find(users,sig.source)&& x[1]=="/voice"){
  sig.source=replace(x[2],"_"," "); sig.uuid=sig.source;
  sig.job=replace(x[3],"_"," "); x.Cut(1,4);
sig.content=implode(x," "); }
</pre>
 
 
== Useful Snippets and Functions ==
 
=== Quickcast ===
A broadcast function with a short name and predefined signal. Saves a lot of typing.
<br>Change the specifics, or remove them. Defaults to '''1459'''.
 
<pre>
// Quickcast, and avoid the hassle.


$foo = "";
def qc(x){ broadcast(signal(x,1459,"Name","Job")); }


if(mem($job)) { $foo = mem($job); }
// Optional command volume. Use loud($) or loud($,1)
else { $foo = substr($job, 1, 6); }


if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
def loud(x,y){ z=signal(x); if(y==1){ z.filters=list("command_headset"); } broadcast(z); }
$source = $source + " (" + $foo + ")"; }</pre>
</pre>


===Selective Mute===
=== Modulo ===
By Matilda.<br>
Returns the remainder of '''x/y'''. Good to six digits.
Turn a wall com to 146.1 to listen to the output of the script.<br>
authorize yourself via ;/authme PASSWORD, just say it on the general channel.<br>
then use ;/crewlist to find the ID of who you want to mute.<br>
then use ;/mute ID to mute them, and ;/unmute ID to unmute them.


<pre>$password = "<insert password here>";
<pre>
// Modulo, for numbers in either sign...


$originalsource = $source;
def mod(x,y) { z=1; if(x/y<0) { z=-1; } return x-(floor((x/y)*z)*z)*y; }
$originaljob = $job;
$me = 4;


if(!mem("crewnum")) {
// ...or, for positive numbers only.
  mem("crewnum",0);
}


$found = 0;
def mod(x,y) { return x-floor(x/y)*y; }
$counter = 0;
</pre>
$me = 0;
while($counter < mem("crewnum")) {
  if (mem("crewlistsource" + $counter) == $originalsource) {
      $me = $counter;
      $found = 1;
  }
  $counter = $counter + 1;
}


if ($found == 0) {
=== Digital Root ===
  $me = mem("crewnum");
Returns the digital root of '''x'''. Good to six digits. Ignores decimals.
  broadcast("Adding new user " + $originalsource + ", " + $originaljob + " to database at location " + mem("crewnum"),1461);
  mem("crewlistsource" + $me,$originalsource);
  mem("crewlistjob" + $me,$originaljob);
  mem("crewlistauth" + $me, 0);
  mem("crewlistmute" + $me, 0);
  mem("crewnum",mem("crewnum") + 1);
}


//HACK ALERT
<pre>
if ($me < 1) { $me = 0; }
// Digital root, for answers in either sign...


def dig(x){ if(x!=0){ y=1; if(x<0){ y=-1; } x-=(floor((x/9)*y)*y)*9; if(x==0){ x=9*y; } } return x; }


if(!mem("usermessagecount")) {
// ...or, for positive answers only.
  mem("usermessagecount",0);
}


$expld1 = explode($content, " ");
def dig(x){ if(x!=0){ if(x<0){ x=x*-1; } x-=floor(x/9)*9; if(x==0){ x=9; } } return x; }
if(at($expld1, 1) ==  "/crewlist") {
</pre>
  $counter = 0;
  while($counter < mem("crewnum")) {
      broadcast($counter + " - " + mem("crewlistsource" + $counter) + " - " + mem("crewlistjob" + $counter) + " - auth " + mem("crewlistauth" +
$counter) + " - mute " + mem("crewlistmute" + $counter),1461," "," ");
      $counter = $counter + 1;
  }
  $pass = 0;
}


$expld1 = explode($content, " ");
=== Log Base ===
if(at($expld1, 1) == "/who") {
NTSL's '''log()''' function is actually ''natural log'', base ''e'', not the typical base 10. This function here returns the log of '''x''' in base '''y'''. Null '''y''' defaults to 10. '''logb(x,E)''' gives natural log, too. Positive numbers only.
  broadcast(mem("crewlistsource" + at($expld1, 2)),1461);
  $pass = 0;
}


$expld1 = explode($content, " ");
<pre>
if(at($expld1, 1) == "/crewnum") {
def logb(x,y){ if(y==null){ y=10; } x=log(x)*(1/log(y)); return x; }
  broadcast(mem("crewnum"), 1461);
</pre>
  $pass = 0;
}


$expld1 = explode($content, " ");
=== Digit Length ===
if(at($expld1, 1) == "/myid") {
Returns the number of digits in '''x'''. Whole numbers only.
  broadcast("Your ID is " + $me, 1461);
  $pass = 0;
}


$expld1 = explode($content, " ");
<pre>
if(at($expld1, 1) ==  "/mute" && mem("crewlistauth" + $me) >= 2) {
def lengthn(x){ if(x<0){ x=x*-1; } x=log(x)*(1/log(10)); return floor(x)+1; }
  mem("crewlistmute" + at($expld1, 2),1);
</pre>
  broadcast(mem("crewlistsource" + at($expld1, 2)) + " has been muted.");
  $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/unmute" && mem("crewlistauth" + $me) >= 2) {
  mem("crewlistmute" + at($expld1, 2),0);
  broadcast(mem("crewlistsource" + at($expld1, 2)) + " has been unmuted.");
  $pass = 0;
}


$expld1 = explode($content, " ");
== Outdated Scripts ==
if(at($expld1, 1) == "/authme") {
  if(at($expld1, 2) == $password) {
      mem("crewlistauth" + $me, 2);
  }
  $pass = 0;
}


$expld1 = explode($content, " ");
===English To Mid-evil Translator===
if(at($expld1, 1) == "/announce" && mem("crewlistauth" + $me) >= 1) {
// English To Mid-evil Translator Script - By Hellafed
  broadcast(" ",$common," "," ");
  broadcast("ANNOUNCEMENT",$common," "," ");
  broadcast("  ",$common," "," ");
  broadcast("  ",$common," "," ");
  broadcast(upper(replace($content, "/announce", " ")),$common," "," ");
  broadcast("    ",$common," "," ");
  broadcast("    ",$common," "," ");
  $pass = 0;
}


if(mem("crewlistmute" + $me) == 1) {
This script initializes a list of words by using the mem() function as a hash table. By doing this it has to initialize first, if you are running this script and then add words later, you must clear the memory of the server first so it initializes again and learns the new words.
  //$pass = 0;
  $content = " ";
  $source = $originalsource + " (MUTED)";
}</pre>


After initialization, this transmission and the rest all skip to splitting the transmission's contents and check each word against the memory, using the word as a key. Because of not needing to loop through the list of words, this is a fast process. If it finds a valid word to replace, it will replace the word with the value that the key led to. Finally, after it is finished it will convert the vector into a string again and then replace the contents of the transmission with the final message. (Credit to Giacom for providing the code i used to create this)
<pre>// English To Mid-evil Translator Script - By Hellafed


===Cleaner Selective Mute===
// Helper Functions
Mute and unmute people merely by saying "/mute FULL NAME" the name has to be capitalized and spelled properly.<br>
Authorizes by one or more sources, but could be configured for a password if you really wanted to.<br>
Great for traitor AIs who don't want their victim screaming about the oxygen siphoning! <br>


<pre>//recursive implode function, takes a vector and
def implode($vector, $adder)
//combines each member into a string with a space to separate
{
//by perogi
$returnString = "";
$index = 1;


def implode($vector)
while($index <= length($vector))
{
$str = at($vector, 1);
remove($vector, $str);
if(length($vector) > 0)  
{
{
$str += " ";
$at = at($vector, $index);
$str += implode($vector);
$toAdd = $adder;
if($index == 1)
{
$toAdd = "";
}
$returnString = $returnString + $toAdd + $at;
$index += 1;
}
}
return $str;
return $returnString;
}
}  
//mute and unmute function
 
//use: type /mute or /unmute then the name of the person exactly as it is spelled
def Initialize()
//by perogi
if($source == "YOUR NAME HERE") //only the name in this line can use script
{
{
if(at(explode($content, " "), 1) == "/mute")
 
// Our words! Format: real word / mid evil word
$words = vector("gun", "cannon",
"my", "my own",
"security", "town watch",
"are", "art",
"yeah", "aye",
"captain", "King",
"hos", "Town Watch Commander",
"ce", "Head Builder",
"dead", "gone to Sovngarde",
          "rd", "Lead Scientist",
"assistant", "peasant",
"Borg", "dwarven automaton",
"Borgs", "dwarven automatons",
"cyborg", "dwarven automaton",
"cyborgs", "dwarven automatons",
"fucker", "milk drinker",
"syndicate", "dragons",
"brig", "dungeon",
"yours", "thine",
"you", "thou",
"do", "dost",
"has", "hath",
"nothing", "naught",
"thanks", "Grammarcy",
"hop", "Inn Manager",
"ai", "King's Servant",
"money", "gold coins",
"friend", "brother",
"station", "town",
"shuttle", "Wagon",
"engine", "waterwheel",
"space", "unknown");
 
//broadcast("Starting Initialization...");
$index = 1;
while($index <= length($words))
{
{
$vec = explode($content, " ");
$key = at($words, $index);
remove($vec, "/mute");
$key = lower($key);
$name = implode($vec);
$value = at($words, $index+1);
$pass = 0;
mem($key, $value);
mem($name,$name);
$index += 2;
}
if(at(explode($content, " "),1) == "/unmute")
{
$pass = 0;
$vec = explode($content, " ");
remove($vec, "/unmute");
mem(implode($vec), 0);
}
}
//broadcast("Initialization Complete!");
}
// Script Begin
if(mem("initialized") != 1)
{
Initialize();
mem("initialized", 1);
}
}
//checks if source is muted
//possible to get around mute by taking off ID and being unknown, hence why unknowns are all blocked
if($source == mem($source) || $source == "Unknown")
{
$pass = 0;
}</pre>
|}


$newContent = explode($content, " ");
$index = 1;
while($index <= length($newContent))
{
$entry = at($newContent, $index);
$value = mem(lower($entry));


==Useful Non-Malicious Scripts==
if($value)
=== Job Indicator ===
{
if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
at($newContent, $index, $value);
    $source = $source + " (" + $job + ")"; } // Add job next to people's names.
}
$index += 1;
}  


=== Arrivals Alert Modification ===
$content = implode($newContent, " ");
Separates the automated arrivals messages from the AI's deliberate messages.


if (find($content, "has signed up as")) { //Is the message an arrival message?
// Script End</pre>
    if ($job == "AI") { //Is it sent by the AI?
      $source = "Arrivals Alert System"; //Change the source of the message
    }
}


=== Anonymous Messages ===
===English To Pirate Translator===
Messages prefixed with "/anon" will hide their sender's identity.
This script initializes a list of words by using the mem() function as a hash table. By doing this it has to initialize first, if you are running this script and then add words later, you must clear the memory of the server first so it initializes again and learns the new words.


$explodeString = explode($content, " ");
After initialization, this transmission and the rest all skip to splitting the transmission's contents and check each word against the memory, using the word as a key. Because of not needing to loop through the list of words, this is a fast process. If it finds a valid word to replace, it will replace the word with the value that the key led to. Finally, after it is finished it will convert the vector into a string again and then replace the contents of the transmission with the final message.
if(at($explodeString, 1) ==  "/anon")
    {
        $pass = false;
        $content = substr($content, 6, length($content)+1);
        broadcast($content, $freq, "Anonymous");
    }


=== Less annoying job indicator ===
<pre>// English To Pirate Translator Script - By Giacom
Only shows abbreviations of job titles instead of full titles.


//code shamelessly copied and pasted from Giacom's pirate script
// Helper Functions
def Initialize() {
$words = vector(
    "Assistant", "Assnt",
    "Captain", "Capt",
    "Head of Personnel", "HoP",
    "Bartender", "Bar",
    "Chef", "Chef",
    "Botanist", "Hydro",
    "Quartermaster", "QM",
    "Cargo Technician", "Cargo",
    "Shaft Miner", "Miner",
    "Clown", "Clown",
    "Mime", "Mime",
    "Janitor", "Jan-r",
    "Librarian", "Lib-n",
    "Lawyer", "Law",
    "Chaplain", "Chapl",
    "Chief Engineer", "CE",
    "Station Engineer", "Engi",
    "Atmospheric Technician", "Atmos",
    "Chief Medical Officer", "CMO",
    "Medical Doctor", "MD",
    "Chemist", "Chem",
    "Geneticist", "G-tic",
    "Virologist", "Viro",
    "Research Director", "RD",
    "Scientist", "Sci",
    "Roboticist", "Robo",
    "Head of Security", "HoS",
    "Warden", "Ward",
    "Detective", "D-tiv",
    "Security Officer", "Sec",
    "AI", "AI",
    "Cyborg", "Borg",
    "Personal AI", "pAI",
    );
   
    $index = 1;
  while($index <= length($words))
  {
  mem(at($words, $index), at($words, $index+1));
  $index += 2;
  }
}
if(mem("initialized") != 1)
{
  Initialize();
  mem("initialized", 1);
}
$foo = "";
if(mem($job)) { $foo = mem($job); }
else { $foo = substr($job, 1, 6); }
if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
$source = $source + " (" + $foo + ")"; }


=== Selective mute ===
def implode($vector, $adder)
By Matilda.<br>
{
Turn a wall com to 146.1 to listen to the output of the script.<br>
$returnString = "";
authorize yourself via ;/authme PASSWORD, just say it on the general com.<br>
$index = 1;
then use ;/crewlist to find the ID of who you want to mute<br>
then use ;/mute ID to mute them, and ;/unmute ID to unmute them


$password = "<insert password here>";
while($index <= length($vector))
{
$originalsource = $source;
$at = at($vector, $index);
$originaljob = $job;
$toAdd = $adder;
$me = 4;
if($index == 1)
{
if(!mem("crewnum")) {
$toAdd = "";
    mem("crewnum",0);
}
}
$returnString = $returnString + $toAdd + $at;
$index += 1;
$found = 0;
}
$counter = 0;
return $returnString;
$me = 0;
}  
while($counter < mem("crewnum")) {
    if (mem("crewlistsource" + $counter) == $originalsource) {
      $me = $counter;
      $found = 1;
    }
    $counter = $counter + 1;
}
if ($found == 0) {
    $me = mem("crewnum");
    broadcast("Adding new user " + $originalsource + ", " + $originaljob + " to database at location " + mem("crewnum"),1461);
    mem("crewlistsource" + $me,$originalsource);
    mem("crewlistjob" + $me,$originaljob);
    mem("crewlistauth" + $me, 0);
    mem("crewlistmute" + $me, 0);
    mem("crewnum",mem("crewnum") + 1);
}
//HACK ALERT
if ($me < 1) { $me = 0; }
if(!mem("usermessagecount")) {
    mem("usermessagecount",0);
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/crewlist") {
    $counter = 0;
    while($counter < mem("crewnum")) {
      broadcast($counter + " - " + mem("crewlistsource" + $counter) + " - " + mem("crewlistjob" + $counter) + " - auth " + mem("crewlistauth" +
$counter) + " - mute " + mem("crewlistmute" + $counter),1461," "," ");
      $counter = $counter + 1;
    }
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) == "/who") {
    broadcast(mem("crewlistsource" + at($expld1, 2)),1461);
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/crewnum") {
    broadcast(mem("crewnum"), 1461);
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/myid") {
    broadcast("Your ID is " + $me, 1461);
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/mute" && mem("crewlistauth" + $me) >= 2) {
    mem("crewlistmute" + at($expld1, 2),1);
    broadcast(mem("crewlistsource" + at($expld1, 2)) + " has been muted.");
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/unmute" && mem("crewlistauth" + $me) >= 2) {
    mem("crewlistmute" + at($expld1, 2),0);
    broadcast(mem("crewlistsource" + at($expld1, 2)) + " has been unmuted.");
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/authme") {
    if(at($expld1, 2) == $password) {
      mem("crewlistauth" + $me, 2);
    }
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/announce" && mem("crewlistauth" + $me) >= 1) {
    broadcast(" ",$common," "," ");
    broadcast("ANNOUNCEMENT",$common," "," ");
    broadcast("  ",$common," "," ");
    broadcast("  ",$common," "," ");
    broadcast(upper(replace($content, "/announce", " ")),$common," "," ");
    broadcast("    ",$common," "," ");
    broadcast("    ",$common," "," ");
    $pass = 0;
}
if(mem("crewlistmute" + $me) == 1) {
    //$pass = 0;
    $content = " ";
    $source = $originalsource + " (MUTED)";
}


def Initialize()
{


===Cleaner Selective Mute ===
// Our words! Format: real word / pirate word
mute and unmute people merely by saying "/mute FULL NAME" the name has to be capitalized and spelled properly.<br>
$words = vector("gun", "cannon",
Authorizes by one or more sources, but could be configured for a password if you really wanted to.<br>
"heaven", "davy jones' locker",
Great for traitor AIs who don't want their victim screaming about the oxygen siphoning!
"I", "aye",
"my", "meh",
"yes", "aye",
"are", "argh",
"yeah", "yarh",
"captain", "Cap'n",
"hos", "First Mate",
"hop", "Crewmaster",
"ai", "Navigator",
"money", "treasure",
"friend", "matey",
"station", "vessel",
"shuttle", "rowboat",
"engine", "sails",
"space", "sea");


//recursive implode function, takes a vector and
//broadcast("Starting Initialization...");
//combines each member into a string with a space to separate
//by perogi
$index = 1;
def implode($vector)
  while($index <= length($words))
{
{
$str = at($vector, 1);
$key = at($words, $index);
  remove($vector, $str);
$key = lower($key);
if(length($vector) > 0)  
$value = at($words, $index+1);
{
mem($key, $value);
$str += " ";
$index += 2;
$str += implode($vector);
}
}
//broadcast("Initialization Complete!");
return $str;
}  
}
//mute and unmute function
//use: type /mute or /unmute then the name of the person exactly as it is spelled
//by perogi
if($source == "YOUR NAME HERE") //only the name in this line can use script
{
if(at(explode($content, " "), 1) == "/mute")
{
$vec = explode($content, " ");
remove($vec, "/mute");
$name = implode($vec);
$pass = 0;
mem($name,$name);
}
if(at(explode($content, " "),1) == "/unmute")
{
$pass = 0;
$vec = explode($content, " ");
remove($vec, "/unmute");
mem(implode($vec), 0);
}
}
//checks if source is muted
//possible to get around mute by taking off ID and being unknown, hence why unknowns are all blocked
if($source == mem($source) || $source == "Unknown")
{
$pass = 0;
}


===Horrible Pun Teller===
// Script Begin


This tells horrible puns. It only has 5 example puns but if you wish you can add more in the pick() list.
if(mem("initialized") != 1)
{
Initialize();
mem("initialized", 1);
}


$expld1 = explode($content, " ");
$newContent = explode($content, " ");
if(at($expld1, 1) ==  "/pun")
$index = 1;
{
while($index <= length($newContent))
broadcast(pick("When I went to the French poultry farm, it was a mess! The poulet everywhere.", "History’s most agreeable tyrant: William the Concurrer.", "What’s a real estate lawyer’s least favourite  song? “Lien On Me“.", "Do all houses come with decks? Un porch innately not.", "My dog was banned from the oil sands, because he bitumeny people."), 1459, "Automated Pun Teller", "Horrible Jokes Ahoy");
{
}


===English To Pirate Translator===
$entry = at($newContent, $index);
$value = mem(lower($entry));


This script initializes a list of words by using the mem() function as a hash table. By doing this it has to initialize first, if you are running this script and then add words later, you must clear the memory of the server first so it initializes again and learns the new words.
if($value)
{
at($newContent, $index, $value);
}
$index += 1;
}


After initialization, this transmission and the rest all skip to splitting the transmission's contents and check each word against the memory, using the word as a key. Because of not needing to loop through the list of words, this is a fast process. If it finds a valid word to replace, it will replace the word with the value that the key led to. Finally, after it is finished it will convert the vector into a string again and then replace the contents of the transmission with the final message.
$content = implode($newContent, " ");
// English To Pirate Translator Script - By Giacom
// Helper Functions
def implode($vector, $adder)
{
$returnString = "";
$index = 1;
while($index <= length($vector))
{
$at = at($vector, $index);
$toAdd = $adder;
if($index == 1)
{
$toAdd = "";
}
$returnString = $returnString + $toAdd + $at;
$index += 1;
}
return $returnString;
}
def Initialize()
{
// Our words! Format: real word / pirate word
$words = vector("gun", "cannon",
"heaven", "davy jones' locker",
"I", "aye",
"my", "meh",
"yes", "aye",
"are", "argh",
"yeah", "yarh",
"captain", "Cap'n",
"hos", "First Mate",
"hop", "Crewmaster",
"ai", "Navigator",
"money", "treasure",
"friend", "matey",
"station", "vessel",
"shuttle", "rowboat",
"engine", "sails",
  "space", "sea");
//broadcast("Starting Initialization...");
 
$index = 1;
  while($index <= length($words))
{
$key = at($words, $index);
$key = lower($key);
$value = at($words, $index+1);
mem($key, $value);
$index += 2;
}
//broadcast("Initialization Complete!");
}
// Script Begin
if(mem("initialized") != 1)
{
Initialize();
mem("initialized", 1);
}
$newContent = explode($content, " ");
$index = 1;
while($index <= length($newContent))
{
$entry = at($newContent, $index);
$value = mem(lower($entry));
if($value)
{
at($newContent, $index, $value);
}
  $index += 1;
}
$content = implode($newContent, " ");
// Script End


===Quiz Bot===
// Script End</pre>


=== Quiz Bot ===
A bot which will ask math additions and keep track of a person's score. You can use /score to display your score. It uses the new time() feature to know when time is up asking a question.
A bot which will ask math additions and keep track of a person's score. You can use /score to display your score. It uses the new time() feature to know when time is up asking a question.


// Quiz Bot - By Giacom  
<pre>// Quiz Bot - By Giacom  
 
$time = time();
def GiveScore($name, $points)
$score = mem($name);
$total = $points + $score;
$message = $name + " was given " + tostring($points) + " point(s). Their total score is now " + tostring($total) + ".";
mem($name, $total);
return $message;
//broadcast($message, $common, $quizMaster, $quizMaster);
}
def GetScore($name)
{
return mem($name);
}
def GetQuestion()
{   
$numberY = rand(1, 9);
$numberX = rand(1, 9);
$looped = 0;
while($looped == 0 || prob(25))
{
$looped += 1;
$numberY = $numberY * rand(1, 9);
$numberX = $numberX * rand(1, 9);
}
$question = "What is " + tostring($numberY) + " + " + tostring($numberX) + "?";
// Store data
mem("currentQuestion", $question);
mem("number1", $numberY);
mem("number2", $numberX);
mem("lastAsked", $time);
mem("pointQuestion", $looped);
broadcast($question, $common, $quizMaster, $quizMaster);
}
// Main()
$quizMaster = "The Math Master";
$currentQuestion = mem("currentQuestion");
$currentNumber1 = mem("number1");
$currentNumber2 = mem("number2");
$lastAsked = mem("lastAsked");
$pointQuestion = mem("pointQuestion");
$askNextQuestion = 15; // 15 seconds
$explode = explode($content, " ");
if(at($explode, 1) == "/score")
{
$theScore = GetScore($source);
broadcast($source + ", you have " + $theScore + " point(s).", $common, $quizMaster, $quizMaster);
$skip = 1;
}
if($currentQuestion == null)
{
broadcast("Welcome! I am " + $quizMaster + " and I will be giving you all questions which you can answer over the radio.", $common, $quizMaster, $quizMaster);
broadcast("I will be keeping track of score. Use /score to view your score! Good luck! You have " +  $askNextQuestion + " seconds.", $common, $quizMaster, $quizMaster);
GetQuestion();
}
elseif($time > $lastAsked + ($askNextQuestion * 10))
{
broadcast("No one has found the answer in the time limit. Starting new round...", $common, $quizMaster, $quizMaster);
GetQuestion();
}
else
{
$answer = tostring($currentNumber1 + $currentNumber2);
if(find($explode, $answer))
{
$results = GiveScore($source, $pointQuestion);
broadcast($source + " wins! Answer was: " + $answer + ". " + $results, $common, $quizMaster,  $quizMaster);
GetQuestion();
}
}
 
==Useful Malicious Scripts==
   
   
===Tourretes Syndrome===
'''Purpose:''' To annoy the station/make everything think that the station has Tourettes.


$explodeContent = explode($content, " ");
$time = time();
$wordReplace = pick($explodeContent);
$content = replace($content, $wordReplace, pick("SHIT", "FUCK", "COCKSUCKER", "BULLSHIT", "CUNT", "MOTHERFUCKER"));


===HONK===
def GiveScore($name, $points)
'''Purpose:''' HONK
$score = mem($name);
$total = $points + $score;
$message = $name + " was given " + tostring($points) + " point(s). Their total score is now " + tostring($total) + ".";
mem($name, $total);
return $message;
//broadcast($message, $common, $quizMaster, $quizMaster);
}


$explodeVector = explode($content, " ");
def GetScore($name)
$tempString = "HONK! ";
{
$content = repeat($tempString, length($explodeVector)-1);
return mem($name);
}


===Rogue-Be-Gone===
def GetQuestion()
'''Purpose:''' To delay the crew knowing about you being rogue.
{   
$numberY = rand(1, 9);
$numberX = rand(1, 9);
$looped = 0;
while($looped == 0 || prob(25))
{
$looped += 1;
$numberY = $numberY * rand(1, 9);
$numberX = $numberX * rand(1, 9);
}
$question = "What is " + tostring($numberY) + " + " + tostring($numberX) + "?";
// Store data
mem("currentQuestion", $question);
mem("number1", $numberY);
mem("number2", $numberX);
mem("lastAsked", $time);
mem("pointQuestion", $looped);
broadcast($question, $common, $quizMaster, $quizMaster);
}


if(find(lower($content), "rogue") || find(lower($content), "roug"))
// Main()
{
$pass = false;
}


===No Shuttle, No Problems===
$quizMaster = "The Math Master";
'''Purpose:''' To stop the crew begging for a shuttle. (It's a copy+pasta)
$currentQuestion = mem("currentQuestion");
$currentNumber1 = mem("number1");
$currentNumber2 = mem("number2");
$lastAsked = mem("lastAsked");
$pointQuestion = mem("pointQuestion");
$askNextQuestion = 15; // 15 seconds


if(find(lower($content), "shuttle") || find(lower($content), "call"))
$explode = explode($content, " ");
{
$pass = false;
}
===Viva La Revolution!===
'''Purpose:''' To help disorganize the heads during a rev, they won't be able to make orders over the radio!


if(find($job, vector("Captain", "Head of Security", "Head of Personnel", "Chief Engineer", "Chief Medical Officer", "Research Director")))
if(at($explode, 1) == "/score")
{
{  
$pass = false;
$theScore = GetScore($source);  
}
broadcast($source + ", you have " + $theScore + " point(s).", $common, $quizMaster, $quizMaster);
$skip = 1;
===Remove Activation===
}  
'''Purpose:''' Have a script you don't want on all the time? Well lucky for you<br>
there's a way to overcome that. Say on the radio the hidden passphrase, of your choice,<br>
and you can enable or disable any script that you have between the if statement.<br>
<br>
'''Protip:''' The phrase will not broadcast on the radio. It doesn't matter how you say it, as long as you say that single word.
$passphrase = "cheezit!";
if(find($content, $passphrase))
{
$pass = 0;
if(mem($passphrase) == 1)
{
mem($passphrase, 0);
}
else
{
mem($passphrase, 1);
}
}
if(mem($passphrase) == 1)
{
// Insert code here. I recommend putting the annoying code here (Tourettes & HONK)
// so you can tease the station. Ideally, put it in a function.
}


===Voice Synthesizer===
'''Purpose:''' To trick the crew into thinking you are a high ranking officer.<br>
Such possible scenarios include: Framing your target by admitting to murder on radio,<br>
ordering the AI to call the shuttle to make your escape, pretend to be the Captain and get<br>
the crew very mad.<br>
<br>
'''How to use:''' /voice <First_Name> <Last_Name> <Job_Title> <Content><br>
<br>
'''Things to look out for:'''<br>
*The AI being smart and realizing it is a fake message.
*Other crew members discovering that it is a fake message by the italics that the fake voice has.
<br>
$explodeVec = explode($content, " ");
if(length($explodeVec) > 4)
{
$userCmd = at($explodeVec, 1);
if($userCmd == "/voice")
{
$newSource = at($explodeVec, 2) + " " + at($explodeVec, 3);
$newJob = at($explodeVec, 4);
$newContent = substr($content, length(" " + $userCmd + " " + $newSource + " " + $newJob + " "), length($content)+1);
$content = $newContent;
$job = $newJob;
$source = $newSource;
}
}


==Useful Snippets and Functions==
if($currentQuestion == null)
{
broadcast("Welcome! I am " + $quizMaster + " and I will be giving you all questions which you can answer over the radio.", $common, $quizMaster, $quizMaster);
broadcast("I will be keeping track of score. Use /score to view your score! Good luck! You have " +  $askNextQuestion + " seconds.", $common, $quizMaster, $quizMaster);
GetQuestion();
}
elseif($time > $lastAsked + ($askNextQuestion * 10))
{
broadcast("No one has found the answer in the time limit. Starting new round...", $common, $quizMaster, $quizMaster);
GetQuestion();
}
else
{
$answer = tostring($currentNumber1 + $currentNumber2);
if(find($explode, $answer))
{
$results = GiveScore($source, $pointQuestion);
broadcast($source + " wins! Answer was: " + $answer + ". " + $results, $common, $quizMaster,  $quizMaster);
GetQuestion();
}


===Implode===
}</pre>


Does the opposite of Explode(). Takes a vector (1st arg) and turns it into a string with a seperator (2nd arg) in between each Vector entry.<br>
=== Misleading Locations ===


def implode($vector, $adder)
Copy and paste this into the def Initialize() block in the [[#English_To_Pirate_Translator|English to Pirate -translator]]. You can also change words within the "" to suit any other needs like making "blood rune" to "retard". Be sure to go into other comm channels, copy/paste and set active for maximum evil laughter.
{
<pre>
$returnString = "";
$words = vector("scripts", "clown", "storage", "brig",
$index = 1;
"maintenance", "bar", "main", "escape", "sec", "medbay",
"brig", "arrivals", "cargo", "engineering", "science", "security",
while($index <= length($vector))
"bar", "vacant", "chapel", "bridge", "dorms", "locker room",
{
"office", "donuts", "upload", "ass", "solars", "escape",
$at = at($vector, $index);
"core", "heart", "engineering", "botany", "locker room", "science");
$toAdd = $adder;
</pre>
if($index == 1)
{
$toAdd = "";
}
$returnString = $returnString + $toAdd + $at;
$index += 1;
}
return $returnString;
}
 
===Broadcast All===
 
Broadcasts to all the department frequencies. Takes all the regular Broadcast() arguments except for frequency.
 
// Broadcasts to all department frequencies, and common.
def BroadcastAll($message, $from, $occupation)
{
$frequencies = vector($command, $common, $science, $medical, $engineering, $security, $supply);
$index = 1;
while($index <= length($frequencies))
{
$thisFrequency = at($frequencies, $index);
broadcast($message, $thisFrequency, $from, $occupation);
$index += 1;
}
}


[[Category:Guides]]
[[Category:Guides]]

Latest revision as of 23:15, 19 April 2022

Pen.png This page needs revising!

The following page is out of date and/or needs to be revised. If the page's guide needs revision, see here for an example.
The revision reason is: "Scripts are out of date compared to ingame."
Marked by: "HauntedOwl28 (talk) 07:14, 19 April 2022 (EST)"



Most of these scripts are compatable, but there are conflicts. The sequence of things is important. Definitely room for improvement. All scripts need the global def process_signal(sig){ as a header and return sig;} as a footer, unless specified otherwise. e.g.:

def process_signal(sig){ // Header.

if(sig.source=="Zion Freeman"){ sig.job="Nerd"; } // Some script.

sig.source+=" ("+sig.job+")"; // More script.

return sig;} // Footer.

For a guide how to use these scripts look here.

Useful Scripts

Job Indicator

Jobs will appear in brackets after names.

sig.source+=" ("+sig.job+")";

Abbr. Job Indicator

Gives abbreviations instead of full titles.

//Abbr. Job Indicator - by TheDL

jobs=list("Admiral", "Adm", "Assistant", "Ass", "Atmospheric Technician", "Atmo", "Bartender", "Bar", "Botanist", "Hydr", "Captain", "Cap", "Cargo Technician", "Carg", "Chaplain", "Chap", "Chemist", "Chem", "Chief Engineer", "CE", "Chief Medical Officer", "CMO", "Clerk", "Clrk", "Clown", "Clwn", "Curator", "Cura", "Detective", "Det", "Geneticist", "Gene", "Head of Personnel", "HoP", "Head of Security", "HoS", "Janitor", "Jani", "Lawyer", "Law", "Librarian", "Lib", "Medical Doctor", "MD", "Mining Medic", "Medi", "Paramedic", "Para", "Psychiatrist", "Psyc", "Quartermaster", "QM", "Research Director", "RD", "Roboticist", "Robo", "Scientist", "Sci", "Security Officer", "Sec", "Shaft Miner", "Mine", "Signal Technician", "Sig", "Station Engineer", "Engi", "Tourist", "Tour", "Unassigned", "Unas", "Unknown", "Unkn", "Virologist", "Viro", "Warden", "Ward", "Personal AI", "pAI", "Default Cyborg", "DefB", "Engineering Cyborg", "EngB", "Janitor Cyborg", "JanB", "Medical Cyborg", "MedB", "Miner Cyborg", "MnrB", "Peacekeeper Cyborg", "PceB", "Security Cyborg", "SecB", "Service Cyborg", "SrvB", "Standard Cyborg", "StnB");

if(find(jobs,sig.job)){ sig.job=jobs[find(jobs,sig.job)+1]; }
sig.source+="["+sig.job+"]";

Spam Jammer

Blocks hulkouts and tourettes ticks.

if(find(list("RAAAAAAAARGH!!!", "HNNNNNNNNNGGGGGGH!!!",
 "GWAAAAAAAARRRHHH!!!", "NNNNNNNNGGGGGGGGHH!!!",
 "AAAAAAARRRGH!!!", "CUNT", "FUCK", "PISS", "SHIT", "TITS",
 "COCKSUCKER", "MOTHERFUCKER"), sig.content)){ sig.pass=0;}


Anonymous Messages

Messages starting with /anon will broadcast under the name "Anonymous".

// Anonymous Messages - by TheDL

x=explode(sig.content," ");
if(x[1]=="/anon"){ sig.pass=0;
 broadcast(signal(implode(x-x[1]," "), sig.freq, "Anonymous")); }

// This one preserves language...

x=explode(sig.content," ");
if(x[1]=="/anon"){ sig.pass=0;
 anon=signal(implode(x-x[1]," "), sig.freq, "Anonymous");
 anon.language=sig.language; broadcast(anon); }

// ...this one randomizes filters, too.

x=explode(sig.content," ");
if(x[1]=="/anon"){ sig.pass=0; a=list("italics", "robot", "sans", "yell");
 anon=signal(implode(x-x[1]," "), sig.freq, "Anonymous");
 n=1; while(n<length(a)){ if(prob(50)){ anon.filters+=a[n]; } n+=1; }
 anon.language=sig.language; broadcast(anon); }

Broadcast to All

Messages starting with /all will be broadcasted to all departments, and common. Admins hate this, though. Expect to get bwoinked.

// Broadcast to All - by TheDL

x=explode(sig.content," ");
freqs=list( 1459, 1447, 1359, 1357, 1355, 1353, 1351, 1349, 1347);
if(x[1]=="/all"){ sig.pass=0; sig.content=implode(x-x[1]," "); n=1;
 while(n<=length(freqs)){ sig.freq=freqs[n]; broadcast(sig); n+=1; } }

Broadcast to Any or All

Messages starting with a channel code will be broadcast to the corresponding department. The channel codes are /c for command, /e for engineering, /m for medical, /n for science, /o for AI private, /s for security, /u for supply, and /v for service. As above, messages starting with /all will be broadcasted to all departments, and common. Again, admins hate this. Expect to get bwoinked.

// Broadcast to Any or All - by TheDL

x=explode(sig.content," ");
freqs=list( 1459, 1447, 1359, 1357, 1355, 1353, 1351, 1349, 1347);
codes=list( "/all", "/o", "/s", "/e", "/m", "/c", "/n", "/v", "/u");
if(find(codes,x[1])){ n=find(codes,x[1]); sig.content=implode(x-x[1]," ");
 if(codes[n]!="/all"){ sig.freq=freqs[n]; } else{ sig.pass=0; n=1;
  while(n<=length(freqs)){ sig.freq=freqs[n]; broadcast(sig); n+=1; } } }


Phrase Toggle

Enable or disable a script using a phrase. Any phrase can be used. Add the script to be toggled where indicated. User restricted, message blocked. Remove &&sig.source=="Your Name" to let anyone use it. Remove sig.pass=0; to not block the message.

// Phrase Toggle - By TheDL

toggle="Phrase"; if(find(sig.content,toggle)&& sig.source=="Your Name"){
 sig.pass=0; if(mem(toggle)!=1){ mem(toggle,1); } else{ mem(toggle,0); } }
if(mem(toggle)==1){
// Insert script here.
}

Pun Pun Teller

Say /pun to have the Ghost of Pun Pun tell an awful pun!

// Pun Pun Teller - by TheDL

exp=explode(sig.content," ");
if(exp[1]=="/pun"){ sig.pass=0;
broadcast(signal(pick("Did you hear about the guy that got cut in half? Don't worry, he's all right now.", "I started a business selling landmines disguised as prayer mats. Prophets are going through the roof!", "Why don't thieves get puns? Because they take things literally.", "My dog has no nose. How does he smell? Awful.", "A man entered ten puns in a pun contest, hoping that one would win. Unfortunately, no pun in ten did."),sig.freq,"The Ghost of Pun Pun"));}

Annoying and Malicious Scripts

_ the Hedgehog

_ the Hedgehog exclaims: "_ Gotta go fast!"

sig.source+=" the Hedgehog";
sig.content+=" Gotta go fast!";
sig.filters=list("italics");

Auto Tourettes

Two versions. First replaces all of a random word in every message. Second randomly replaces entire messages, prob() being the percent chance of this. Use prob(100) to replace all messages.

// Auto Tourettes, for random words...

sig.content=replace(sig.content,pick(explode(sig.content," ")),pick("SHIT", "FUCK", "COCKSUCKER", "BULLSHIT", "CUNT", "MOTHERFUCKER"));

// ...or random messages.

if(prob(20)){ sig.content=pick("SHIT", "FUCK", "COCKSUCKER", "BULLSHIT", "CUNT", "MOTHERFUCKER");}

HONK!

Replace every word of every message with HONK!

sig.content=repeat("HONK! ",length(explode(sig.content," "))-1);
sig.content=substr(sig.content, 1, length(sig.content));

La Revolution!

Prevents heads of staff from using the radio.

if(find(list("Captain", "Chief Engineer", "Chief Medical Officer", "Head of Personnel", "Head of Security", "Research Director"), sig.job)){ sig.pass=0;}

No Shuttle Calls

Blocks messages containing any of the words on the list.

block=list("call", "shuttle", "rogue", "rouge", "malf");
n=1; while(n<=length(block)){ if(find(sig.content,block[n])){ sig.pass=0; } n+=1; } 

Forced Singing

Replaces messages with lyrics, in this case those of Always Look on the Bright Side of Life. Say /sing Full Name to toggle a specific person. Say /sing all to toggle everyone. Say /sing pause to pause or unpause the singing.

// Forced Singing - by TheDL

song=list("Some things in life are bad,", "They can really make you mad.", "Other things just make you swear and curse.", "When you're chewing on life's gristle,", "Don't grumble, give a whistle!", "And this'll help things turn out for the best...", "And... always look on the bright side of life... tudum, tudu-tudu-tudum.", "Always look on the light side of life... tudum, tudu-tudu-tudum.", "If life seems jolly rotten,", "There's something you've forgotten,", "And that's to laugh and smile and dance and sing.", "When you're feeling in the dumps,", "Don't be silly, chumps!", "Just purse your lips and whistle -- that's the thing!", "And... always look on the bright side of life... tudum, tudu-tudu-tudum.", "Always look on the light side of life... tudum, tudu-tudu-tudum.", "For life is quite absurd,", "And death's the final word.", "You must always face the curtain with a bow.", "Forget about your sin, give the audience a grin.", "Enjoy it - it's your last chance anyhow!", "So... always look on the bright side of death, tudum, tudu-tudu-tudum.", "Just before you draw your terminal breath, tudum, tudu-tudu-tudum.", "Life's a piece of shit,", "When you look at it.", "Life's a laugh and death's a joke, it's true.", "You'll see it's all a show,", "Keep 'em laughing as you go.", "Just remember that the last laugh is on you.", "And, always look on the bright side of life... tudum, tudu-tudu-tudum.", "Always look on the right side of life... tudum tudu-tudu-tudum.", "Come on guys, cheer up!", "Always look on the bright side of life... tudum, tudu-tudu-tudum.", "Always look on the bright side of life... tudum, tudu-tudu-tudum.", "Worse things happen at sea, you know.", "Always look on the bright side of life... tudum, tudu-tudu-tudum.", "I mean, what you got to lose, you know? You come from nothing, you're going back to nothing. What you lost? Nothing!", "Always look on the right side of life... tudum, tudu-tudu-tudum.", "Nothing will come from nothing, you know what they say?", "Always look on the bright side of life... tudum, tudu-tudu-tudum...");

x=explode(sig.content," ");
y=mem("singers"); n=mem("lyrics");
if(y==null){ y=list(); y-=y[1]; mem("singers",y); }
if(n==null|| n>length(song)){ n=1; mem("lyrics",n); }
if(x[1]=="/sing"&& sig.source=="Your Name"){
 sig.pass=0; x=implode(x-x[1]," ");
 if(!find(y,x)){ y+=x; } else{ y-=x; } mem("singers",y); }
if(find(y,sig.source)|| find(y,"all")){ if(!find(y,"pause")){
  sig.pass=1; sig.content=song[n]; n+=1; mem("lyrics",n); } }

Selective Mute

Say /mute Full Name to mute (or unmute) people. Use proper case and spelling. Say /muted to broadcast the list of people being muted. Should choose a channel other than 1459, though. Alternatively, omit broadcast entirely. Users restricted.

// Selective Mute - by TheDL

x=explode(sig.content," ");
users=list("Your Name", "Zion Freeman", "Et Cetera");
if(mem("mute")==null){ m=list(); m-=m[1]; mem("mute",m); }
m=mem("mute"); if(find(users,sig.source)){
 if(find(list("/mute", "/muted"),x[1])){ sig.pass=0;
  if(x[1]=="/mute"){ x=implode(x-x[1]," ");
   if(!find(m,x)){ m+=x; } else{ m-=x; } mem("mute",m); }
  else{ broadcast(signal(implode(m,", ")+".",1459)); } } }
if(find(m,sig.source)){ sig.pass=0; }

// Without broadcasting.

x=explode(sig.content," ");
users=list("Your Name", "Zion Freeman", "Et Cetera");
if(mem("mute")==null){ m=list(); m-=m[1]; mem("mute",m); }
m=mem("mute"); if(find(users,sig.source)&& x[1]=="/mute"){
 sig.pass=0; x=implode(x-x[1]," ");
 if(!find(m,x)){ m+=x; } else{ m-=x; } mem("mute",m); }
if(find(m,sig.source)){ sig.pass=0; }

Simple Voice Synth

Say /voice N_ame J_ob Message to broadcast a message with a false identity. Use underscores for spaces in names or titles, and correct spelling and capitalization. Users restricted.
e.g.: Et Cetera exclaims: "/voice Is-a-Lizard Cargo_Technician I confess!"
e.g.: [Common] Is-a-Lizard (Cargo Technician) exclaims: "I confess!"
e.g.: Et Cetera says: "/voice Hugh_Man Head_of_Security Arrest the lizard."
e.g.: [Common] Hugh Man (Head of Security) says: "Arrest the lizard."

// Simple Voice Synth - by TheDL

x=explode(sig.content," ");
users=list("Your Name", "Zion Freeman", "Et Cetera");
if(find(users,sig.source)&& x[1]=="/voice"){
 sig.source=replace(x[2],"_"," "); sig.uuid=sig.source;
 sig.job=replace(x[3],"_"," "); x.Cut(1,4);
 sig.content=implode(x," "); }


Useful Snippets and Functions

Quickcast

A broadcast function with a short name and predefined signal. Saves a lot of typing.
Change the specifics, or remove them. Defaults to 1459.

// Quickcast, and avoid the hassle.

def qc(x){ broadcast(signal(x,1459,"Name","Job")); }

// Optional command volume. Use loud($) or loud($,1)

def loud(x,y){ z=signal(x); if(y==1){ z.filters=list("command_headset"); } broadcast(z); }

Modulo

Returns the remainder of x/y. Good to six digits.

// Modulo, for numbers in either sign...

def mod(x,y) { z=1; if(x/y<0) { z=-1; } return x-(floor((x/y)*z)*z)*y; }

// ...or, for positive numbers only.

def mod(x,y) { return x-floor(x/y)*y; }

Digital Root

Returns the digital root of x. Good to six digits. Ignores decimals.

// Digital root, for answers in either sign... 

def dig(x){ if(x!=0){ y=1; if(x<0){ y=-1; } x-=(floor((x/9)*y)*y)*9; if(x==0){ x=9*y; } } return x; }

// ...or, for positive answers only.

def dig(x){ if(x!=0){ if(x<0){ x=x*-1; } x-=floor(x/9)*9; if(x==0){ x=9; } } return x; }

Log Base

NTSL's log() function is actually natural log, base e, not the typical base 10. This function here returns the log of x in base y. Null y defaults to 10. logb(x,E) gives natural log, too. Positive numbers only.

def logb(x,y){ if(y==null){ y=10; } x=log(x)*(1/log(y)); return x; }

Digit Length

Returns the number of digits in x. Whole numbers only.

def lengthn(x){ if(x<0){ x=x*-1; } x=log(x)*(1/log(10)); return floor(x)+1; }

Outdated Scripts

English To Mid-evil Translator

// English To Mid-evil Translator Script - By Hellafed

This script initializes a list of words by using the mem() function as a hash table. By doing this it has to initialize first, if you are running this script and then add words later, you must clear the memory of the server first so it initializes again and learns the new words.

After initialization, this transmission and the rest all skip to splitting the transmission's contents and check each word against the memory, using the word as a key. Because of not needing to loop through the list of words, this is a fast process. If it finds a valid word to replace, it will replace the word with the value that the key led to. Finally, after it is finished it will convert the vector into a string again and then replace the contents of the transmission with the final message. (Credit to Giacom for providing the code i used to create this)

// English To Mid-evil Translator Script - By Hellafed

// Helper Functions

def implode($vector, $adder)
{ 
	$returnString = "";
	$index = 1;

	while($index <= length($vector))
	{
		$at = at($vector, $index);
		$toAdd = $adder;
		if($index == 1)
		{
			$toAdd = "";
		}
		$returnString = $returnString + $toAdd + $at;
		$index += 1;
	}
	return $returnString;
} 

def Initialize()
{

	// Our words! Format: real word / mid evil word
	$words = vector("gun", "cannon",
					"my", "my own",
					"security", "town watch",
					"are", "art",
					"yeah", "aye",
					"captain", "King",
					"hos", "Town Watch Commander",
					"ce", "Head Builder",
					"dead", "gone to Sovngarde",
           				"rd", "Lead Scientist",
					"assistant", "peasant",
					"Borg", "dwarven automaton",
					"Borgs", "dwarven automatons",
					"cyborg", "dwarven automaton",
					"cyborgs", "dwarven automatons",
					"fucker", "milk drinker",
					"syndicate", "dragons",
					"brig", "dungeon",
					"yours", "thine",
					"you", "thou",
					"do", "dost",
					"has", "hath",
					"nothing", "naught",
					"thanks", "Grammarcy",
					"hop", "Inn Manager",
					"ai", 	"King's Servant",
					"money", "gold coins",
					"friend", "brother",
					"station", "town",
					"shuttle", "Wagon",
					"engine", "waterwheel",
 					"space", "unknown");
					

	//broadcast("Starting Initialization...");
 	
	$index = 1;
 	while($index <= length($words))
	{
		$key = at($words, $index);
		$key = lower($key);
		$value = at($words, $index+1);
		mem($key, $value);
		$index += 2;
	}
	//broadcast("Initialization Complete!");
} 

// Script Begin

if(mem("initialized") != 1)
{ 
	Initialize();
	mem("initialized", 1);
}

$newContent = explode($content, " ");
$index = 1;
while($index <= length($newContent))
{ 

	$entry = at($newContent, $index);
	$value = mem(lower($entry));

	if($value)
	{
		at($newContent, $index, $value);
	}
	
 	$index += 1;
} 

$content = implode($newContent, " ");

// Script End

English To Pirate Translator

This script initializes a list of words by using the mem() function as a hash table. By doing this it has to initialize first, if you are running this script and then add words later, you must clear the memory of the server first so it initializes again and learns the new words.

After initialization, this transmission and the rest all skip to splitting the transmission's contents and check each word against the memory, using the word as a key. Because of not needing to loop through the list of words, this is a fast process. If it finds a valid word to replace, it will replace the word with the value that the key led to. Finally, after it is finished it will convert the vector into a string again and then replace the contents of the transmission with the final message.

// English To Pirate Translator Script - By Giacom

// Helper Functions

def implode($vector, $adder)
{ 
	$returnString = "";
	$index = 1;

	while($index <= length($vector))
	{
		$at = at($vector, $index);
		$toAdd = $adder;
		if($index == 1)
		{
			$toAdd = "";
		}
		$returnString = $returnString + $toAdd + $at;
		$index += 1;
	}
	return $returnString;
} 

def Initialize()
{

	// Our words! Format: real word / pirate word
	$words = vector("gun", "cannon",
					"heaven", "davy jones' locker",
					"I", "aye",
					"my", "meh",
					"yes", "aye",
					"are", "argh",
					"yeah", "yarh",
					"captain", "Cap'n",
					"hos", "First Mate",
					"hop", "Crewmaster",
					"ai", 	"Navigator",
					"money", "treasure",
					"friend", "matey",
					"station", "vessel",
					"shuttle", "rowboat",
					"engine", "sails",
 					"space", "sea");

	//broadcast("Starting Initialization...");
 	
	$index = 1;
 	while($index <= length($words))
	{
		$key = at($words, $index);
		$key = lower($key);
		$value = at($words, $index+1);
		mem($key, $value);
		$index += 2;
	}
	//broadcast("Initialization Complete!");
} 

// Script Begin

if(mem("initialized") != 1)
{ 
	Initialize();
	mem("initialized", 1);
}

$newContent = explode($content, " ");
$index = 1;
while($index <= length($newContent))
{ 

	$entry = at($newContent, $index);
	$value = mem(lower($entry));

	if($value)
	{
		at($newContent, $index, $value);
	}
	
 	$index += 1;
} 

$content = implode($newContent, " ");

// Script End

Quiz Bot

A bot which will ask math additions and keep track of a person's score. You can use /score to display your score. It uses the new time() feature to know when time is up asking a question.

// Quiz Bot - By Giacom 
 

$time = time();

def GiveScore($name, $points)
{  
	$score = mem($name);
	$total = $points + $score;
	$message = $name + " was given " + tostring($points) + " point(s). Their total score is now " + tostring($total) + ".";
	mem($name, $total);
	return $message;
	//broadcast($message, $common, $quizMaster, $quizMaster);
} 

def GetScore($name)
{ 
	return mem($name);
}

def GetQuestion()
{    
	$numberY = rand(1, 9);
	$numberX = rand(1, 9);
	$looped = 0;
	
	while($looped == 0 || prob(25))
	{
		$looped += 1;
		$numberY = $numberY * rand(1, 9);
		$numberX = $numberX * rand(1, 9);
	}
	
	$question = "What is " + tostring($numberY) + " + " + tostring($numberX) + "?";
	
	// Store data
	mem("currentQuestion", $question);
	mem("number1", $numberY);
	mem("number2", $numberX);
	mem("lastAsked", $time);
	mem("pointQuestion", $looped);
	broadcast($question, $common, $quizMaster, $quizMaster);
}

// Main()

$quizMaster = "The Math Master";
$currentQuestion = mem("currentQuestion");
$currentNumber1 = mem("number1");
$currentNumber2 = mem("number2");
$lastAsked = mem("lastAsked");
$pointQuestion = mem("pointQuestion");
$askNextQuestion = 15; // 15 seconds

$explode = explode($content, " ");

if(at($explode, 1) == "/score")
{ 
	$theScore = GetScore($source); 
	broadcast($source + ", you have " + $theScore + " point(s).", $common, $quizMaster, $quizMaster);
	$skip = 1;
} 


if($currentQuestion == null)
{
	broadcast("Welcome! I am " + $quizMaster + " and I will be giving you all questions which you can answer over the radio.", $common, $quizMaster, $quizMaster);
	broadcast("I will be keeping track of score. Use /score to view your score! Good luck! You have " +  $askNextQuestion + " seconds.", $common, $quizMaster, $quizMaster);
	GetQuestion();
}
elseif($time > $lastAsked + ($askNextQuestion * 10))
{
	broadcast("No one has found the answer in the time limit. Starting new round...", $common, $quizMaster, $quizMaster);
	GetQuestion();
}
else
{
	$answer = tostring($currentNumber1 + $currentNumber2);
	if(find($explode, $answer))
	{
		$results = GiveScore($source, $pointQuestion);
		broadcast($source + " wins! Answer was: " + $answer + ". " + $results, $common, $quizMaster,  $quizMaster);
		GetQuestion();
	}

}

Misleading Locations

Copy and paste this into the def Initialize() block in the English to Pirate -translator. You can also change words within the "" to suit any other needs like making "blood rune" to "retard". Be sure to go into other comm channels, copy/paste and set active for maximum evil laughter.

$words = vector("scripts", "clown", "storage", "brig",
"maintenance", "bar", "main", "escape", "sec", "medbay",
"brig", "arrivals", "cargo", "engineering", "science", "security",
"bar", "vacant", "chapel", "bridge", "dorms", "locker room",
"office", "donuts", "upload", "ass", "solars", "escape",
"core", "heart", "engineering", "botany", "locker room", "science");