Tool Galaxy parser

Anker

New Member
Reaction score
0
Code:
# function StructTest() {
#     myStruct myStructTest;
#     myStructTest.a = 256;
#     myStructTest.b = 874;
#

#     UIDisplayMessage(PlayerGroupAll(), 4, StringToText(IntToString(myStructTest.b)));
# }

That isn't valid Galaxy...

Oh, come on, that's valid.

I have tried this, and it displays "874". I think he just mistyped "function".
 

Anker

New Member
Reaction score
0
Yep just replace "function" with "void".

attachment.php


1.jpg
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
114
So What would you use for a number like 5.5. I cant find real anywhere...
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
114
Ill look around, But Is known yet if its possible to have a unit set to yaw, pitch, roll with code?
 

phyrex1an

Staff Member and irregular helper
Reaction score
446
Parser updated, works with most of the code posted here.

Except:
  1. -=, +=, etc style statements. Question: Does this work on all different binary operators (|=) (&&=), (&=), (/=) etc or just a few? I'm guessing that it doesn't work on the equality operators (==, >=) since the syntax for that doesn't make sense.
  2. Some usage of nested arrays/pointer dereferences (and declarations). I'm trying to figure out how to remove some ugly repetition before fixing this.
  3. Function pointer calls (The kind j4l reported giving errors in game).

Another question: Does this work (compiles and executes)
Code:
struct murder {
    string means;
    string time;
};

void apply(murder* attempt, string target){
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(target+" has died at "+attempt->time+" by: "+attempt->means+"."));
}
bool testthings (bool testConds, bool runActions) {
    murder how;
    how.time="midnight";
    how.means="axe to the fricking face";
    apply(&how,"A young boy");
    return true;
}
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
114
Code:
struct human {
    string name;
};

void test()
{
    human mark;
    string aName = "tom";
   
    mark.name = aName;
}

Why wont this pass the Parser?
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
114
Thanks. That did it.

What about this? Or how would you do it with in array of structs?

Code:
struct person
{
    string name;
};


void setup()
{
    //Dont Work
    person[2] aPlayer;
    aPlayer[0]->name = "Mark";
     
    //Works
    //person aPlayer;
    //aPlayer->name = "Mark";

}
 

phyrex1an

Staff Member and irregular helper
Reaction score
446
Code:
struct human {
    string name;
};

void test()
{
    human mark;
    string aName = "tom";
   
    mark.name = aName;
}

Why wont this pass the Parser?
Does that code compile is sc2? Please note that the parser is very much alfa software, always test the code in sc2 regardless of what the parser tells you. Please report any inconsistency between sc2 and the parser, I don't have the beta so I need other peoples input to figure out the correct syntax :p
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
114
I will be more clear for now on.

That only passed the alpha parser. So Not 100% chance it works in starcraft 2. I can not test it to be sure.
 

Anker

New Member
Reaction score
0
Code:
struct human {
    string name;
};

void test()
{
    human mark;
    string aName = "tom";
   
    mark.name = aName;
}

Why wont this pass the Parser?
Try "->" instead of ".".



You can't be serious! You are using '->' after a struct name, not a pointer. And you say "That did it."

Are you truly playing the same Starcraft 2 as mine?


My code:

Code:
struct myStruct {
    int a; 
    string b; 
};

void StructTest() {
    myStruct myStructTest;
    myStructTest.a = 256;
    myStructTest.b = "ABC";
    UIDisplayMessage(PlayerGroupAll(), 4, StringToText(IntToString(myStructTest.a)));
    UIDisplayMessage(PlayerGroupAll(), 4, StringToText(myStructTest.b));
}

It 100% works.

1.jpg


And myStructTest->a = "ABC" will never work.

See for youself, just put this MeleeAI.galaxy under SC2 InstallPath(ie.X:\...\StarCraft II Beta) and run any map with AI, you will see "256" and "ABC".
View attachment MeleeAI.galaxy.zip
 

Vestras

Retired
Reaction score
248
You can't be serious! You are using '->' after a struct name, not a pointer. And you say "That did it."

Are you truly playing the same Starcraft 2 as mine?


My code:

Code:
struct myStruct {
    int a; 
    string b; 
};

void StructTest() {
    myStruct myStructTest;
    myStructTest.a = 256;
    myStructTest.b = "ABC";
    UIDisplayMessage(PlayerGroupAll(), 4, StringToText(IntToString(myStructTest.a)));
    UIDisplayMessage(PlayerGroupAll(), 4, StringToText(myStructTest.b));
}

It 100% works.

View attachment 35994


And myStructTest->a = "ABC" will never work.

See for youself, just put this MeleeAI.galaxy under SC2 InstallPath(ie.X:\...\StarCraft II Beta) and run any map with AI, you will see "256" and "ABC".
View attachment 35996

I know, I just saw that the parser accepted it. Too lazy to try in SC2 to see if it's correct ;)
 

phyrex1an

Staff Member and irregular helper
Reaction score
446
Parser updated. I think it parses all examples in this thread (plus hopefully a lot more valid code), except the ones that actually contains syntax errors (j4l I'm looking at you). It also parses some syntactically invalid code, but I think I'll defer that checking to the (unwritten) type check for saner code.
 

ZugZugZealot

New Member
Reaction score
33
Code:
const int RED = 0x0000FF;
const int GREEN = 0x00FF00;
const int BLUE = 0xFF0000;

const int canHasPie = 0x0001;
const int isAwesome = 0x0002;
const int causeLaughter = 0x0004;
const int dances = 0x0008;
const int isPervert = 0x0010;

void DoThings(int flags) {
   if ( (flags & canHasPie)>0 ) { UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( "Here's a pie!" )); }
   if ( (flags & isAwesome)>0) { UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( "You are awesome!" )); }
   if ( (flags & causeLaughter)>0 ) { UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( "I lol'd!" )); }
   if ( (flags & dances)>0 ) { 
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( "<(''<)" ));
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( " <(''<)" ));
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( " (>'')>" ));
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( " <(''<)" ));
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( " <(  )>" ));
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( " (>'')>" ));
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( " <('')>" ));
   }
   if ( (flags & isPervert)>0 ) { 
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( "Scanning harddrive..." )); 
      UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText( "Fap results: 29401" )); 
   }
}

int GetRed(int rgbVal) {return (rgbVal & RED);}

int GetGreen(int rgbVal) {return (rgbVal & GREEN);}

int GetBlue(int rgbVal) {return (rgbVal & BLUE);}

void testFunc()
{
   int i = 0x0000FF;
   int rgbVal = 0xFFFF80;
   
   UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText("red is " + IntToString(GetRed(rgbVal))));

   DoThings(canHasPie|isPervert);
}

Yay! It uses 'or' and 'and' operators!

Sadly it doesn't like bitwise-left and bitwise-right. =(
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top