NTSL Scripts: Difference between revisions

From BeeStation Wiki
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 (Replaces 'retard' with 'idiot.')
 
(29 intermediate revisions by 10 users not shown)
Line 1: Line 1:
Script repository. Place your [[NT Script|NT Scripts]] here.
{{Important
|Image=Server.gif
|Title=NTSL is disabled
|Note=As of 4-10-15, NTSL is disabled on /tg/station. This page is maintained as a historical archive.}}


More in [http://forums.nanotrasen.com/viewtopic.php?f=3&t=8147 this thread].


==Old Scripts Archive for Older Revisions==
This is the NTSL script repository where you can place your scripts.
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.
{| 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
'''[[NT_Script#Simple_Guide_to_Using_Scripts|For a guide how to use these scripts look here.]]'''


def Initialize() {
==Useful Non-Malicious Scripts==
=== Job Indicator ===
Shows everyone's jobs.
 
<pre>if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
  $source = $source + " (" + $job + ")"; } // Add job next to people's names.</pre>
 
=== Arrivals Alert Modification ===
Separates the automated arrivals messages from the AI's deliberate messages.
 
<pre>if (find($content, "has signed up as")) { //Is the message an arrival message?
  if ($job == "AI") { //Is it sent by the AI?
      $source = "Arrivals Alert System"; //Change the source of the message
  }
}</pre>
 
=== Anonymous Messages ===
Messages prefixed with "/anon" will hide their sender's identity.
 
<pre>$explodeString = explode($content, " ");
if(at($explodeString, 1) ==  "/anon")
    {
      $pass = false;
      $content = substr($content, 6, length($content)+1);
      broadcast($content, $freq, "Anonymous");
    }</pre>
 
=== Less Annoying Job Indicator ===
Only shows abbreviations of job titles instead of full titles.
 
<pre>def Initialize() {
$words = vector(
$words = vector(
    "Assistant", "Assnt",
  "assistant", "Assnt",
    "Captain", "Capt",
  "captain", "Capt",
    "Head of Personnel", "HoP",
  "head of personnel", "HoP",
    "Bartender", "Bar",
  "bartender", "Bar",
    "Chef", "Chef",
  "chef", "Chef",
    "Botanist", "Hydro",
  "botanist", "Hydro",
    "Quartermaster", "QM",
  "quartermaster", "QM",
    "Cargo Technician", "Cargo",
  "cargo technician", "Cargo",
    "Shaft Miner", "Miner",
  "shaft miner", "Miner",
    "Clown", "Clown",
  "clown", "Clown",
    "Mime", "Mime",
  "mime", "Mime",
    "Janitor", "Jan-r",
  "janitor", "Jan-r",
    "Librarian", "Lib-n",
  "librarian", "Lib-n",
    "Lawyer", "Law",
  "lawyer", "Law",
    "Chaplain", "Chapl",
  "chaplain", "Chapl",
    "Chief Engineer", "CE",
  "chief engineer", "CE",
    "Station Engineer", "Engi",
  "station engineer", "Engi",
    "Atmospheric Technician", "Atmos",
  "atmospheric technician", "Atmos",
    "Chief Medical Officer", "CMO",
  "chief medical officer", "CMO",
    "Medical Doctor", "MD",
  "medical doctor", "MD",
    "Chemist", "Chem",
  "chemist", "Chem",
    "Geneticist", "G-tic",
  "geneticist", "G-tic",
    "Virologist", "Viro",
  "virologist", "Viro",
    "Research Director", "RD",
  "research director", "RD",
    "Scientist", "Sci",
  "scientist", "Sci",
    "Roboticist", "Robo",
  "roboticist", "Robo",
    "Head of Security", "HoS",
  "head of security", "HoS",
    "Warden", "Ward",
  "warden", "Ward",
    "Detective", "D-tiv",
  "detective", "D-tiv",
    "Security Officer", "Sec",
  "security officer", "Sec",
    "AI", "AI",
  "ai", "AI",
    "Cyborg", "Borg",
  "cyborg", "Borg",
    "Personal AI", "pAI",
  "personal ai", "pAI",
     );
     );
      
      
Line 55: Line 79:
   while($index <= length($words))
   while($index <= length($words))
  {
  {
  mem(at($words, $index), at($words, $index+1));
  $key = at($words, $index);
  $value = at($words, $index+1);
  mem($key,$value);
   $index += 2;
   $index += 2;
  }
  }
Line 67: Line 93:


$foo = "";
$foo = "";
$joblow = lower($job);


if(mem($job)) { $foo = mem($job); }
if(mem($joblow)) { $foo = mem($joblow); }
else { $foo = substr($job, 1, 6); }
else { $foo = substr($job, 1, 6); }


if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
$source = $source + " (" + $foo + ")"; }</pre>
$source = $source + " [" + $foo + "]"; }</pre>


===Selective Mute===
===Selective Mute ===
By Matilda.<br>
Mute and unmute people merely by saying "/mute FULL NAME" the name has to be capitalized and spelled properly.<br>
Turn a wall com to 146.1 to listen to the output of the script.<br>
Authorizes by one or more sources, but could be configured for a password if you really wanted to.<br>
authorize yourself via ;/authme PASSWORD, just say it on the general channel.<br>
Great for traitor AIs who don't want their victim screaming about the oxygen siphoning!
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>//recursive implode function, takes a vector and
//combines each member into a string with a space to separate
//by perogi
def implode($vector)
{
  $str = at($vector, 1);
  remove($vector, $str);
  if(length($vector) > 0)
  {
      $str += " ";
      $str += implode($vector);
  }
  return $str;
}
//mute and unmute function
//use: type /mute or /unmute then the name of the person exactly as it is spelled
//by perogi


$originalsource = $source;
$exp = explode($content, " ");
$originaljob = $job;
$me = 4;


if(!mem("crewnum")) {
if($source == "YOUR NAME HERE") //only the name in this line can use script
  mem("crewnum",0);
{
}


$found = 0;
  if(at($exp, 1) == "/mute")
$counter = 0;
  {
$me = 0;
      remove($exp, "/mute");
while($counter < mem("crewnum")) {
      $name = implode($exp);
   if (mem("crewlistsource" + $counter) == $originalsource) {
      $pass = 0;
       $me = $counter;
      mem($name,$name);
       $found = 1;
  }
 
   if(at($exp,1) == "/unmute")
  {
       $pass = 0;
      remove($exp, "/unmute");
       $muteremove = implode($exp);
      mem($muteremove, 0);
   }
   }
  $counter = $counter + 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>


if ($found == 0) {
===Horrible Pun Teller===
  $me = mem("crewnum");
This tells horrible puns. It only has 5 example puns but if you wish you can add more in the pick() list.
  broadcast("Adding new user " + $originalsource + ", " + $originaljob + " to database at location " + mem("crewnum"),1461);
 
  mem("crewlistsource" + $me,$originalsource);
<pre>$expld1 = explode($content, " ");
  mem("crewlistjob" + $me,$originaljob);
if(at($expld1, 1) ="/pun")
  mem("crewlistauth" + $me, 0);
{
  mem("crewlistmute" + $me, 0);
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");
  mem("crewnum",mem("crewnum") + 1);
}</pre>
}
 
===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)
<pre>// 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()
{


//HACK ALERT
// Our words! Format: real word / mid evil word
if ($me < 1) { $me = 0; }
$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!");
}


if(!mem("usermessagecount")) {
// Script Begin
  mem("usermessagecount",0);
}


$expld1 = explode($content, " ");
if(mem("initialized") != 1)
if(at($expld1, 1) ==  "/crewlist") {
{  
  $counter = 0;
Initialize();
  while($counter < mem("crewnum")) {
mem("initialized", 1);
      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, " ");
$newContent = explode($content, " ");
if(at($expld1, 1) ==  "/who") {
$index = 1;
  broadcast(mem("crewlistsource" + at($expld1, 2)),1461);
while($index <= length($newContent))
  $pass = 0;
{
}


$expld1 = explode($content, " ");
$entry = at($newContent, $index);
if(at($expld1, 1) ==  "/crewnum") {
$value = mem(lower($entry));
  broadcast(mem("crewnum"), 1461);
  $pass = 0;
}


$expld1 = explode($content, " ");
if($value)
if(at($expld1, 1) ==  "/myid") {
{
  broadcast("Your ID is " + $me, 1461);
at($newContent, $index, $value);
  $pass = 0;
}
}
$index += 1;
}  


$expld1 = explode($content, " ");
$content = implode($newContent, " ");
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, " ");
// Script End</pre>
if(at($expld1, 1) ==  "/authme") {
  if(at($expld1, 2) == $password) {
      mem("crewlistauth" + $me, 2);
  }
  $pass = 0;
}


$expld1 = explode($content, " ");
===English To Pirate Translator===
if(at($expld1, 1) == "/announce" && mem("crewlistauth" + $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.
  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) {
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.
  //$pass = 0;
  $content = " ";
  $source = $originalsource + " (MUTED)";
}</pre>


<pre>// English To Pirate Translator Script - By Giacom


===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 / 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))
{
{
$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")
//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)
{
{
$pass = 0;
at($newContent, $index, $value);
$vec = explode($content, " ");
remove($vec, "/unmute");
mem(implode($vec), 0);
}
}
}
//checks if source is muted
$index += 1;
//possible to get around mute by taking off ID and being unknown, hence why unknowns are all blocked
}  
if($source == mem($source) || $source == "Unknown")
 
{
$content = implode($newContent, " ");
$pass = 0;
 
}</pre>
// 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.


==Useful Non-Malicious Scripts==
<pre>// Quiz Bot - By Giacom
=== Job Indicator ===
   
  if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
    $source = $source + " (" + $job + ")"; } // Add job next to people's names.


=== Arrivals Alert Modification ===
$time = time();
Separates the automated arrivals messages from the AI's deliberate messages.


if (find($content, "has signed up as")) { //Is the message an arrival message?
def GiveScore($name, $points)
    if ($job == "AI") { //Is it sent by the AI?
{
      $source = "Arrivals Alert System"; //Change the source of the message
$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);
}  


=== Anonymous Messages ===
def GetScore($name)
Messages prefixed with "/anon" will hide their sender's identity.
{
return mem($name);
}


$explodeString = explode($content, " ");
def GetQuestion()
if(at($explodeString, 1) == "/anon")
{   
    {
$numberY = rand(1, 9);
        $pass = false;
$numberX = rand(1, 9);
        $content = substr($content, 6, length($content)+1);
$looped = 0;
        broadcast($content, $freq, "Anonymous");
    }
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);
}


=== Less annoying job indicator ===
// Main()
Only shows abbreviations of job titles instead of full titles.


//code shamelessly copied and pasted from Giacom's pirate script
$quizMaster = "The Math Master";
$currentQuestion = mem("currentQuestion");
def Initialize() {
$currentNumber1 = mem("number1");
$words = vector(
$currentNumber2 = mem("number2");
    "Assistant", "Assnt",
$lastAsked = mem("lastAsked");
    "Captain", "Capt",
$pointQuestion = mem("pointQuestion");
    "Head of Personnel", "HoP",
$askNextQuestion = 15; // 15 seconds
    "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 ===
$explode = explode($content, " ");
By Matilda.<br>
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 com.<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


$password = "<insert password here>";
if(at($explode, 1) == "/score")
{  
$originalsource = $source;
$theScore = GetScore($source);  
$originaljob = $job;
broadcast($source + ", you have " + $theScore + " point(s).", $common, $quizMaster, $quizMaster);
$me = 4;
$skip = 1;
}  
if(!mem("crewnum")) {
    mem("crewnum",0);
}
$found = 0;
$counter = 0;
$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)";
}




===Cleaner Selective Mute ===
if($currentQuestion == null)
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>
broadcast("Welcome! I am " + $quizMaster + " and I will be giving you all questions which you can answer over the radio.", $common, $quizMaster, $quizMaster);
Great for traitor AIs who don't want their victim screaming about the oxygen siphoning!
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();
}


