| Language Overview |
Sixen |
avogatro |
Mar 16, 2011 |
| Hint OUTSIDE a function, a variable can only be defined with simple values: int a = 5; U can't use any complex operation. int a = 5+5; will fail, game will not start. In a function, never define new variable, after some operation. void test(){ int a = 15; a+=15; int b; } in that case int b will fail. Language Features if if (RandomInt(1, 3) == 1) // Brace required { Print("Good"); } else if (Random(1, 5) < 4) // else if { Print("Average"); } else { Print("Bad"); } while int i = 0; // You can... |
| Errors |
Sixen |
Ardnived |
Feb 27, 2011 |
| Syntax error You are using a function that is forward defined: void func () { forwardDefinition(); } void forwardDefinition() { } Solution 1: Put the function before void forwardDefinition() { } void func () { forwardDefinition(); } Solution 2: Put the function prototype before void forwardDefinition(); // Prototype void func () { forwardDefinition(); } void forwardDefinition() { } Variable declarations must be made at the top of the function. void func() { int a; a = 1; int b; // Must be... |
| Language Overview / Arrays |
Sixen |
moshewe |
Jan 14, 2011 |
| Arrays are a way to store and use multiple values of the same type. int[10] list; int i = 0; while (i < 10) { list[i] = i * i; i += 1; } print(list[5]); // 25 print(list[10]); // error, index overflow The list then has 10 values in it, indexed from 0 to 9, filled with the values { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 }. Arrays must have their length pre-declared. As far as Galaxy is concerned, int[10] is a completely different type from int[12]. Arrays can be of any type. struct MyType { int... |
| Callbacks |
Sixen |
Sixen |
Aug 17, 2010 |
| Callbacks are functions called by Starcraft II directly when an event occur. InitMap() - After all the galaxy files have been parsed. DebugCallback(int player) AI AIMeleeStart(int player) AINewUnit(int player, unit u) AIIsAttacking(int player) AINeedsDefending(int player) AICombatPriority(unit target, unitgroup attackers, unitgroup enemies) AITownIsFull(int player, int town) AIWaveThink(int player, wave w, int type) AITownWasLost(int player, int town) AIMelee(int player) AIWaveAddedUnit(int,... |
| Language Overview / Structs |
Sixen |
Sixen |
Aug 17, 2010 |
| structs are data structures which hold other relevant pieces of information. Defining a struct Let's say I want to have a monkey and track the number of bananas it has and also how much poo the monkey has flung thus far. struct Monkey { int numBananas; int pooFlung; }; // ending semicolon is important There I defined a struct named Monkey that has a two fields: int numBananas and int pooFlung. To make a new Monkey, all that needs to be done is to declare Monkey myMonkey; Creating a struct... |