I am trying to get the player's army composition (e.g. 10 drones, 1 overlord, 3 larva, etc.) written out to a bank file when a new unit is created. What I have currently is pasted below. My current issue is I'm only able to get the total number of units, and I'm not able to get the unit name/identifier written out. Ideally, I'd be writing data out:
"drones" : 10
"overlord" : 1
"larva" : 3
Can anyone offer some direction on how to get this working properly? It's not critical I get the actual unit name. So long as it's some unique identifier, I can figure out what those identifiers are and then create a mapping between those and "human-readable" names farther down in my stack.
switch depending on unit type of unitpicked unit if (drone) set unitpickedname = drone
there might be a way to return as the name of the unit but i don't have editor open right now and i'm too lazy to do so right now, i'll edit this in the morning and post a new reply if i find an easier method.
Cool! Thanks! Would appreciate that. I saw some code on this site for doing it for a specific unit, but doing it for every race and unit in that race seems a bit redundant, but if it's the only way I suppose it'll have to be done that way.
And at the next layer in my stack (I'll share this project once it's complete), I'm able to condense this into the desired format of:
SCV : 7
CommandCenter : 1
Marine : 1
I didn't see anyway to iterate over each type of unit and write this out directly from SC2 to the bank files without doing if (Marine ) if (SCV), etc. Does anyone know if there are any optimizations between my code and the final desired product?
Ahh sorry - should've been clearer. This doesn't have to do with the Unit/Name stuff - that can easily be removed in the Editor or later on as I'm doing now.
I meant currently I write out SCV, SCV, SCV, SCV, Command Center to my bank file. Is there any way to make it so I can write out SCV 6, Command Center 1, Marines 17, etc. Right now I just write out a list of every unit.
I suppose I could do as I'm doing now, but for every unit type, get the total of that unit and write that, but then I'd still be writing N times if I have N units no?
I am trying to get the player's army composition (e.g. 10 drones, 1 overlord, 3 larva, etc.) written out to a bank file when a new unit is created. What I have currently is pasted below. My current issue is I'm only able to get the total number of units, and I'm not able to get the unit name/identifier written out. Ideally, I'd be writing data out:
"drones" : 10 "overlord" : 1 "larva" : 3
Can anyone offer some direction on how to get this working properly? It's not critical I get the actual unit name. So long as it's some unique identifier, I can figure out what those identifiers are and then create a mapping between those and "human-readable" names farther down in my stack.
Many thanks!
switch depending on unit type of unitpicked unit
if (drone)
set unitpickedname = drone
there might be a way to return as the name of the unit but i don't have editor open right now and i'm too lazy to do so right now, i'll edit this in the morning and post a new reply if i find an easier method.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
@willuwontu: Go
Cool! Thanks! Would appreciate that. I saw some code on this site for doing it for a specific unit, but doing it for every race and unit in that race seems a bit redundant, but if it's the only way I suppose it'll have to be done that way.
here's a map that returns the unit's name, you'll have to convert it to what you want in order to use it, but it gives you the idea
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
@willuwontu: Go
Thank you thank you thank you! That worked great! For anyone who stumbles upon this later, here is my trigger to get this working:
This will write out data to the bank that looks like:
And at the next layer in my stack (I'll share this project once it's complete), I'm able to condense this into the desired format of: SCV : 7 CommandCenter : 1 Marine : 1
I didn't see anyway to iterate over each type of unit and write this out directly from SC2 to the bank files without doing if (Marine ) if (SCV), etc. Does anyone know if there are any optimizations between my code and the final desired product?
Thanks all!
you can get rid of the Unit/name/ by removing the first 10 characters of each string btw.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
@willuwontu: Go
Ahh sorry - should've been clearer. This doesn't have to do with the Unit/Name stuff - that can easily be removed in the Editor or later on as I'm doing now.
I meant currently I write out SCV, SCV, SCV, SCV, Command Center to my bank file. Is there any way to make it so I can write out SCV 6, Command Center 1, Marines 17, etc. Right now I just write out a list of every unit.
I suppose I could do as I'm doing now, but for every unit type, get the total of that unit and write that, but then I'd still be writing N times if I have N units no?
what you're doing is fine i was just commenting on how the example above had:
and how you could get rid of that easily
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)