• Welcome to Freedom Reborn Archive.
 

localinit.py

Started by Mystik, October 07, 2007, 11:27:21 PM

Previous topic - Next topic

Mystik

would it be possible to create changes to the localinit.py file , but only have the changes affect one of my mods on my pc. or would it be possible to create a localinit file that was in my mod folder?

stumpy

A localinit.py file placed in the mod's scripts folder will not be automatically loaded. I am pretty sure the game only looks for that file in the \System folder.


Really, depending on what you want to do, most mod-specific calls should go in the mod's mission.py files themselves or in separate python files in the mod's scripts folder that you load from the mission.py files for each of the mod's missions. In other words, if you want to change the max zoom value to 6000 (or other localinit.py-type thing), you should create a file called, for example, modinit.py in the mod's \Missions\Scripts folder that looks like
# Mod-specific initialization calls

import ff

ff.CAM_MAX_ZOOM=6000


And then have a line that imports that module in your mission.py files for each of the missions, like import modinit. (Obviously, for such a simple, one-line thing, it would be just as easy just to call ff.CAM_MAX_ZOOM=6000 from mission.py directly. But, if you were doing something substantial, creating a python file that you import is the way to go.)


The localinit.py is supposed to be used to make changes that all mods will see and which will be made before anything else mod-specific is loaded (like that mod's cshelper or ffx files). If you make changes to \System\localinit.py, your mod will be tougher to distribute because normally mods only make changes in their mod folders (plus a shortcut somewhere to start the mod).

If you are just trying to make a change that gets loaded for every mission and you don't care that it gets loaded before other modules do, then you can put the change in the mod's cshelper.py file. At least for FFX3.2+ enabled mods, the mod loads the cshelper from it's own mod folder (not the one in the Data mod) so that you cann make changes to that which will only affect your mod.


If you absolutely have to make changes to localinit.py, then adding lines something like the following to the bottom of localinit.py will allow for mod-specific calls to be made from within it.
import os.path
import sys
mod = 'zffx3'   # <---- put your mod name (as it appears in the shortcut) here
if mod in map(lambda p: os.path.basename(os.path.dirname(os.path.dirname(p))),sys.path):
    print 'loading mod-specific system/localinit.py calls for mod <%s>' % mod
    # put your mod-specific calls here



Hope that helps.

Epimethee

Quote from: stumpy on October 08, 2007, 01:11:49 AMIf you absolutely have to make changes to localinit.py, then adding lines something like the following to the bottom of localinit.py will allow for mod-specific calls to be made from within it.
If you REALLY need to do that, though, instead of writing directly to localinit.py, it would be better to create a startup plugin. Cf. the \statupplugins folder for examples.

Mystik

well I made changes to built in attributes like heatsensitive and myoptic so what would be the best way to include the changes in my mod without affect other mods when i release it.

stumpy

Épiméthée is right. I initially dismissed the the startup plug-ins approach because those plug-ins are not mod-specific. But, you can put the code I wrote for localinit.py into a startup plug-in to make that plug-in mod specific.

But, the issue with installers and so on persists.

Quote from: Thor Reborn on October 08, 2007, 09:42:03 AMwell I made changes to built in attributes like heatsensitive and myoptic so what would be the best way to include the changes in my mod without affect other mods when i release it.

You made changes to the built-in attributes? Do you mean that you removed them from the Attributes tab in FFEdit and added scripted versions with different internal names (but possibly the same string names)? Or, do you mean you changed one of the ff variables that affects how the game uses those attributes? In either case, those are changes that should be made in ffx.py or to an FFX plug-in (preferably). You include those files with your release of the mod, so your mod will not affect other mods when you release it.

There is no need to make changes to localinit.py for your mod to have its own versions of scripted attributes (or scripted variations on built-in attributes).

Mystik

i'm changing the variables, for example changing the damage multiplier for heatsensitive

stumpy

Just do that with an FFX plug-in. It will run as FFX is loaded and make the changes you want to those variables.

PS: I am assuming you mean heat sensitive, as the built-in attribute with two words. I thought that just lowered the character's resistance for fire damage by one on the VERY RESISTANT - RESISTANT - NORMAL - VULNERABLE - DEFENSELESS scale. I didn't know that you could change the damage multiplier or that scale for just one damage type. What's the variable that does that?

Mystik

sorry I typed the wrong thing I meant the RPG_VULN_MULTIPLIER
am i making more sense? I'm not home right so i dont have my init.py statements that i altered

stumpy

Okay, those are the ones that I know about. But, won't changing those values change the damage inflicted on anyone with an attack type weakness, regardless of which attribute gives it to them?

Mystik

so how would i make these lines from my file into a ffx plugin?

RPG_MYOPIC_ACCURACY   1.0
RPG_MYOPIC_SPEED_PENALTY   -2.0



how do I find all the init py statements, because back when  I  had furys big list I think i was able the to change which vuln multiplier  was called for the attribute


stumpy

Quote from: Thor Reborn on October 09, 2007, 08:24:06 PMso how would i make these lines from my file into a ffx plugin?

RPG_MYOPIC_ACCURACY   1.0
RPG_MYOPIC_SPEED_PENALTY   -2.0

In your mod's scripts folder, open the ffxplugins\active folder and create a subfolder named (for instance) newmyopic. Then in that folder, create a python file called (again, for instance) newmyopic.py that has the following code
import ff
# Change the way the built-in MYOPIC attribute works
ff.RPG_MYOPIC_ACCURACY = 1.0
ff.RPG_MYOPIC_SPEED_PENALTY = -2.0

I think that's it. Others have more practice at this than I do, but I think it's that straightforward. FFX will take care of loading that code every time it loads.

Quote from: Thor Reborn on October 09, 2007, 08:24:06 PMhow do I find all the init py statements, because back when  I  had furys big list I think i was able the to change which vuln multiplier  was called for the attribute

I didn't save fury's list, but I posted an equivalent list and some code on how to generate the list on your own. Take a look at this post for the list (and the one further down to generate your own list).