Staredit Network > Forums > SC1 UMS Theory and Ideas > Topic: SCMD2 Text Trigger Commenting
SCMD2 Text Trigger Commenting
May 11 2013, 2:50 pm
By: Moose  

May 11 2013, 2:50 pm Moose Post #1

We live in a society.

While playing around with SCMD2 text triggers, I noticed that the seperator between triggers can use any number of dashses or be omitted entirely. It would come back the same way after compiling the triggers. So, having some C++ and PHP experience, I decided to check if Trigedit's parser would consider anything after a double forward slash (//) to be a comment. Well, we have another similarity between text triggers and those programming languages; the answer is yes.

So what's the significance? If you edit your triggers in an external text editor and copy/paste into SCMD2 text triggers, you can have unlimited commenting directly in the trigger text. If you happened to still use the comment action, now you can use this and save strings and an action. The limitation is that the comments disappear after compiling into the map, which is why you must keep the original copy of the triggers in an external text file.

So, anything after a double forward slash (//) is considered a comment until a new line starts. You can either start a line with // and have a full line comment or put // to comment after a specific condition, action, whatever. Unfortunately, while C++ and PHP support multi-line comments (/* ...comment... */), note that Trigedit does not.

Example:
"Commented Triggers"
// Death Counter Reference maybe?
// Unit Reference?
// Switch Reference?
// All kinds of Reference?
//
// Obscure triggers I forget the particular syntax of?
// Modify Unit Resource Amount(#)("Players", Resource Amount(#), Unit Amount(#), "Location");
// Leaderboard Goal Points("Label", Score Type, Goal Amount(#)); <-- Let's face it, I won't remember this one offhand.
// Leaderboard Goal Resources("Label", Goal Amount(#), Resource Type); <-- Now I don't have to look at that other text file that lists all the triggers and syntax.  Why is it not the help menu for Trigedit anyway?
// Modify Unit Shield Points("Players", "Unit Name", Shield%, Unit Amount(#), "Location");

Trigger("Player 8"){
Conditions:
    Always();

Actions:
    // This is a comment.
    Wait(0);
    Set Switch("Switch1", set);
    Wait(0); // Also a comment.
    Preserve Trigger();
}

//---- This thing used to seperate triggers?  Actually an automatically generated comment! ----------//

Trigger("Player 7"){ // Let's put a comment here because we can.
Conditions: // and here too.
    Switch("Switch1", set); // Here? Why not?

Actions:
    Set Switch("Switch1", clear);
    Wait(0);
    Preserve Trigger();
    // These were hyper triggers.
}

//-----------------------------------------------------------------//


compiles into:

"Compiled Triggers (Comments Removed)"
Trigger("Player 8"){
Conditions:
    Always();

Actions:
    Wait(0);
    Set Switch("Switch1", set);
    Wait(0);
    Preserve Trigger();
}

//-----------------------------------------------------------------//

Trigger("Player 7"){
Conditions:
    Switch("Switch1", set);

Actions:
    Set Switch("Switch1", clear);
    Wait(0);
    Preserve Trigger();
}

//-----------------------------------------------------------------//


I would keep the first set of triggers in a text file on my computer for editing and paste them into SCMD2 whenever I wanted them compiled into the map.

Happy Triggering! :moose:




May 11 2013, 7:26 pm Oh_Man Post #2

Find Me On Discord (Brood War UMS Community & Staredit Network)

Holy SHIT another big find...

Wait so if they disappear after compiling does this mean it is useless for the classic trigger editor?




May 11 2013, 11:23 pm Roy Post #3

An artist's depiction of an Extended Unit Death

Quote from Oh_Man
Wait so if they disappear after compiling does this mean it is useless for the classic trigger editor?
Yes. This text is just ignored at compile-time, and the regular separator comments are generated when you view the text trigger editor. You would not see any of these types of comments in the classic trigger editor, nor would you see it from opening the text trigger editor.

For a use-case scenario, Moose already provided an example: you paste the first snippet with all the comments into SCMD2 and compile, and when you close and re-open the text trigger editor, it will look like the second snippet with all the comments stripped.

If you already keep your text triggers in a separate text file, it's certainly more convenient to have this method of commenting available (you don't have to edit anything when pasting it into SCMD2), but other than that, there isn't any major applicable use.




