[ques] How to change existing platform data

Hi, I’m pretty new here and I have researched enough to make a working mod that adds new platforms/consoles to the game, but I’d like to also edit the existing ones without editing the core files of the game. To that end my researched came up with this from the Advanced Modding part of the Modding API’s wiki:

var originalMethod = GDT.foo;
var bar = function(){
    //add your custom code
    originalMethod();//if appropriate, call the original logic
};

GDT.foo = bar;//assign your custom method over the original.

The problem is that I have no prior experience in java scripting and my attempts at trial-and-error have been fruitless. My searches for more explanations on this have equally been in vain.

In short, how do I use that code to modify the stats of an existing platform/console?

Any help would be greatly appreciated.

Eric.

The technique you refer to described under advanced modding is used to change or amend the behavior of an existing method. What you are trying to do is to change the data (configuration) of an object.

To do this you can simply override specific data with what you want.

Example

//enumerate through existing platforms
for (var i=0;i<Platforms.allPlatforms.length;i++){
	var platform = Platforms.allPlatforms[i];
	//find target by id
	if (platform.id == 'G64'){
		//change data
		platform.licencePrize = 10000;
	}
}
  1. enumerate platforms
  2. find target by id (do not search by name, otherwise your code will not work with translated versions of the game)
  3. change data

You will need to look at the original code to see what id and what data to change.

2 Likes

Hi, thanks for your reply however I can’t seem to make it work. Here is what I placed in my script just to test it:

for (var i=0;i<Platforms.allPlatforms.length;i++){
	var platform = Platforms.allPlatforms[i];

	if (platform.id == 'PC'){
		platform.licencePrize = 10000;
		platform.developmentCosts: 20000;
	}
}

When going in game there is actually no change to the default values of the PC, it’s still free to start making games for it and development costs are still 5000 per game.

Thanks for any help.

Eric.

There is an error in your syntax.

This:

platform.developmentCosts: 20000;

Should be:

platform.developmentCosts = 20000;

Otherwise the rest looks good :smile:

I suggest using an IDE to help with development. VisualStudio and Aptana are some good free IDE’s that support javascript.

3 Likes

you might also want to read through the debugging section on the wiki.

1 Like

Sorry about that… It confuses me how syntax in the main files is different from the syntax in the mod script. For example in the main files you have " " but in the mod it’s ’ ’

Anyways, my problem has been solved, thank you both for your help.

Now I will do some more research on other subjects, like the possibility of adding categories (I feel some are not well represented in the generalization used) and if it’s possible to include the manufacturer name in the platform choice window… example:

Govodore
G64
Dev. cost: 5K
Marketshare: 58.6%

Genre match: unknown

If either are impossible to do with mods, please feel free to stop me now ^.^;

Eric.

Hi again,

Does this work with events as well? I haven’t been able to make it work with either the original hijack method I first mentioned or with this new method because I have no idea what the terms would be.

Thanks

Eric.