//recursive implode function, takes a vector and
}</pre>
//combines each member into a string with a space to separate
//by perogi
def implode($vector)
{
$str = at($vector, 1);
remove($vector, $str);
if(length($vector) > 0)
{
$str += " ";
$str += implode($vector);
}
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===
=== Spam Removal ===
To remove radio clutter when there's too many hulks and/or tourettes. Filters them out.


This tells horrible puns. It only has 5 example puns but if you wish you can add more in the pick() list.
<pre>$npass = 1;


$expld1 = explode($content, " ");
if ($content == "GWAAAAAAAARRRHHH!!!" || $content == "HNNNNNNNNNGGGGGGH!!!" || $content == "RAAAAAAAARGH!!!" || $content == "AAAAAAARRRGH!!!" || $content == "NNNNNNNNGGGGGGGGHH!!!") {
if(at($expld1, 1) == "/pun")
  $npass = 0;
{
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===
}
if ($content == "CUNT" || $content == "SHIT" || $content == "FUCK" || $content == "COCKSUCKER" || $content == "TITS" || $content == "MOTHERFUCKER") {
  $npass = 0;
}
if (mem($source) == $content) {
  $npass = 0;
}
if (mem($source) != $content) {
  mem($source, $content);
}


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.
$space = 1;
while ($space) {
  $space = 0;
  $init = substr($content, 1, 2);
  if ($init == " ") {
    $space = 1;
    $content = substr($content, 2, length($content)+1);
  }
}
$firstchar = substr($content, 1, 2);
if ($firstchar == lower($firstchar)) {
  $firstchar = upper($firstchar);
}
$content = $firstchar + substr($content, 2, length($content)+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.
$end = substr($content, length($content), length($content)+1);
if ($end != "." && $end != "!" && $end != "?") {
// English To Pirate Translator Script - By Giacom
  $content += ".";
}
// 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===
if ($content == upper($content)) {
  $content = lower($content);
  $init = upper(substr($content, 1, 2));
  $seq = substr($content, 2, length($content)+1);
  $content = $init + $seq;
}
$pass = 0;
if ($npass && $job != "Cyborg" && $job != "AI") {
  broadcast($content, $freq, $source, $job);
}</pre>


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.
=== All Channel Communication for the AI ===
To ease the AI's way of communicating to each department separately.


// Quiz Bot - By Giacom
<pre>//Usage: Set private to speaker/mic, set public to speaker only, use "sBlah" for sec etc, upload everywhere
 
if (mem("init") != 1) {
  $freqs = vector("1359", "s", "1357", "e", "1355", "m", "1353", "c", "1351", "n", "1347", "u", "1349", "v");
$time = time();
   $index = 1;
  while ($index <= length($freqs)) {
def GiveScore($name, $points)
      $tfreq = at($freqs, $index);
{
      $tid = at($freqs, $index + 1);
$score = mem($name);
      mem($tfreq, $tid);
$total = $points + $score;
      mem($tid, $tfreq);
$message = $name + " was given " + tostring($points) + " point(s). Their total score is now " + tostring($total) + ".";
      $index += 2;
mem($name, $total);
  }
return $message;
  mem("init", 1);
//broadcast($message, $common, $quizMaster, $quizMaster);
}
}
$clen = length($content) + 1;
$first = substr($content, 1, 2);
def GetScore($name)
$rest = substr($content, 2, $clen);
{
$freqs = tostring($freq);
return mem($name);
if ($freq == 1447 && $job == "AI" && mem($first)) {
}
  $tfreq = mem($first);
  broadcast($rest, $tfreq, $source, $job);
def GetQuestion()
} elseif ($freq == 1447 && $job == "AI") {
{    
  broadcast($content, 1459, $source, $job);
$numberY = rand(1, 9);
} elseif (mem($freqs)) {
$numberX = rand(1, 9);
  $tid = mem($freqs);
$looped = 0;
  broadcast("["+$tid+"]"+$content, 1447, $source, $job);
}</pre>
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==
== Useful Malicious Scripts ==
   
   
===Tourretes Syndrome===
=== Tourretes Syndrome ===
'''Purpose:''' To annoy the station/make everything think that the station has Tourettes.
'''Purpose:''' To annoy the station/make everything think that the station has Tourettes.


Line 693: Line 541:
  $content = replace($content, $wordReplace, pick("SHIT", "FUCK", "COCKSUCKER", "BULLSHIT", "CUNT", "MOTHERFUCKER"));
  $content = replace($content, $wordReplace, pick("SHIT", "FUCK", "COCKSUCKER", "BULLSHIT", "CUNT", "MOTHERFUCKER"));


===HONK===
=== HONK ===
'''Purpose:''' HONK
'''Purpose:''' HONK


Line 700: Line 548:
  $content = repeat($tempString, length($explodeVector)-1);
  $content = repeat($tempString, length($explodeVector)-1);


===Rogue-Be-Gone===
=== Rogue-Be-Gone ===
'''Purpose:''' To delay the crew knowing about you being rogue.
'''Purpose:''' To delay the crew knowing about you being rogue.


Line 708: Line 556:
  }
  }


===No Shuttle, No Problems===
=== No Shuttle, No Problems ===
'''Purpose:''' To stop the crew begging for a shuttle. (It's a copy+pasta)
'''Purpose:''' To stop the crew begging for a shuttle. (It's a copy+pasta)


Line 716: Line 564:
  }  
  }  
   
   
===Viva La Revolution!===
=== Viva La Revolution! ===
'''Purpose:''' To help disorganize the heads during a rev, they won't be able to make orders over the radio!
'''Purpose:''' To help disorganize the heads during a rev, they won't be able to make orders over the radio!


Line 724: Line 572:
  }
  }
   
   
