Staredit Network > Forums > SC1 Mapping Tools > Topic: Trigger Sorter
Trigger Sorter
Jun 17 2009, 5:48 am
By: Vrael  

Jun 17 2009, 5:48 am Vrael Post #1



I just finished writing a program that takes a .txt file of triggers and sorts it into 9 .txt files, separating Player 1, Player 2, Player 3, ... , Player 8, into their own .txt files, and 1 file for "Other Players" (all players, forces, ect)
I figured I ought to share this with everyone else, dunno how much use will come of it, but hey, why not right?
It formats triggers like SCMDraft's text editor, and as long as starforge uses { } on its triggers I think it should work with that too. To use it, put your triggers.txt into the same folder as this application "Trigger Filter.exe" and run it, type the name of your file in, and 9 text files will pop up for you.

If anyone knows C++ and would like the source code to improve upon/write their own or whatever, I'd be glad to provide it, just PM me or something.
Worked great on my triggers.

Zip File Link (.exe, Readme, and Source Code): http://cid-681c2250300dd052.skydrive.live.com/self.aspx/Public/Trigger%20Filter.zip

Post has been edited 2 time(s), last time on Jun 17 2009, 7:11 am by Vrael.



None.

Jun 17 2009, 5:50 am Falkoner Post #2



Hmm, I'd love to see the source so I can get an idea of how to work with SC files, also, I think a cool program would be one that takes them and actually puts them in the order that they will run, splitting All Players or Force triggers into separate triggers as well.

EDIT: Oh, this doesn't pull the triggers from the map, nvm about the sourcecode then :(



None.

Jun 17 2009, 5:53 am Vrael Post #3



Adding the source code to my skydrive with its own link now, but it won't really help you much falk unless you know C++ because it's really just text manipulation. It finds specific strings like "Trigger("Player 1")" and the "{" and "}" to determine where a trigger stops, and basically uses that information to filter the trigger into the correct .txt file.

Yeah I don't know anything about the .chk really so I wouldn't know where to start making a program that will show triggers in the order they run. Unless I'm mistaken though, in the Player1.txt ... Player8.txt files from my filter program they will be in runtime order, just missing "all players" and "force" triggers.



None.

Jun 17 2009, 5:58 am Falkoner Post #4



Yeah, I realized that, and I do know C++, I was just hoping to see the source for a program that extracted info from a map, since I'd like to write programs to do that.

Also:
"The application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem"

I have it in a folder, alone, with a file called "Triggers", and that's what I get when I run it.

EDIT: Actually, I think this program with some tweaks should be able to put them in the order they run, you'd just have to split the triggers under forces between the players, of course, it'd be a bit more difficult, since you're not just adding the trigger to the end of the right file depending on it's beginning, you'd have to insert and such.



None.

Jun 17 2009, 6:00 am scwizard Post #5



Err, if I have a trigger for players 1 2 and 5, I don't like the idea of that trigger being in 3 separate text files.

Great idea though, good luck with polishing it. I don't get why you'd use C++ though. This seems like the kind of macro one would typically write in bash or emacs or something.



None.

Jun 17 2009, 6:01 am Vrael Post #6



Hrm. Maybe it's because I have a 64-bit OS? Idk. If you have your own compiler you can copy my source code into your compiler and make it for yourself.

A trigger like " Trigger("Player 1", "Player 2", "Player 5",) " will be put into the "Other Players.txt" file.



None.

Jun 17 2009, 6:01 am Falkoner Post #7



Quote
Err, if I have a trigger for players 1 2 and 5, I don't like the idea of that trigger being in 3 separate text files.

Yeah, but that's really how it runs, 3 different times.



None.

Jun 17 2009, 6:03 am scwizard Post #8



Quote from Falkoner
Quote
Err, if I have a trigger for players 1 2 and 5, I don't like the idea of that trigger being in 3 separate text files.

Yeah, but that's really how it runs, 3 different times.
I know, but if I want to change what runs those three times I can do it by editing one line.

After running your thingy, I'd have to edit three different lines in three different files.



None.

Jun 17 2009, 6:04 am Vrael Post #9



If SI or someone can teach me how SCMDraft makes trigger ID's and puts that information into text-based triggers, then I can probably make it sort into runtime order.



None.

Jun 17 2009, 6:10 am scwizard Post #10



Quote from Vrael
If SI or someone can teach me how SCMDraft makes trigger ID's and puts that information into text-based triggers, then I can probably make it sort into runtime order.
What do you mean by "makes trigger IDs"?

Also if the input is coming from trigedit, isn't it already in order?

Quote
scwiz, my program doesn't split a Trigger(P1,P2,P5) into 3 trigs yet, just dumps it in the 9th file
Good I'd prefer things that way. In that case I may use this program at some point.



None.

Jun 17 2009, 6:11 am Falkoner Post #11



Quote
Also if the input is coming from trigedit, isn't it already in order?

Nope, no matter what, P1 runs all his triggers first, through P8, and that includes the triggers combined with other players too.



None.

Jun 17 2009, 6:20 am scwizard Post #12



Quote from Falkoner
Quote
Also if the input is coming from trigedit, isn't it already in order?

Nope, no matter what, P1 runs all his triggers first, through P8, and that includes the triggers combined with other players too.
Yeah, but remember this program is separating things by players. So P1.txt will be in order P2.txt will in order etc right?



None.

Jun 17 2009, 6:27 am Vrael Post #13



Quote from scwizard
Quote from Falkoner
Quote
Also if the input is coming from trigedit, isn't it already in order?
Nope, no matter what, P1 runs all his triggers first, through P8, and that includes the triggers combined with other players too.
Yeah, but remember this program is separating things by players. So P1.txt will be in order P2.txt will in order etc right?
Yeah, but some triggers from the Other Players.txt will be running during the P1.txt file, so the whole trigger set isn't precisely in order. I'm going to do some copy/pasting/filtering with SCMDraft and my new program to see if I can glean any useful information out of this. Gonna try copy/pasting into trigedit in my map in order of the txt files and see if it organizes them. If it works, at least P1-P8 triggers will all be together in the trigedit instead of all mixed up.



Edit:
Important Change
I noticed that strings used in the game, like if you had a guy go "Townsfolk: Hey Bob!" would mess with the ability for SCMDraft to recompile the text, since strings had to be on a single line. This occured because of special characters like the ":" in "Conditions:"
I think I fixed this, new link is on first post.

Edit2:
Yeah, after using my filter then copying them back into SCMDraft's trigedit, the classic trigedit is unchanged from before I did anything, but the text editor is a lot more organized. The Force triggers are still a bit mixed up, but they're at the bottom at least.
This means tweaking my program to make it so they go into runtime order will be a lot harder if I ever figure out how the triggers are ordered.

Post has been edited 3 time(s), last time on Jun 17 2009, 7:40 am by Vrael.



None.

Jun 17 2009, 9:27 am Ahli Post #14

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

I cannot start your exe because of some side-by-side-configurations... (I compiled your code myself with g++).

I would build in 2 modes. At least I would use this program to analyze the triggers of a player (finding bugs faster). You need to add the force/all players triggers in the right order to the e.g. Player1.txt, too. Then you can easily see ALL triggers that are owned by a player to debug your triggers.

btw, if there is a comment or the "zoom in comment"
( source text:
"
//<
//> Hypertrigger
Trigger("All players"){
" )

in the text, they will screw the triggers atm
(gives:
//-----------------------------------------------------------------////<//> HypertriggerTrigger("All players"){
)




Jun 17 2009, 6:05 pm Falkoner Post #15



Quote
This means tweaking my program to make it so they go into runtime order will be a lot harder if I ever figure out how the triggers are ordered.

It's actually pretty simple how they're ordered, they run from Player 1 to Player 8, in the order that they are in the editor, if a force or All Players or multiple players selected trigger is hit, it will only run if the player who's triggers are currently being run is one of the players that the trigger is marked for.



None.

Jun 18 2009, 12:10 am Heinermann Post #16

SDE, BWAPI owner, hacker.

I don't see a benefit to using this program. In fact, I think it's a downfall for triggers impacting the map's file size.




Jun 18 2009, 12:41 am scwizard Post #17



Quote from Heinermann
I don't see a benefit to using this program. In fact, I think it's a downfall for triggers impacting the map's file size.
I don't see what you mean.

Also the benefit is that you have your triggers organized in the fashion that classic trig edit organizes them.



None.

Jun 18 2009, 4:07 am Vrael Post #18



Quote from Ahli
I cannot start your exe because of some side-by-side-configurations... (I compiled your code myself with g++). I would build in 2 modes. At least I would use this program to analyze the triggers of a player (finding bugs faster). You need to add the force/all players triggers in the right order to the e.g. Player1.txt, too. Then you can easily see ALL triggers that are owned by a player to debug your triggers. btw, if there is a comment or the "zoom in comment" ( source text: " //< //> Hypertrigger Trigger("All players"){ " ) in the text, they will screw the triggers atm (gives: //-----------------------------------------------------------------////<//> HypertriggerTrigger("All players"){ )
I have never used comments or zoom-in comments in my SCMDraft text triggers, so I don't know what to do to account for this capability. This program formats the triggers based on the occurence of these specific substrings:
"tions:"
"{"
"}"
"/T"
");"
That's why it messed up that specific text.


Quote from Falkoner
Quote
This means tweaking my program to make it so they go into runtime order will be a lot harder if I ever figure out how the triggers are ordered.
It's actually pretty simple how they're ordered, they run from Player 1 to Player 8, in the order that they are in the editor, if a force or All Players or multiple players selected trigger is hit, it will only run if the player who's triggers are currently being run is one of the players that the trigger is marked for.
So when SC goes to execute triggers, it checks the entire trigger list for P1 triggers, and just skips over P2 triggers? Then it switches into "P2" mode, skips the P1 triggers, and executes all P2 triggers? Then into "P3 mode" and skips the P1 and P2 triggers and runs all P3 triggers? If this is what you mean , then I can probably modify the program to filter them correctly, splitting them into the correct file. I'll need to add a "force" and "Players in each force" input though, damn that'll be annoying.



Quote from Heinermann
I don't see a benefit to using this program. In fact, I think it's a downfall for triggers impacting the map's file size.
Then don't use it. It doesn't affect the map's file size at all.



Quote from scwizard
Also the benefit is that you have your triggers organized in the fashion that classic trig edit organizes them.
Yeah, kinda. It still doesn't separate "force" and "all players" triggers, but my idea behind this was that I'd be able to look at JUST P1's trigger list in the text editor. Also, after sending my triggers through this filter and copying back into SCMDraft in order, the text editor is nice an organized with all P1's triggers, then all P2's triggers, ect.



None.

Jun 18 2009, 4:21 am Falkoner Post #19



Quote
So when SC goes to execute triggers, it checks the entire trigger list for P1 triggers, and just skips over P2 triggers? Then it switches into "P2" mode, skips the P1 triggers, and executes all P2 triggers? Then into "P3 mode" and skips the P1 and P2 triggers and runs all P3 triggers? If this is what you mean , then I can probably modify the program to filter them correctly, splitting them into the correct file. I'll need to add a "force" and "Players in each force" input though, damn that'll be annoying.

Yeah, that's exactly how it works :)

Quote
Then don't use it. It doesn't affect the map's file size at all.

It does since it splits triggers for multiple players(I think)



None.

Jun 18 2009, 5:25 am Vrael Post #20



Quote from Falkoner
Quote
So when SC goes to execute triggers, it checks the entire trigger list for P1 triggers, and just skips over P2 triggers? Then it switches into "P2" mode, skips the P1 triggers, and executes all P2 triggers? Then into "P3 mode" and skips the P1 and P2 triggers and runs all P3 triggers? If this is what you mean , then I can probably modify the program to filter them correctly, splitting them into the correct file. I'll need to add a "force" and "Players in each force" input though, damn that'll be annoying.
Yeah, that's exactly how it works :)
Quote
Then don't use it. It doesn't affect the map's file size at all.
It does since it splits triggers for multiple players(I think)
At this point in time the program has no trigger-splitting capability, and hence no additional filesize. I may add this functionality in soon, but I need to work on my map first a bit, then put some thought into how to accomplish the additional splitting/sorting functionality, since it will need to encompass user-input force names and text manipulation with C++ isn't my strongest venue :)

Currently the program just detects use of the special character sequences above to create the SCMDraft-compatible formatting, but I may need to think up something better. Maybe using an array of strings in my program would work better than just concatenating the whole trigger and reformatting it in the output stage, but I'm not all that familiar with the ins-and-outs of the standard C++ string class so I'd need to do some testing first. Or maybe I can do something with the getline() tool and constantly detect for a "Trigger(" type substring and just switch which file is being filtered into at the moment. Hopefully this program will be of some use to someone other than me, it's really already accomplished what I needed it for but I'll try to expand on it and make it more useful.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:05 pm]
Vrael -- Its simple, just send all minerals to Vrael until you have 0 minerals then your account is gone
[04:31 pm]
Zoan -- where's the option to delete my account
[04:30 pm]
Zoan -- goodbye forever
[04:30 pm]
Zoan -- it's over, I've misclicked my top right magic box spot
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- there are some real members mixed in those latter pages, but the *vast* majority are spam accounts
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- there are almost 3k pages
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- the real members stop around page 250
[2024-4-14. : 9:20 pm]
O)FaRTy1billion[MM] -- look at the members list
[2024-4-12. : 12:52 pm]
Oh_Man -- da real donwano
da real donwano shouted: This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
it's pretty common
[2024-4-11. : 9:53 pm]
da real donwano -- This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
Please log in to shout.


Members Online: jjf28