Page 1 of 1
Coding Questions
Posted: Thu Mar 31, 2016 4:27 pm
by GaryChildress
I tried to create a code that will rename units of a particular regime (regime 0) to names from a predefined string list. When I run it, however, it doesn't rename anything. Would anyone be able to spot where I'm going wrong? [:o]
0) LOOPER: TempVar0 FROM 0 TO CheckTotalHistoricalUnits
1) CHECK: CheckUnitOwner(TempVar0) == 0
2) LOOPER: TempVar2 FROM 0 TO CheckTotalHistoricalUnits
3) SETVAR: TempString1 = CheckStringList(4, TempVar2, 0)
4) EXECUTE: ExecSetUnitName(TempVar0, TempString1, 0)
5) END LOOPER
6) END CHECK
7) END LOOPER
I've attached the scenario file. It's event #1.
Many thanks.
RE: Coding Questions
Posted: Thu Mar 31, 2016 4:31 pm
by ernieschwitz
I'm taking a peak, and I will inform you what i think is wrong, here...
RE: Coding Questions
Posted: Thu Mar 31, 2016 4:45 pm
by GaryChildress
Many thanks ernieschwitz! I just started peaking into code this week and some of it seems to make a little sense to me but it's hard to get the hang of. I've been able to figure out a few mistakes on my own but it takes a lot of trial and error. This one I seem to be stuck on. [:o]
RE: Coding Questions
Posted: Thu Mar 31, 2016 4:56 pm
by ernieschwitz
Well... the first problem is that you (apparantly) don't have any historical units in the game. Which makes the first line go from 0 to 0. That means basically 1 check or is that 0 checks... It doesn't really get to the renaming process....
I'd go with the CheckUnitTotal instead of the CheckHistoricalUnitTotal ...
I think at least this is what is wrong.
EDIT: Umm I think I got the order of the Checks command names in some strange order, but you should be able to recognize them.
RE: Coding Questions
Posted: Thu Mar 31, 2016 4:57 pm
by ernieschwitz
What is it exactly you are trying to do anyway? Perhaps there is a better way.

RE: Coding Questions
Posted: Thu Mar 31, 2016 5:02 pm
by ernieschwitz
Is this what you are trying to work on?
tm.asp?m=4054824
RE: Coding Questions
Posted: Thu Mar 31, 2016 5:41 pm
by GaryChildress
Yes. I'm trying to create a code for action cards to create new pre-defined units. Once a unit is created, then I want it to be given a name from a string list. I'm trying to set up a game where only the human player uses action cards to create and/or reinforce units. The AI will use the standard procedure to create and reinforce units as I'm not sure it will handle unit creation action cards very well.
What exactly is a "historical" unit? I was thinking that "historical" referred to pre-placed units on the map. [&:]
RE: Coding Questions
Posted: Thu Mar 31, 2016 5:58 pm
by ernieschwitz
While not being an expert on what historical units are, I can give some examples.
I believe that a unit with TO&E is a historical unit, that an Officer is too a historical unit... but other than that, I am not sure what is.
Why don't you, instead of creating the unit, and then changing the name of the unit, do the reverse...
Decide the name of the unit, and put it directly into the created unit template?
RE: Coding Questions
Posted: Thu Mar 31, 2016 5:59 pm
by ernieschwitz
As for action cards, the AI doesn't play them, unless you program it to do it.
RE: Coding Questions
Posted: Thu Mar 31, 2016 6:07 pm
by GaryChildress
ORIGINAL: ernieschwitz
While not being an expert on what historical units are, I can give some examples.
I believe that a unit with TO&E is a historical unit, that an Officer is too a historical unit... but other than that, I am not sure what is.
Why don't you, instead of creating the unit, and then changing the name of the unit, do the reverse...
Decide the name of the unit, and put it directly into the created unit template?
Hadn't thought of that. I'll give it a try. [:)]
RE: Coding Questions
Posted: Thu Mar 31, 2016 7:05 pm
by icym
This is probably not that helpful, but if you want the units named and numbered, maybe it could be a workaround. Might be workable on a smallish map where you are not creating lots of units via action cards.
Create a New Dawn random game. If you wanted to draw a map from scratch, in settings add the width you want to be to the right side of the map, then delete the hexes from the left side that have the existing map drawn on then. Change the depth if needed. This will give you a blank map to work with.
Design the units you want to place by card, give them a name if you prefer. Then add the same units in the TOE designer, again named how you want.
When you create a new (say) infantry unit via action card, you can click on the change model button and assign it to a TOE template giving you named and consecutively numbered units. Extra clicking though.