===Remove Activation===
=== Remove Activation ===
'''Purpose:''' Have a script you don't want on all the time? Well lucky for you<br>
'''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>
there's a way to overcome that. Say on the radio the hidden passphrase, of your choice,<br>
Line 750: Line 598:
  }
  }


===Voice Synthesizer===
=== Voice Synthesizer ===
'''Purpose:''' To trick the crew into thinking you are a high ranking officer.<br>
'''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>
Such possible scenarios include: Framing your target by admitting to murder on radio,<br>
Line 780: Line 628:
  }
  }


==Useful Snippets and Functions==
=== Choreographed Always Look on the Bright Side of Life ===
<pre>
//to bring some joy to a station in dire need just say "/happy all" over general radio
//to bring joy to a single person one just needs to say "/happy [insert downer]"
//remember to fill the authority slot with your name
//and as always capitalisation is important
 
$authority ="[insert name here]";
 
$Bright = vector("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 have you got to lose?","You know, you come from nothing - you're going back to nothing.What have you lost? Nothing!","Always look on the right side of life... tudum tudu-tudu-tudum");
 
def implode($vector)
 
{
        $str = at($vector, 1);
        remove($vector, $str);
        if(length($vector) > 0)
        {
                $str += " ";
                $str += implode($vector);
        }
        return $str;
}
if (mem("Happy") == mem("invalid"))
{
        mem("Happy","0");
}
if($source == $authority)
{
        if(at(explode($content, " "), 1) == "/happy")
        {
                $vec = explode($content, " ");
                remove($vec, "/happy");
                $name = implode($vec);         
                $pass = 0;
                mem($name,$name);
        }
        if(at(explode($content, " "),1) == "/unhappy")
        {
                $pass = 0;
                $vec = explode($content, " ");
                remove($vec, "/unhappy");
                $temp = implode($vec);
                mem($temp, 0);
        }     
}
if ("all" == mem("all"))
{
        $temp = mem("Happy");
        $count = tonum($temp);
        $content = at($Bright,$count);
        $count = $count +1;
        $temp2 = length($Bright);
        if ($count > $temp2)
        {
                $count = 1;
        }
        $temp3 = tostring($count);
        mem("Happy",$temp3);
}
if($source == mem($source))
{
        $output = implode($Bright);
        $content = $output;
}
if ($pass == 0 && $job =="AI")
{
        $pass = 1;
        $content = "beep";
}</pre>


