Question about tempstrings?

Discuss and post your mods and scenarios here for others to download.

Moderator: Vic

Post Reply
Grymme
Posts: 1776
Joined: Sun Dec 16, 2007 5:06 pm
Contact:

Question about tempstrings?

Post by Grymme »

Is it possible to embedd a tempstring into an unit name

For example

I want a player to be able to create a certain unit and i want each unit created to have a successive number so that the first time the card is played the unit is called 1st division HQ the second time 2nd division HQ and so on.

Does anyone know if this is possible?
My Advanced Tactics Mod page
http://atgscenarios.wordpress.com

30+ scenarios, maps and mods for AT and AT:G
spidey007
Posts: 13
Joined: Sun Jun 26, 2011 9:19 pm

RE: Question about tempstrings?

Post by spidey007 »

Yes I do in the formation mod I'm working on.
Here is the script I use to add a unit via a card.
0) SETVAR: TempVar10 = CheckTurn
1) EXECUTE: ExecAddUnit(TempVar0, TempVar2, TempVar3, TempVar10)
2) SETVAR: TempVar11 = CheckTotalUnits
3) SETVAR: TempVar12 = CheckRegimePeople(TempVar10)
4) EXECUTE: ExecUnitPeopleModify(TempVar11, 0, TempVar12, TempVar12)
5) SETVAR: TempVar100 = CheckRegimeVar(TempVar10, 20)
6) SETVAR: TempVar100 + 1
7) EXECUTE: ExecSetRegimeVar(TempVar10, 20, TempVar100)
8) SETVAR: TempString10 = TempVar100
9) SETVAR: TempString10 + 'th Division'
10) EXECUTE: ExecSetUnitName(TempVar11, TempString10, TempString10)

Let me know if you have any questions.

Spidey
Grymme
Posts: 1776
Joined: Sun Dec 16, 2007 5:06 pm
Contact:

RE: Question about tempstrings?

Post by Grymme »

Many thanks, that did the trick. But i removet the "th" from the string since you will be in trouble with 2nd, 3rd and so on divisions.

You seem to have a talent for coding. I am terrible at it, what i know have been learned from horribly tedious trial and error.
My Advanced Tactics Mod page
http://atgscenarios.wordpress.com

30+ scenarios, maps and mods for AT and AT:G
spidey007
Posts: 13
Joined: Sun Jun 26, 2011 9:19 pm

RE: Question about tempstrings?

Post by spidey007 »

I always start at a higher number since there are already units starting on the map so the th is less a problem for me. Glad it worked for you. If you need any other help coding always glad to help.

Spidey

Realized "th" would still be an issue on higher numbers (wasn't thinking it thru) so here is code to fix that if you want.


0) SETVAR: TempVar10 = CheckTurn
1) EXECUTE: ExecAddUnit(TempVar0, TempVar2, TempVar3, TempVar10)
2) SETVAR: TempVar11 = CheckTotalUnits
3) SETVAR: TempVar12 = CheckRegimePeople(TempVar10)
4) EXECUTE: ExecUnitPeopleModify(TempVar11, 0, TempVar12, TempVar12)
5) SETVAR: TempVar100 = CheckRegimeVar(TempVar10, 20)
6) SETVAR: TempVar100 + 1
7) EXECUTE: ExecSetRegimeVar(TempVar10, 20, TempVar100)
8) SETVAR: TempString10 = TempVar100
9) SETVAR: TempVar13 = TempVar100
10) SETVAR: TempVar13 / 10
11) SETVAR: TempVar13 * 10
12) SETVAR: TempVar14 = TempVar100
13) SETVAR: TempVar14 - TempVar13
14) CHECK: TempVar14 == 0
15) SETVAR: TempString11 = 'th Division'
16) END CHECK
17) CHECK: TempVar14 == 1
18) SETVAR: TempString11 = 'st Division'
19) END CHECK
20) CHECK: TempVar14 == 2
21) SETVAR: TempString11 = 'nd Division'
22) END CHECK
23) CHECK: TempVar14 == 3
24) SETVAR: TempString11 = 'rd Division'
25) END CHECK
26) CHECK: TempVar14 > 3
27) SETVAR: TempString11 = 'th Division'
28) END CHECK
29) CHECK: TempVar100 < 21
30) CHECK: TempVar100 > 3
31) SETVAR: TempString11 = 'th Division'
32) END CHECK
33) END CHECK
34) SETVAR: TempString10 + TempString11
35) EXECUTE: ExecSetUnitName(TempVar11, TempString10, TempString10)


Added code to take care of teens as well so comes out 11th not 11st worked fine on my tests and should be good not matter home many units you create now.
Post Reply

Return to “Mods and Scenarios”