Jump to content

Ini files for mods


Recommended Posts

I've been working on a mod which changes the values of armor when it is equipped.

 

I'd like to provide an ini file to allow players to make changes in the mods parameters for the game.

 

I tried to do this for a few hours and could not seem to make the ini and scrips communicate.

 

Does anyone have some advice on how to get the scrips and ini files to communicate?

 

Appreciate your wisdom here.

Link to comment
Share on other sites

You need to use OBSE with the RunBatchScript command to read in the ini file. Basically all an ini file does for Oblivion is to set a bunch of variables in a quest script.

 

So your ini file would look like this:

 

Set ObXPSettings.attributePointsPerLevel 	to 13
Set ObXPSettings.skillPointsPerLevel 		to 48

 

That's just a sample. Then your main script would load that in:

 

	;run batch ini settings script
	if ( fileExists "Data\ini\Oblivion XP Settings.ini" == 1 )
		runBatchScript "Data\ini\Oblivion XP Settings.ini"
	else
		let tempString := mqGetMenuGlobalStringValue "Obxp\_iniMissing"
		messageBoxEx "%z" tempString
		return
	endif

 

You need to put that in an "if ( GetGameLoaded )" block so that it's only run when the game is loaded or reloaded.

 

The ObXPSettings that you saw in the ini file is the name of the quest that has the script with all those variables in it. Then whenever you need one of those variables elsewhere in your mod, you would reference them using the same dot notation.

 

You'll probably need to read up on the OBSE documentation if you're not familiar with OBSE.

 

Pluggy can also read ini files, but Pluggy is an OBSE plugin, so you might be better just sticking with OBSE. If you use Pluggy, then players will have to load that up too.

 

Edit: Ignore the mqGetMenuGlobalStringValue command. I'm using MenuQue to make translation of my mod easier. Just set the tempString to the error message you want to display if the ini file isn't found.

Edited by AndalayBay
Link to comment
Share on other sites

To expand on what AndalayBay said:

 

With OBSE and runBatchScript you are technically NOT creating an ini file using the common definition of an ini file. What you are creating and running

is a batch script file that can be executed. As AndalayBay's example illustrates you are loading a file and then executing it as if you had done something

like "bat my_console_commands.txt".

 

See here.

 

The OBSE Plugin called Pluggy does, however, have a fully featured ini file implementation that allows you to create a file of sectioned name-value pairs

that can be read into your script and/or written back to the ini file.

 

See here.

 

So it depends greatly on what implementation you need.You can also make a pseudo implementation using just OBSE by implementing your settings as

a quest, as AndalayBay has done above, and using runBatchScript to populate the quest's variables on demand.

Edited by Astymma
Link to comment
Share on other sites

Thanks a bunch Astymma and Andalaybay,

 

Sounds like I may have been mixing the pluggy and OBSE ini implications that I was studying in various scrips.

 

I'll give this a try and let you know how it goes.

Link to comment
Share on other sites

There is another big restriction to runBatchScript: you cannot use full OBSE fuctionality. So you cannot set array elements, which makes it pretty cumbersome to pre-set like a list of string elements.
Link to comment
Share on other sites

RunBatchScript only replicates what you can do in the console. If you can type the command in the console, you can put it in a RunBatchScript. That's all it does.

 

Pluggy is a great tool, but a lot of players can't run it. Unfortunately I must include myself in those ranks. It crashes my game every time.

Link to comment
Share on other sites

You may want to explicitly state what it is you're doing that might require Pluggy. Myself, and I'm sure AndalayBay and Fore, have experience working with OBSE runBatchScript solutions to problems specifically tailored to eliminate the Pluggy requirement since it IS quite installation dependent and many users cannot seem to get it to function no matter what they try. Perhaps we can find an alternative that is OBSE reliant only? Edited by Astymma
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...