===Implode===
=== Misleading Locations ===
 
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 "idiot". Be sure to go into other comm channels, copy/paste and set active for maximum evil laughter.
<pre>
$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");
</pre>
 
== Useful Snippets and Functions ==
 
=== Implode ===


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>
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>
Line 805: Line 747:
  }  
  }  


===Broadcast All===
=== Broadcast All ===


Broadcasts to all the department frequencies. Takes all the regular Broadcast() arguments except for frequency.
Broadcasts to all the department frequencies. Takes all the regular Broadcast() arguments except for frequency.
Line 823: Line 765:
  }
  }


==Less-than-useful Scripts==
=== (Name) The Hedgehog ===
'''Purpose:''' I'm Sonic! Sonic the Hedgehog!<br>
<pre>
$source = $source + " The Hedgehog";
$content = $content + " Gotta go fast!";
</pre>
[[Category:Guides]]
[[Category:Guides]]
[[Category:Removed Content]]

Latest revision as of 06:45, 16 April 2021

NTSL is disabled

As of 4-10-15, NTSL is disabled on /tg/station. This page is maintained as a historical archive.



This is the NTSL script repository where you can place your scripts.

For a guide how to use these scripts look here.

Useful Non-Malicious Scripts

Job Indicator

Shows everyone's jobs.