May 12 2013, 12:04 am Azrael Post #4



Quote from Oh_Man
Holy SHIT another big find...

Don't act surprised :P Roy and I informed you about this four months ago, and you didn't seem very excited then lol.

I don't think it had its own thread at any point though, so this should be a good resource for explaining it to people.

Post has been edited 2 time(s), last time on May 12 2013, 12:11 am by Azrael.




May 12 2013, 12:19 am Ahli Post #5

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

I think Tuxlar used that a long time ago. Then I copied his style and notepad++ macros.
He added a triggers language to add a collapse/expand into the language to organize your code. So did I after he uploaded that somewhere, I believe.

This was 5 years ago.

I found this in my attachments: notepad++ macro
But I think you would need the language file which I haven't anymore, I believe. At least not on this computer. Maybe it's inside it. I don't know anymore... I think it's complete... it was too long ago. I can't remember it anymore...

edit:
Then my code looked like that:
Code
                //> random % DUR [25,75] (tmp0) index 306 -> 307
       
        Trigger("Player 1"){
        Conditions:
            Deaths("Current Player", "0 ItemCreationIndex", Exactly, 306);
        Actions:
           Preserve Trigger();
            Set Switch("Switch1", randomize);
            Set Switch("Switch2", randomize);
            Set Switch("Switch3", randomize);
            Set Switch("Switch4", randomize);
            Set Switch("Switch5", randomize);
            Set Switch("Switch6", randomize);
            Set Deaths("Current Player", "0 tmp0", Set to, 25);
        }
       
        //-------------------------------------------------------------------------//
        Trigger("Player 1"){
        Conditions:
            Switch("Switch1", set);
            Deaths("Current Player", "0 ItemCreationIndex", Exactly, 306);
        Actions:
           Preserve Trigger();
            Set Deaths("Current Player", "0 tmp0", Add, 1);
        }
       
        //-------------------------------------------------------------------------//



<//

Then I used my own string replacing program to translate my variables like "0 tmp0" into starcraft units.
I started them with a 0 and a space to create a unique starting string for the replacement to avoid unwanted replacements corrupting the code.

Post has been edited 1 time(s), last time on May 12 2013, 12:27 am by Ahli.




May 12 2013, 1:00 am Lanthanide Post #6



I remember a thread probably 2 years ago now where we talked about commenting and using the Comment action vs text-trigger comments.



None.

May 12 2013, 1:08 am Oh_Man Post #7

Find Me On Discord (Brood War UMS Community & Staredit Network)

Well if you can't use it in classic isn't it kind of useless? I mean comments are only handy when you are looking through classic not when you are scrolling through all dat raw code in notepad!




May 12 2013, 2:44 pm Moose Post #8

We live in a society.

Apparently this isn't as new to us as I thought.

Traditional comments are only useful in classic as they affect how the triggers are displayed. I must admit that I haven't used classic triggers in years. However, I sure have used the occasional comment and CTRL + F in text triggers find particular comments to jump directly to sections of triggers that I wish to edit.

Having a bunch of text in your triggers that doesn't take up strings in your map is pretty useful.

Whether or not these things are useful enough to justify having to edit triggers in an external program and copy/paste depends on the mapper's preferences and the particular maps.

Post has been edited 1 time(s), last time on May 12 2013, 2:51 pm by Mini Moose 2707.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[06:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[06:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[06:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
[06:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[06:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
[06:48 pm]
Vrael -- Perhaps that utilizes cutting-edge technology and eco-friendly cleaning products?
[06:47 pm]
Vrael -- Do you know anyone with a deep understanding of the unique characteristics of your carpets, ensuring they receive the specialized care they deserve?
[06:45 pm]
NudeRaider -- Vrael
Vrael shouted: I've also recently becoming interested in Carpet Cleaning, but I'd like to find someone with a reputation for unparalleled quality and attention to detail.
beats me, but I'd make sure to pick the epitome of excellence and nothing less.
[06:41 pm]
Vrael -- It seems like I may need Introductions to multiple companies for the Topics that I care deeply about, even as early as Today, 6:03 am.
[06:38 pm]
Vrael -- I need a go-to solution and someone who understands that Carpets are more than just decorative elements in my home.
Please log in to shout.


Members Online: NudeRaider