Tutorials/Common Error Messages
The idea of this page is to collect error messages and then write a little bit about how they occured and what the fix is. You can search the page using your browsers search function. If you're having trouble finding the cause of your error, make sure you enable the debugger inside the "File >> Preferences" menu. While you're there, make sure you check the box to freeze the game upon encountering an error. With this enabled, whenever you encounter an error, the game will pause and you can see the values of every variable (including local variables and parameters used within the Action that had an error)
- 1 Errors
- 2 Other Problems
When publishing, this is what you get when the process failed.
- Check your "Map>Player properties". No player may have their race defined in there. It should be set as random. Player race should be defined in Map>Game Variants.
Script load failed: Syntax error
When working with custom scripting (meaning you're not using the trigger editor), you can get parsing errors.
- Make sure all brackets have pairs. This can be done in dedicated coding text-editors such as Galaxy++ or Notepad++.
- Functions that have a return type (not void) needs to have a return statement.
Expected a return value
You'll usually get this error when saving or trying to run the map. If you have a function that returns something, it must always return in any circumstance.
- If you add Return statements directly into if-then or switch statements, all possible outcomes must have a Return statement. In particular, the default value can be easy to miss.
- This error will usually open the mapscript and show you a line number where the error occurred. You can just scroll up to see what function is causing the problem.
Negative Array Indexes are Not Supported
When working with arrays, you tried to use a negative index somewhere.
- You can't use a negative index if you're using triggers, so it usually means you have a function that's returning a value of -1.
- For example, if you set "Set Variable MyVariable[Player from player group (An Empty Player Group)] = 1", a negative value could be returned and then inserted into the index
Out-of-Bounds Array Index
This is similar to the negative array index error (see above), but it means you went too high instead of too low. Arrays have an upper limit, which you set when creating the variable. This error means you're trying to reference an index that's bigger than your array size. So if you have a size 15 array, you can't try to set or read MyVariable.
- Like negative indexes, the GUI editor won't allow you to set a value that's too high, meaning you have a function that's returning something too high. Look for anywhere you used a function to return the index of an array.
- For example, if you said "Set MyVaraible[Triggering Player] = 1", you could get an error if the player's number was higher than your array's size.
Execution took too long
Every trigger or action must be run completely before the game can move to the next cycle of the game loop. It's a little complicated, but basically it means sc2 can't do what you're asking it to do within the time of once cycle.
- This usually happens if you're trying to run loops inside of more loops, or if you're using too many Repeats or a Repeat Forever.
- If you add a "wait" action, it will allow the game to continue running without finishing your action right away. One game loop "cycle" is a very small amount of time, so you can just wait 0.0016 seconds to avoid the error.
You see a Placeholder Gray Ball instead of a real model
If you have been working with custom units and models, this can be an outcome. The cause is an improper linking between the actor, model and the unit. Make sure the actors Token has been properly defined or that the events are not trying to create the same Unit or Doodad type actor several times at once.
Resources can not be harvested
Resources are units and thus owned by a player. If the player is not 0 (neutral), it might be a enemy. Friendly units may not harvest enemy resources using the default Harvest ability, only neutral ones.