if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
   $source = $source + " (" + $job + ")"; } // Add job next to people's names.

Arrivals Alert Modification

Separates the automated arrivals messages from the AI's deliberate messages.

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

Anonymous Messages

Messages prefixed with "/anon" will hide their sender's identity.

$explodeString = explode($content, " ");
if(at($explodeString, 1) ==  "/anon")
    {
       $pass = false;
       $content = substr($content, 6, length($content)+1);
       broadcast($content, $freq, "Anonymous");
    }

Less Annoying Job Indicator

Only shows abbreviations of job titles instead of full titles.

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))
 {
   $key = at($words, $index);
   $value = at($words, $index+1);
  mem($key,$value);
  $index += 2;
 }
}

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

$foo = "";
$joblow = lower($job);

if(mem($joblow)) { $foo = mem($joblow); }
else { $foo = substr($job, 1, 6); }

if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
$source = $source + " [" + $foo + "]"; }

Selective Mute

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

//recursive implode function, takes a vector and
//combines each member into a string with a space to separate
//by perogi
def implode($vector)
{
   $str = at($vector, 1);
   remove($vector, $str);
   if(length($vector) > 0) 
   {
      $str += " ";
      $str += implode($vector);
   }
   return $str;
}
//mute and unmute function
//use: type /mute or /unmute then the name of the person exactly as it is spelled
//by perogi

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

