Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[READY] NTSL refactor #4486

Merged
merged 13 commits into from Feb 24, 2019
Merged

[READY] NTSL refactor #4486

merged 13 commits into from Feb 24, 2019

Conversation

monster860
Copy link
Member

@monster860 monster860 commented Feb 14, 2019

DOCUMENTATION: https://wiki.yogstation.net/wiki/NT_Script

Don't tell me there's no documentation.

This will break your scripts, here's how you make a script now:

// you can initialize associative lists
replacements = list(
  "A" = "fuck",
  "B" = "shit"
);
// signal processing occurs in a function now, and the global scope is only executed once, immediately after compilation
def process_signal(sig) {
  sig.source += " OwO"; // you can modify the signal like before
  // you can use []
  if(replacements.Find(sig.content)) {
    sig.content = replacements[sig.content];
  }
  sleep(2); // sleeping will no longer confuse the absolute shit out of the interpreter.
  return sig; // you have to return the signal object, you can even create a new one!
}
// broadcast a message
broadcast_sig = signal("Compilation successful!", channels.common, "NTSL script");
broadcast_sig.say = "states";
channels_to_broadcast = list(channels.common, channels.command, channels.security);
for(i = 1; i <= channels_to_broadcast.len; i++) {
  broadcast_sig.freq = channels_to_broadcast;
  broadcast(broadcast_sig); // broadcasts the signal
}

// I can't be bothered to make an example for this, but there's also closures, like in JS.
  • Refactor assignments to be operators
  • Refactor the scope to be passed around as paremeters so sleep() doesn't fuck shit up horribly
  • Add for loops
  • Add the "." operator, and the related interactions
  • Add the "[]" operator
  • Add support for creating assoc lists easily
  • Refactor functions
  • Move signal processing from the global scope into a function

馃啈 monster860
tweak: Assignemts in NTSL are now operators
fix: sleep() in NTSL no longer breaks things horribly
add: Adds for loops to NTSL
add: Adds the "." and "[]" operator to NTSL. You can do "sig.content" or "some_list[3]" now.
add: You can now create associative lists in NTSL using list()
tweak: Signal processing is done in a function called "process_signal" that must be defined by the user - one argument is passed, the signal argument, change properties on it to change the signal.
fix: The stack traces in the runtime errors for NTSL actually contain line numbers now.
tweak: Broadcasting in NTSL is now done by calling broadcast() with an argument of a signal object, which can be created with a signal() function. Remote signalling is done with remote_signal().
fix: You can do mem() in NTSL with the second argument null and it will remove the property
tweak: several global vars in NTSL have been moved to objects. Languages are in the "languages" object, filters are in the "filter_types" object, and channels are in the "channels" object.
/:cl:

@monster860 monster860 added Feature This adds new content to the game DO NOT MERGE Should not be merged without express approval from a Head Dev WORK IN PROGRESS This PR will take a while before its complete, but is actively being worked on. labels Feb 14, 2019
@Altoids1
Copy link
Contributor

image

@monster860 monster860 changed the title [WIP] NTSL refactor [READY] NTSL refactor Feb 20, 2019
@monster860 monster860 removed DO NOT MERGE Should not be merged without express approval from a Head Dev WORK IN PROGRESS This PR will take a while before its complete, but is actively being worked on. labels Feb 20, 2019
Copy link
Contributor

@Altoids1 Altoids1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So are you going to write up any documentation that actually lists off all the changes you've made to my baby, or are we all just kinda supposed to figure that one out ourselves more or less?

@Altoids1 Altoids1 added the Needs review This PR needs to be reviewed label Feb 22, 2019
@Altoids1 Altoids1 merged commit 7d8281c into yogstation13:master Feb 24, 2019
@yogstation13-bot yogstation13-bot added DME Edit This PR affects the yogstation.DME file Tweak This PR contains changes to the game. labels Feb 24, 2019
@Jc1469
Copy link
Contributor

Jc1469 commented Mar 2, 2019

disgusting

@snowsignal
Copy link

We should really add docs for this, I spent a while trying to find how the new NTSL worked.

@Altoids1 Altoids1 removed the Needs review This PR needs to be reviewed label Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DME Edit This PR affects the yogstation.DME file Feature This adds new content to the game Tweak This PR contains changes to the game.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants