TriGen
Apr 11 2017, 9:24 pm
By: Zoan  

Apr 11 2017, 9:24 pm Zoan Post #1

Math + Physics + StarCraft = Zoan

---TriGen- A Trigger Generator for Python

**Version 0.0.5 downloadable at the bottom!**


Introduction:

The goal of TriGen is to provide an intuitive way to create macro triggers. It is most similar to Oreo Triggers (which utilizes php) in that it provides a variety of different classes to make writing triggers more intuitive, as well as a variety of other additional modifiers you can add to triggers. It expands upon Oreo Triggers in that it offers an easier to type syntax, more features, Python's compiler which does not require a web-browser, auto-completion of partially typed functions for quicker typing, and a much easier method of creating custom conditions.

As with most other trigger generators, TriGen is a program which reads code written in a file (in this case a Python file) and outputs a text file containing the generated triggers. You then copy and paste these triggers into your map on a map editor like SCMDraft.


Features:

TriGen offers many handy features. Here are a few of them:

  • Easy to type and read syntax.
  • 'and', 'or', and 'not' statements in conditions.
  • An intuitive way to create macro conditions and actions.
  • Else statements.
  • A way to 'discretize' triggers so they only execute when conditions become met.
  • Multiple ways to call the same conditions and actions.
  • The ability to add and subtract two Deathcounters.

How to Get Started:


Step 1: Downloading Python

First off, TriGen is a program written in Python which reads Python files and outputs a text file. You will need to download Python Version 2.7 or higher in order to run TriGen.

You can download Python from here.


Step 2: Preliminary Modifications

After downloading TriGen, open up the Maps folder contained in the TriGenBeta folder you just downloaded. Within it should be a file called 'template.py.'

To begin with, we must first edit this file slightly. Open template.py with a text editor (I like to use Notepad++).

The part of this file we want to edit is the part containing something like 'C:\\PythonPrograms\\TriGen.0.0.5\\TriGen' at the top of the file.

Change this to whatever location you downloaded TriGen to.


Step 3: Familiarizing Yourself with Python and How to Use it

After downloading Python, open up command prompt (or its equivalent on whatever operating system you are using (e.g. Windows, Mac, Linux)).

To do this on Windows, click on the "Start" button on the bottom left, and then select "Run" and type in 'cmd' and then press Ok.

For those unfamiliar, you type 'cd -name of folder-' to move around folders within command prompt, and type 'cd ..' to back out of a folder. Also type 'dir' to see a list of all folders and files in the folder you are currently in.

Within command prompt, navigate to the TriGenBeta folder that you downloaded, and then to the Maps folder.

Now type 'python template.py output.txt', and hit enter.

You should get a print out on command prompt informing you everything was generated properly.

What just happened is that TriGen read in the 'template.py' file and generated triggers to the 'output.txt' file, which you may now copy and paste into your map. It's as easy as that! :D


How To Write Triggers In TriGen Syntax:

Triggers are simple. They need three basic things:

  • Players which own the trigger
  • Conditions
  • Actions

Thus, the syntax for making triggers in TriGen is just as simple. Here is is:

T( P=[Players], C=[Conditions], A=[Actions] )

For example, lets say we want to have the following trigger:

Example
Players

  • Player 1
  • Conditions

  • Command("Current Player", "Terran Marine", "At least", 1);
  • Actions

  • Display Text("You own a marine!", Always Display);
  • Preserve Trigger();


  • To write this in TriGen, we write the following:

    T( P=[1], C=[command(cp, "Terran Marine")], A=[display_text("You own a marine!")] )

    As stated before, there are number of ways to call the same conditions or actions in TriGen. For example, we can replace command(cp, "Terran Marine") with cp.command("Terran Marine"), or if we have a 'marine' object defined as a Unit beforehand, we can write marine.command(cp).

    Note that TriGen automatically assumes the "At least" and "1" part of the rest of the condition. It does this when you leave those slots blank. In general, TriGen will assume the rest by trying to affect 'as much as possible.'

    For example, in conditions, it will do the most general case (e.g. locations will be assumed to be "Anywhere", modifiers will be "At least", units will be "Any unit", etc.).

    A List of all the Classes and their Features:

    DC


    --I ran out of space, so I will move everything over to GitHub once I figure out how to do that--

    Thanks for trying it out!:

    Thanks!

    Update Notes:
    Version 0.0.3:
    1. It works :lol: Version 0.0.2 does not, as I made a dumb mistake right before uploading it.

    Version 0.0.4:
    1. Fixed some bugs (don't remember exactly what they were)
    2. Added the ability to input lists into the player slot in triggers:
    For example, you can now have something like the following:

    survivors = [p[1], p[2], p[3], p[4]]
    T( P=[survivors], C=[conditions...], A=[actions...] )

    3. Added the ability to input lists into actions. Doing so outputs that action for each player (e.g. if you have 3 players in that list, it will output three actions, one for each player).

    Version 0.0.5:
    1. Fixed some bugs in a few of the classes, particularly the Location class.
    2. Fixed some bugs in the Trigger class.





    Attachments:
    TriGen.0.0.5.zip
    Hits: 7 Size: 103.11kb

    Post has been edited 12 time(s), last time on May 15 2017, 1:29 am by Zoan.



    \:rip\:ooooo\:wob\:ooooo \:angel\: ooooo\:wob\:ooooo\:rip\:

    Apr 11 2017, 9:43 pm Matt.- Post #2

    CCSM, PCNSE7

    Looks pretty intuitive. I'll take a look at it with a quick test map when I get home.



    Latest Completed Projects:
    Dodge & Attack
    Stacked Marine D

    Apr 12 2017, 5:52 am NudeRaider Post #3

    We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

    Quote from Zoan
    The goal of TriGen is to provide an intuitive way to create macro triggers. It is most similar to Oreo Triggers (which utilizes php) in that it provides a variety of different classes to make writing triggers more intuitive, as well as a variety of other additional modifiers you can add to triggers.
    Not to sound condescending, but what's the advantage (going to be) of your editor? What does your editor offer that other's don't? (sell your product!)




    Apr 12 2017, 4:51 pm Zoan Post #4

    Math + Physics + StarCraft = Zoan

    Quote from NudeRaider
    Quote from Zoan
    The goal of TriGen is to provide an intuitive way to create macro triggers. It is most similar to Oreo Triggers (which utilizes php) in that it provides a variety of different classes to make writing triggers more intuitive, as well as a variety of other additional modifiers you can add to triggers.
    Not to sound condescending, but what's the advantage (going to be) of your editor? What does your editor offer that other's don't? (sell your product!)

    I edited it to explain why I made TriGen after using Oreo Triggers for a long time.



    \:rip\:ooooo\:wob\:ooooo \:angel\: ooooo\:wob\:ooooo\:rip\:

    May 6 2017, 7:21 pm Zoan Post #5

    Math + Physics + StarCraft = Zoan

    Added Version 0.0.4. I will finish up the list of classes and their functions today as well. I made the list but it was too long to upload to Sen.

    Post has been edited 2 time(s), last time on May 15 2017, 1:21 am by Zoan.



    \:rip\:ooooo\:wob\:ooooo \:angel\: ooooo\:wob\:ooooo\:rip\:

    Aug 10 2017, 5:37 pm BumpelSnake Post #6



    Is this still worked on? Did you make a more detailed documentary? I can't seem to find your list.

    Good work so far!



    None.

    Aug 11 2017, 3:50 pm Zoan Post #7

    Math + Physics + StarCraft = Zoan

    I haven't worked on this for a while, but will if I ever get back into map making, which will probably happen sometime after the Remaster comes out.



    \:rip\:ooooo\:wob\:ooooo \:angel\: ooooo\:wob\:ooooo\:rip\:

    Aug 12 2017, 3:35 am ImagoDeo Post #8



    Quote from Zoan
    I haven't worked on this for a while, but will if I ever get back into map making, which will probably happen sometime after the Remaster comes out.

    Would be nice to have more documentation on this. It looks like the most intuitive out of my various trigger generation options.



    None.

    Aug 30 2017, 4:56 am DeadlyBytes Post #9

    ( Discord: DeadlyBytes#6993 / Steam: /id/Bytes )

    Thank you for this! Took a bit of work to get situated, and had to go over some of the files but this is pretty awesome! I really hope this project doesn't die.


    EDIT:

    Really enjoy how customizable the whole thing is, I've already added and tweaked a couple of action/conditions. And I really like the fact I can split up my triggers over multiple files and have it import all of them when generating the triggers.

    Post has been edited 1 time(s), last time on Aug 30 2017, 5:18 pm by DeadlyBytes.



    None.

    Jan 3 2018, 2:25 pm T-warp Post #10



    You should eliminate the need for python to be installed with some compiler (py2exe for example).



    None.

    Options
      Back to forum
    Please log in to reply to this topic or to report it.
    Members in this topic: None.
    [06:11 pm]
    Suicidal Insanity -- Dem0n
    Dem0n shouted: It's hardly even a SEN server honestly. Just mostly the same 10 people saying dumb shit LMAO
    Sounds like SEN shoutbox :P
    [04:47 pm]
    Dem0n -- then again w/e
    [04:46 pm]
    Dem0n -- It's hardly even a SEN server honestly. Just mostly the same 10 people saying dumb shit LMAO
    [04:46 pm]
    Dem0n -- NudeRaider
    NudeRaider shouted: Voyager7456 there should probably be a place more obvious that gives the link to the discord server. I'd say we're past trial stage by now.
    no tbh. Lots of dumb people that shouldn't be on it.
    [04:45 pm]
    Suicidal Insanity -- Naw, somebody just redefined what one standard moose is
    [04:39 pm]
    Dem0n -- Our Moosey's all grown up C|:'^ )
    [04:36 pm]
    Dem0n -- O__________________________________________________________O
    [04:17 pm]
    jjf28 -- moose is no longer a mini O.O
    [10:41 am]
    NudeRaider -- NudeRaider
    NudeRaider shouted: Voyager7456 there should probably be a place more obvious that gives the link to the discord server. I'd say we're past trial stage by now.
    In the menu. Probably an item under Site, or preferably next to Wiki
    [10:40 am]
    NudeRaider -- Voyager7456
    Voyager7456 shouted: You download Discord and join the SEN server :P
    there should probably be a place more obvious that gives the link to the discord server. I'd say we're past trial stage by now.
    Please log in to shout.


    Members Online: Roy, Excalibur, Suicidal Insanity