How to Count?

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

Moderator: Vic

Post Reply
User avatar
GunnyJarhead
Posts: 27
Joined: Mon Jul 16, 2012 7:31 pm
Contact:

How to Count?

Post by GunnyJarhead »

I am trying to figure out how to count the number of a particular landscape type (or Items or ocations etc...) that a regime owns at the start of there turn.

Added a Regime Slot "Wheat"
Set Each Regime's Slot to Zero

I want to count how many fields a regime owns at the start of its turn and add 1 to the regime slot wheat for each field hex owned

Any Help will be appreciated!



Some people are still alive only because it is illegal to kill them.
User avatar
ernieschwitz
Posts: 4245
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: How to Count?

Post by ernieschwitz »

You want to know how many fields (that is how many of the landscape type fields) is owned?

You need to make a looper, or rather two loopers.

The first looper will go across the board from 0 to mapwidth

The second looper will go down the board from 0 to mapheight

after these you need to set a check for hextype = fields

then a counter (tempvar) that you assign the value +1

end check

end looper

end looper

That is more or less the structure of it.
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
GunnyJarhead
Posts: 27
Joined: Mon Jul 16, 2012 7:31 pm
Contact:

RE: How to Count?

Post by GunnyJarhead »

Ok this is what I have

I can Count just cant add to the regimevariable


0) LOOPER: TempVar0 FROM 0 TO CheckMapWidth
1) LOOPER: TempVar1 FROM 0 TO CheckMapHeight
2) CHECK: CheckLandscapeType(TempVar0, TempVar1) == 3
3) SETVAR: ????????????
5) END CHECK
7) END LOOPER
8) END LOOPER
Some people are still alive only because it is illegal to kill them.
User avatar
ernieschwitz
Posts: 4245
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: How to Count?

Post by ernieschwitz »

I see where you are having trouble...

Do you want it to be the regimevar for the current regime?
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4245
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: How to Count?

Post by ernieschwitz »

If so I imagine you want to add a few lines to your function...

0) SetVar: TempVar2 == CheckTurn
1) LOOPER: TempVar0 FROM 0 TO CheckMapWidth
2) LOOPER: TempVar1 FROM 0 TO CheckMapHeight
3) CHECK: CheckLandscapeType(TempVar0, TempVar1) == 3
4) CHECK: CheckHexOwner(TampVar0, Tempvar1) == TempVar2
5) SETVAR: TempVar3 + 1
6) END CHECK
7) END CHECK
8) END LOOPER
9) END LOOPER
10) SETVAR: TempVar3 + ChechRegimeVar(TempVar2, "WheatVarNr")
11). EXECUTE: ExecSetRegimeVar (TempVar2, "WheatVarNr", TempVar3)

Where "WheatVarNr" is the RegimeVarNr of wheat.
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
GunnyJarhead
Posts: 27
Joined: Mon Jul 16, 2012 7:31 pm
Contact:

RE: How to Count?

Post by GunnyJarhead »

I kept reading what you wrote and was able to come up with the following:

0) LOOPER: TempVar0 FROM 0 TO CheckMapWidth
1) LOOPER: TempVar1 FROM 0 TO CheckMapHeight
2) ' Check Map for LandTyp 10 Forest Loaf
3) CHECK: CheckLandscapeType(TempVar0, TempVar1) == 10
4) ' I think this checks the LandTyp 10 to see if it belongs to Regime 0
5) CHECK: CheckHexOwner(TempVar0, TempVar1) == 0
6) ' Now I want it to add the number of LandTyp 10 that belongs to Regime 0 to the regime variable "Lumber"
7) SETVAR: Peoples Republic_Lumber(#11) + 1
8) END CHECK
9) END CHECK
10) END LOOPER
11) END LOOPER


It did indeed do what I wanted it to do. It counts the Forest or the Lumber or whatever and it displays the count at the start of the regimes turn.

This works for one regime. Is there a way to:

Set it up so that I dont have to type the code for each individual regime?

Also on top of the main screen where it displays the count at the start of the turn for example 100. When a unit takes control of one more field hex the new count is 101. But the display stays at 100.



Thank you for the help!
Some people are still alive only because it is illegal to kill them.
User avatar
GunnyJarhead
Posts: 27
Joined: Mon Jul 16, 2012 7:31 pm
Contact:

RE: How to Count?

Post by GunnyJarhead »

I think we crossed posts.

I think I was pretty close to what you had. I also think that you answered my question about having to type the code for each individual regime with the checkturn function.

Im not sure what your lines 10 and 11 are doing but I will copy and add them to test it out!

Thanks..Im getting closer I do believe
Some people are still alive only because it is illegal to kill them.
User avatar
GunnyJarhead
Posts: 27
Joined: Mon Jul 16, 2012 7:31 pm
Contact:

RE: How to Count?

Post by GunnyJarhead »

Awesome!! Thanks Ernie.

now I just need to figure out how to get it to display at the top correctly. But that is Minor!

Some people are still alive only because it is illegal to kill them.
User avatar
ernieschwitz
Posts: 4245
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: How to Count?

Post by ernieschwitz »

No problem :)
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
Post Reply

Return to “Mods and Scenarios”