I recently decided to grab Starcraft 2 and check out its editor, as I used to have a wonderful time mapping for Warcraft III back in the day.
I've been trying to get into using galaxy's scripting language (I have experience in several C-family languages, so it's been a fairly easy transition), but I keep running into one problem, and I can't seem to find an answer to it anywhere.
As the title suggests, I need to know how to access resources, such as units and regions, inside of a galaxy script. Say, I create a region and name it "Spawn_Left". I try plugging that into my code, like so:
...works just fine. Am I supposed to access the regions by their ID or something? If so, how might I grab the ID to access them? Or is there some other way that I'm overlooking? I have this problem with units, regions, doodads, variables, and anything else created in the GUI editor.
If anyone could help, I would greatly appreciate it.
Thanks for your time.
Script users often encounter the problem of referencing terrain-editor placed objects. There are a few solutions.
RegionFromId (int id) is what GUI uses to get preplaced objects, but GUI has access to the ids; a scripter would need to find the id and input it manually, which is dreadfully cumbersome. RegionFromName (string name) is far more convenient and suits your implementation. One may also use the region API to create regions from the script rather than refer to preplaced regions, but it's not always practical.
EDIT: Oh, and your error was caused by an undefined identifier, in that Spawn_Left is not automatically made a variable by the editor, so you can't reference it like that.
Thanks for the reply! I tried using RegionFromName, and it worked perfectly.
As far as variables placed via GUI go, I did some digging and discovered that they can be referred to in script by adding the prefix "gv_", which I'm sure you already know. "waveTime" becomes "gv_waveTime", "currentLevel" becomes "gv_currentLevel", and so on.
Again, thanks for the help.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I recently decided to grab Starcraft 2 and check out its editor, as I used to have a wonderful time mapping for Warcraft III back in the day.
I've been trying to get into using galaxy's scripting language (I have experience in several C-family languages, so it's been a fairly easy transition), but I keep running into one problem, and I can't seem to find an answer to it anywhere.
As the title suggests, I need to know how to access resources, such as units and regions, inside of a galaxy script. Say, I create a region and name it "Spawn_Left". I try plugging that into my code, like so:
...and it just spits out an error. "Invalid parameter list." Whereas this:
...works just fine. Am I supposed to access the regions by their ID or something? If so, how might I grab the ID to access them? Or is there some other way that I'm overlooking? I have this problem with units, regions, doodads, variables, and anything else created in the GUI editor.
If anyone could help, I would greatly appreciate it. Thanks for your time.
Script users often encounter the problem of referencing terrain-editor placed objects. There are a few solutions.
RegionFromId (int id)
is what GUI uses to get preplaced objects, but GUI has access to the ids; a scripter would need to find the id and input it manually, which is dreadfully cumbersome.RegionFromName (string name)
is far more convenient and suits your implementation.One may also use the region API to create regions from the script rather than refer to preplaced regions, but it's not always practical.
EDIT: Oh, and your error was caused by an undefined identifier, in that Spawn_Left is not automatically made a variable by the editor, so you can't reference it like that.
@JademusSreg: Go
Thanks for the reply! I tried using RegionFromName, and it worked perfectly.
As far as variables placed via GUI go, I did some digging and discovered that they can be referred to in script by adding the prefix "gv_", which I'm sure you already know. "waveTime" becomes "gv_waveTime", "currentLevel" becomes "gv_currentLevel", and so on.
Again, thanks for the help.