if($source == "YOUR NAME HERE") //only the name in this line can use script
{

   if(at($exp, 1) == "/mute")
   {
      remove($exp, "/mute");
      $name = implode($exp);
      $pass = 0;
      mem($name,$name);
   }
   
   if(at($exp,1) == "/unmute")
   {
      $pass = 0;
      remove($exp, "/unmute");
      $muteremove = implode($exp);
      mem($muteremove, 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

This tells horrible puns. It only has 5 example puns but if you wish you can add more in the pick() list.

$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/pun")
{
	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 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();
	}

}

Spam Removal

To remove radio clutter when there's too many hulks and/or tourettes. Filters them out.

$npass = 1;

if ($content == "GWAAAAAAAARRRHHH!!!" || $content == "HNNNNNNNNNGGGGGGH!!!" || $content == "RAAAAAAAARGH!!!" || $content == "AAAAAAARRRGH!!!" || $content == "NNNNNNNNGGGGGGGGHH!!!") {
  $npass = 0;

}
if ($content == "CUNT" || $content == "SHIT" || $content == "FUCK" || $content == "COCKSUCKER" || $content == "TITS" || $content == "MOTHERFUCKER") {
  $npass = 0;
}
if (mem($source) == $content) {
  $npass = 0;
}
if (mem($source) != $content) {
  mem($source, $content);
}

$space = 1;
while ($space) {
  $space = 0;
  $init = substr($content, 1, 2);
  if ($init == " ") {
     $space = 1;
     $content = substr($content, 2, length($content)+1);
  }
}
$firstchar = substr($content, 1, 2);
if ($firstchar == lower($firstchar)) {
  $firstchar = upper($firstchar);
}
$content = $firstchar + substr($content, 2, length($content)+1);

$end = substr($content, length($content), length($content)+1);
if ($end != "." && $end != "!" && $end != "?") {
  $content += ".";
}

if ($content == upper($content)) {
  $content = lower($content);
  $init = upper(substr($content, 1, 2));
  $seq = substr($content, 2, length($content)+1);
  $content = $init + $seq;
}
$pass = 0;
if ($npass && $job != "Cyborg" && $job != "AI") {
  broadcast($content, $freq, $source, $job);
}

All Channel Communication for the AI

To ease the AI's way of communicating to each department separately.

//Usage: Set private to speaker/mic, set public to speaker only, use "sBlah" for sec etc, upload everywhere
if (mem("init") != 1) {
   $freqs = vector("1359", "s", "1357", "e", "1355", "m", "1353", "c", "1351", "n", "1347", "u", "1349", "v");
   $index = 1;
   while ($index <= length($freqs)) {
      $tfreq = at($freqs, $index);
      $tid = at($freqs, $index + 1);
      mem($tfreq, $tid);
      mem($tid, $tfreq);
      $index += 2;
   }
   mem("init", 1);
}
$clen = length($content) + 1;
$first = substr($content, 1, 2);
$rest = substr($content, 2, $clen);
$freqs = tostring($freq);
if ($freq == 1447 && $job == "AI" && mem($first)) {
   $tfreq = mem($first);
   broadcast($rest, $tfreq, $source, $job);
} elseif ($freq == 1447 && $job == "AI") {
   broadcast($content, 1459, $source, $job);
} elseif (mem($freqs)) {
   $tid = mem($freqs);
   broadcast("["+$tid+"]"+$content, 1447, $source, $job);
}

Useful Malicious Scripts

Tourretes Syndrome

Purpose: To annoy the station/make everything think that the station has Tourettes.

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

HONK

Purpose: HONK

$explodeVector = explode($content, " ");
$tempString = "HONK! ";
$content = repeat($tempString, length($explodeVector)-1);

Rogue-Be-Gone

Purpose: To delay the crew knowing about you being rogue.

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

No Shuttle, No Problems

Purpose: To stop the crew begging for a shuttle. (It's a copy+pasta)

if(find(lower($content), "shuttle") || find(lower($content), "call"))
{
	$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")))
{
	$pass = false;
}

Remove Activation

Purpose: Have a script you don't want on all the time? Well lucky for you
there's a way to overcome that. Say on the radio the hidden passphrase, of your choice,
and you can enable or disable any script that you have between the if statement.

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.
Such possible scenarios include: Framing your target by admitting to murder on radio,
ordering the AI to call the shuttle to make your escape, pretend to be the Captain and get
the crew very mad.

How to use: /voice <First_Name> <Last_Name> <Job_Title> <Content>

Things to look out for:

  • 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.


$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;

	}
}

Choreographed Always Look on the Bright Side of Life

//to bring some joy to a station in dire need just say "/happy all" over general radio
//to bring joy to a single person one just needs to say "/happy [insert downer]"
//remember to fill the authority slot with your name 
//and as always capitalisation is important

$authority ="[insert name here]";

$Bright = vector("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 have you got to lose?","You know, you come from nothing - you're going back to nothing.What have you lost? Nothing!","Always look on the right side of life... tudum tudu-tudu-tudum");

def implode($vector)

{
        $str = at($vector, 1);
        remove($vector, $str);
        if(length($vector) > 0) 
        {
                $str += " ";
                $str += implode($vector);
        }
        return $str;
}
if (mem("Happy") == mem("invalid"))
{
        mem("Happy","0");
}
if($source == $authority)
{
        if(at(explode($content, " "), 1) == "/happy")
        {
                $vec = explode($content, " ");
                remove($vec, "/happy");
                $name = implode($vec);          
                $pass = 0;
                mem($name,$name);
        }
        if(at(explode($content, " "),1) == "/unhappy")
        {
                $pass = 0;
                $vec = explode($content, " ");
                remove($vec, "/unhappy");
                $temp = implode($vec);
                mem($temp, 0);
        }       
}
if ("all" == mem("all"))
{
        $temp = mem("Happy");
        $count = tonum($temp);
        $content = at($Bright,$count);
        $count = $count +1;
        $temp2 = length($Bright);
        if ($count > $temp2)
        {
                $count = 1;
        } 
        $temp3 = tostring($count);
        mem("Happy",$temp3); 
}
if($source == mem($source))
{
        $output = implode($Bright);
        $content = $output;
}
if ($pass == 0 && $job =="AI")
{
        $pass = 1;
        $content = "beep";
}

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 "idiot". 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");

Useful Snippets and Functions

Implode

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.

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;
} 

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;
	}
}

Less-than-useful Scripts

(Name) The Hedgehog

Purpose: I'm Sonic! Sonic the Hedgehog!

$source = $source + " The Hedgehog";
$content = $content + " Gotta go fast!";