Cyborgking Posted June 28, 2013 Share Posted June 28, 2013 Hello everyone, I am working on a mod that will have some optional things included. All these optional things add or change a small part of the same script. Now the problem is that an extra plugin will replace the script that the base plugin has as a whole and not just a small part. This isn't very handy for when there are multiple optional things that have to be able to run at the same time, you'd have to make a plugin for every combination. So what's the best way to implement these optional things? Isolate parts of the script in the base plugin? Link to comment Share on other sites More sharing options...
jazzisparis Posted June 28, 2013 Share Posted June 28, 2013 Could you elaborate, please? What does this mod do?It may be possible to use a single plugin with a single script. Link to comment Share on other sites More sharing options...
SpectralDragon Posted June 28, 2013 Share Posted June 28, 2013 If I am reading this right you want to have multiple plugins for a mod that modify the same script for different purposes. This isn't a good idea, as whichever plugin at the bottom of the load order will overwrite any and all changes from the plugins above it in the load order. I can think of two stable ways to handle this: 1) Use a unique script for each plugin instead, each performing the necessary task.2) You may be able to use a single script for each plugin, but the script will need to be the same for each plugin, only utilizing different parts of the script each. Not sure how this would work. Link to comment Share on other sites More sharing options...
luthienanarion Posted June 28, 2013 Share Posted June 28, 2013 Jazz is spot-on here. NVSE is magic. Link to comment Share on other sites More sharing options...
Cyborgking Posted June 28, 2013 Author Share Posted June 28, 2013 Could you elaborate, please? What does this mod do?It may be possible to use a single plugin with a single script. I am working on a crosshair mod that, for example, should have an extra plugin for the gun runners arsenal DLC ammo or one for a perks mod. The extra plugin adds something to the main script that is also in the base plugin. I guess what would work is create a seperate script for every extra plugin in the base plugin. In the base plugin all those seperate scripts will include a function that the "main script" refers to that returns a constant value like 1. In the extra plugins those seperate scripts get modified to serve their purpose, leaving the main script unchanged. This is also what SpectralDragon has in mind? Link to comment Share on other sites More sharing options...
jazzisparis Posted June 28, 2013 Share Posted June 28, 2013 I'm sorry, but that's still a little vague. What, exactly, are you doing with the crosshair? Link to comment Share on other sites More sharing options...
Gribbleshnibit8 Posted June 29, 2013 Share Posted June 29, 2013 Why not use a more robust system for your detection. If you're just detecting what ammo is being used and working from that, then it would be fine to use form lists that hold the ammo. All the lists and their modifiers can be in the main script, and the plugins just add items to the lists, when the item is detected in a list, a conditional check determines what should be done. See Project Nevada for pretty much every possible way to implement that. Link to comment Share on other sites More sharing options...
Cyborgking Posted June 29, 2013 Author Share Posted June 29, 2013 Why not use a more robust system for your detection. If you're just detecting what ammo is being used and working from that, then it would be fine to use form lists that hold the ammo. All the lists and their modifiers can be in the main script, and the plugins just add items to the lists, when the item is detected in a list, a conditional check determines what should be done. See Project Nevada for pretty much every possible way to implement that.I guess this will also work for perks? So when I make the plugin, I load all the plugins that the script could do something with, like GRA DLC, make the script refer to lists of ammo or perks of those plugins, compile the sciprt, and then the plugin would run fine both with and without those other plugins loaded? Link to comment Share on other sites More sharing options...
jazzisparis Posted June 29, 2013 Share Posted June 29, 2013 and then the plugin would run fine both with and without those other plugins loaded?No, that would cause the game to crash if one of the files is missing. You can use form lists for both ammo and perks. Clever use of the NVSE function BuildRef can spare you of the need to make separate plugins for every DLC/mod.For example, suppose you want to add the .45 ACP ammo types to your ammo list, without requiring HH as a master, you can use this code (in a quest script): short iIndex ref rObject begin GameMode if GetGameRestarted set iIndex to GetModIndex "HonestHearts.esm" if iIndex < 255 set rObject to BuildRef iIndex 38011 ; Decimal FormID of .45 Auto ListAddForm YourAmmoList rObject set rObject to BuildRef iIndex 40554 ; Decimal FormID of .45 Hollow Point ListAddForm YourAmmoList rObject set rObject to BuildRef iIndex 40555 ; +P ListAddForm YourAmmoList rObject set rObject to BuildRef iIndex 40556 ; Hand-Load ListAddForm YourAmmoList rObject endif ; (...) endif end Link to comment Share on other sites More sharing options...
Cyborgking Posted June 29, 2013 Author Share Posted June 29, 2013 (edited) and then the plugin would run fine both with and without those other plugins loaded?No, that would cause the game to crash if one of the files is missing. You can use form lists for both ammo and perks. Clever use of the NVSE function BuildRef can spare you of the need to make separate plugins for every DLC/mod.For example, suppose you want to add the .45 ACP ammo types to your ammo list, without requiring HH as a master, you can use this code (in a quest script): short iIndex ref rObject begin GameMode if GetGameRestarted set iIndex to GetModIndex "HonestHearts.esm" if iIndex < 255 set rObject to BuildRef iIndex 38011 ; Decimal FormID of .45 Auto ListAddForm YourAmmoList rObject set rObject to BuildRef iIndex 40554 ; Decimal FormID of .45 Hollow Point ListAddForm YourAmmoList rObject set rObject to BuildRef iIndex 40555 ; +P ListAddForm YourAmmoList rObject set rObject to BuildRef iIndex 40556 ; Hand-Load ListAddForm YourAmmoList rObject endif ; (...) endif end That's a nice way for the ammo but I won't be able to do perks this way. I'll try to clear up a bit what I am doing:With ShadauxCat's permission, I am working on a port of his dynamic crosshair: http://fallout3.nexusmods.com/mods/15724/?tab=1&navtag=%2Fajax%2Fmoddescription%2F%3Fid%3D15724%26preview%3D&pUp=1 The crosshair scaling is handled through one script that keeps perks in mind, consumables, limbs, ammo and other factors. Now a mod could add some new perks that effect a players spread on certain conditions or always. The problem is that for every new perk I'd have to add some code to the dynamic crosshair script so that that perk is kept in mind. The piece of code could be something simple like this: if Player.hasPerk Someperk == 1 set PerkBonus to PerkBonus * 1.2 endif Or something like this: if Player.hasPerk Someperk2 == 1 if player.IsMoving set PerkBonus to PerkBonus * 0.8 else set PerkBonus to PerkBonus * 1.2 endif endif Thanks everyone for helping me btw. Edited June 29, 2013 by Cyborgking Link to comment Share on other sites More sharing options...
Recommended Posts