question about globalvars

Posted by littleone90 
question about globalvars
Date: July 03, 2013 02:12AM
Posted by: littleone90
hello to all
I wanted to know if using the globalvars.ini or something else, was possible to implement the possibility to choose the pilot of a team for all races, for example, in 2009 mod, the choice between massa badoer and fisichella for the entire season, and not whit massa from australia to hungay, badoer for valencia and spa, and fisichella for the other races.
I hope I explained myself
thanks in advance


Re: question about globalvars
Date: July 04, 2013 01:48AM
Posted by: TomMK
Yes it is possible. GlobarVars.ini is where you would control this from, but it is not the only file you need to edit. The things in a mod that "create" a driver are:

1) Their helmet texture in the Data\Helmets folder
2) The driver's TeamArt picture in Data\TeamArt\Drivers folder
3) Their name and performance numbers in the performance file (location of this file depends on the mod author).

So we need to make CSM aware that we want a different driver helmet texture, teamart picture and performance file depending on whether we choose Massa, Badoer or Fisichella. The helmet and teamart parts are easy, the performance file part is more complicated, so let's start with the easy ones first :)

Driver helmet and teamart

In GlobalVars.ini there is a section called [Vars]. In this section you will find some variables called driver01, driver02, driver03, ... etc etc. These variables tell CSM what filename / folder to look for when loading files for that driver from Data\Helmets and Data\TeamArt\Drivers. In your example (2009 Ferrari driver), we want to edit the driver03 variable because that is Massa's car that year.

For example, if driver03 = massa then CSM will load helmets from Data\Helmets\massa\ and teamart from Data\TeamArt\massa.gpi

But if we change driver03 = badoer then CSM will load helmets from Data\Helmets\badoer\ and teamart from Data\TeamArt\badoer.gpi

And finally if driver03 = fisichella then CSM will load helmets from Data\Helmets\fisichella\ and teamart from Data\TeamArt\fisichella.gpi

Still understanding? ;) Note: you need to put these files (helmet tex and teamart gpi) in the above folders so CSM can find them.

But we don't want to edit GlobalVars.ini every time to change driver03, right? Of course not!...

CSM allows you to change the variables in GlobalVars.ini from the CSM menu. To do this, add this to the end of your GlobalVars.ini:

[driver03]
AllowChange		=1
Name			=Ferrari driver?
VarCount		=3
Var1			=massa
Var2			=badoer
Var3			=fisichella

So let's look at this line-by-line to see what it does:

[driver03] <-- this line tells CSM: "Hey CSM, I want to change the value of the variable named between the [ ] brackets". In this case we're changing the value of driver03.

Allowchange = 1 <-- this line tells CSM to make the choice appear in CSM "The mod's configurables" section.

Name = Ferrari driver? <-- this is the text that will appear in the CSM menu

VarCount = 3 <-- how many different values are we going to get the choice of?

Var1 = massa <-- choice 1
Var2 = badoer <-- choice 2
Var3 = fisichella <-- choice 3

When you make a choice in the menu, CSM will update driver03 in the [Vars] section accordingly. Try it out!

I'll do another post to explain how to change the performance files when I get back from work (this took a bit longer than I thought it would!!).

=====================================================


Intel NUC 8i3, 8GB RAM, MS Sidewinder Wheel
Re: question about globalvars
Date: July 04, 2013 10:41AM
Posted by: littleone90
Wow! that was a great explanation! thank you very much! waiting for the explanation for changing performance =D


Re: question about globalvars
Date: July 04, 2013 01:20PM
Posted by: TomMK
So swapping performance files is harder to explain because the author can place the file in different places, and it can be done many different ways, so it's not the same in all cases. Anyway, let's look at a generic example:

Performance files are loaded by GPxPatch, specifically GPxSet. You will find the location of your mod's performance file in Data\GPxPatch\gpxset.ini under the [PerfManager] section:

[PerfManager]
Enable =1
Path =gpxpdata\performance.txt

The above example is taken from the 2013 Mod by GP4 Central (soon to be released!) (shameless plug!). It shows the performance file is in the gpxdata folder (which is in the GP4 game folder). You need to check your mod for the exact location of your performance file.

Create 3 different performance files, one with Massa as driver 3, one with Badoer and one with Fisichella. Set their performance (Badoer's grip value should be about 12000 hot). Name them as follows and put them in your GPxPatch folder (or wherever your mod puts them).

Data\GPxPatch\performance_massa.txt
Data\GPxPatch\performance_badoer.txt
Data\GPxPatch\performance_fisichella.txt

When CSM loads the mod, we want to supply GPxPatch with one of the three performance files above, and it must be renamed to performance.txt because that is what GPxPatch is expecting (look again at the code above under [PerfManager]). To do this we're going to use a built-in function of CSM called swapping. Swapping is like copying; you specify a source file or folder, and then the destination you would like the file or folder swapped, or copied, to. Swapping is controlled by the Settings\Swap.ini file:

[Swapfiles]
File1 =GPxPatch\performance_%driver03%.txt,gpxdata\performance.txt

This looks complicated but it's actually quite easy. What we are saying to CSM is "Hey CSM, swap the file before the comma from my mod into the location I've put after the comma". But, what does that ugly bit with the percent signs mean??? Percent signs tell CSM we are referring to a variable. So CSM sees %driver03% and it knows you mean "the variable called driver03". So CSM goes off to the GlobalVars.ini file, finds the value for driver03, and substitutes the value into this line of text, so we get:

if driver03 = massa:
[Swapfiles]
File1 =GPxPatch\performance_massa.txt,gpxdata\performance.txt

if driver03 = badoer:
[Swapfiles]
File1 =GPxPatch\performance_badoer.txt,gpxdata\performance.txt

if driver03 = fisichella:
[Swapfiles]
File1 =GPxPatch\performance_fisichella.txt,gpxdata\performance.txt

Notice how the destination (the bit after the comma) is always the same - swapping can also be used to rename the file when it is swapped. In this example, whichever of your 3 performance files we choose to swap, it will always be renamed to performance.txt. This way, GPxPatch is always able to find it.

Hopefully it makes a bit more sense now. (Y)

=====================================================


Intel NUC 8i3, 8GB RAM, MS Sidewinder Wheel
Re: question about globalvars
Date: July 04, 2013 02:18PM
Posted by: nicki87
Thanks a lot for the explanation Tom :) I'm wondering if you may include that into a broader tutorial on how to make a CSM mod or compile it, it would be helpful for all of us being quite newbie on GP4 modding :)
Re: question about globalvars
Date: July 05, 2013 01:22AM
Posted by: littleone90
wow, it works perfect! thank you very much! a wonderful explanation! ;)


Re: question about globalvars
Date: July 05, 2013 02:59AM
Posted by: TomMK
Quote
nicki87
Thanks a lot for the explanation Tom :) I'm wondering if you may include that into a broader tutorial on how to make a CSM mod or compile it, it would be helpful for all of us being quite newbie on GP4 modding :)

Yeh I've been meaning to write a guide for ages but keep finding excuses not to do it. Maybe after I've published the 2013 Mod I'll get round to it.

Quote
littleone90
wow, it works perfect! thank you very much! a wonderful explanation!

Glad it helped!

=====================================================


Intel NUC 8i3, 8GB RAM, MS Sidewinder Wheel
Sorry, only registered users may post in this forum.

Click here to login

Maintainer: mortal, stephan | Design: stephan, Lo2k | Moderatoren: mortal, TomMK, Noog, stephan | Downloads: Lo2k | Supported by: Atlassian Experts Berlin | Forum Rules | Policy