icecreamassassin Posted January 29, 2015 Share Posted January 29, 2015 So I have this massive museum mod that is finely tuned and polished and a bunch of addons that make changes to the game and the museum based on other mods (to add displays for new unique items, quest displays, some balancing and duplication issues, etc) but I want to roll it all into one big package so that when you load up my mod, it will detect if a specific mod is loaded, and if so it will enable and disable various references and set up references which work with data from the given mod So I found the entry on the creation kit wiki about the GetFormFromFile() function but I am having a hard time wrapping my head around it. Could anyone give me a pointer or a link to a good guide that would help me get started on this? It'd be much appreciated Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 29, 2015 Share Posted January 29, 2015 I haven't seen any one particular setup across multiple mods. Most are handle differently as each author writes code up differently. However, most do have certain things in common. 1. Code to run to set things up the first time2. Code to run to see if any supported mods have been added or removed3. Code to run depending upon results of 2 #1 is usually an OnInit() event#2 is usually an OnPlayerLoadGame() event#3 is usually a function called upon appropriate conditions within #2 There is an example setup on the CK wiki.http://www.creationkit.com/Complete_Example_Scripts#Maintenance.2Fupdate_code_which_runs_once_per_save_load_and_shows_a_message_when_a_mod_is_updated_or_first_loaded That said, you can look into other mods which do things depending upon other mods installed. Live Another Life is an example of just such a mod. Link to comment Share on other sites More sharing options...
icecreamassassin Posted January 29, 2015 Author Share Posted January 29, 2015 I just kinda started playing around with it and I think I have something put together that may work for what I am doing here. The only issue I am running into is that I can't seem to fill the formID into a property. is there any way I can do that? or am I going to have to set up a script for each activator that is calling for a check and action on forms inside the other file? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 29, 2015 Share Posted January 29, 2015 You want an object from another mod stored as a property on your script? Try this: Your script MiscObject Property SomeObject Auto Hidden ;bunch of other stuff ;some event SomeObject = Game.GetFormFromFile(0x10123456,"SomeOtherMod.esp") as MiscObject ;other stuff Link to comment Share on other sites More sharing options...
icecreamassassin Posted January 29, 2015 Author Share Posted January 29, 2015 (edited) No I mean is there a way to define the form ID AS a property, so I'd do Form WDISPLAY = Game.GetFormFromFile(MyFormID, "AetheriumSwordsnArmor.esp") otherwise it looks like I would have to write the formID into the code itself and thus every single item I reference would need a different script ahhh oblivion days :smile: Ultimately I would like a script that I could use on any weapon display and plug in properties for the formID and the file to look under, but don't see how to if even possible Edited January 29, 2015 by icecreamassassin Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 29, 2015 Share Posted January 29, 2015 (edited) No. GetFormFromFile uses the hex value of the object. I don't think you can pre-store that number in a variable. My theoretical guess on what you might be able to do. NOT TESTED. A second script on your control quest (could be MCM quest if you have one) Form SomeWeapon000 Form SomeWeapon001 ObjectReference Property SomeWeaponDisplay000 Auto ObjectReference Property SomeWeaponDisplay001 Auto Form Function GetMyDisplayObject(ObjectReference Display) If Display == SomeWeaponDisplay000 Return SomeWeapon000 ElseIf Display == SomeWeaponDisplay001 Return SomeWeapon001 EndIf EndFunction Event OnInit() Maint() EndEvent Function Maint() If Game.GetFormFromFile(0x10123456,"SomeArmorWeaponPack.esp") Debug.Trace("SomeArmorWeaponPack.esp located") SomeWeapon000 = Game.GetFormFromFile(0x10123456,"SomeArmorWeaponPack.esp") SomeWeapon001 = Game.GetFormFromFile(0x10123457,"SomeArmorWeaponPack.esp") Else Debug.Trace("SomeArmorWeaponPack.esp not located. Please ignore errors about missing file") EndIf EndFunction On your display script ControlQuestSecondScript Property CQS Auto Actor Property PlayerRef Auto Form MyItem Event OnActivate(ObjectReference akActionRef) MyItem = CQS.GetMyDisplayObject(Self as ObjectReference) If akActionRef == PlayerRef If PlayerRef.GetItemCount(MyItem) > 0 ;other stuff EndIf EndIf EndEvent Edited January 29, 2015 by IsharaMeradin Link to comment Share on other sites More sharing options...
icecreamassassin Posted January 30, 2015 Author Share Posted January 30, 2015 as always you are a scripting genius :) managed to get it working. just have to tweak a few things because my Don't have the right item message isn't triggering, but other than that, it's working perfectly! Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 30, 2015 Share Posted January 30, 2015 You mean it worked? It actually worked?! Cool! I need to keep this in mind for use later if I ever need it. Link to comment Share on other sites More sharing options...
icecreamassassin Posted February 1, 2015 Author Share Posted February 1, 2015 yeah it's working pretty sharp. I have all the individual displays all set up. I had to alter the code a little because you can't activate an object that is currently disabled, so this line: MyItem = CQS.GetMyDisplayObject(Self es ObjectReference) has to be changed to: MyItem = ControlScript.GetMyDisplayObject(GetLinkedRef() as ObjectReference) and I basically have invisible activators set up linked to the disabled display item and it works just great. Only issue I have is that I can't seem to get a message to show when the conditional fails to find the item in your inventory, but that's a little thing. The more important thing I am now trying to figure out is how to tie it all into a single activator like I have for the rest of the displays. Everything else in the museum which is built into the mod or vanilla works off of paired display and item formlists (if you recall), but for GetFormFromFile, it really can't work that way can it? Can I perhaps set up an AddForm to add the referenced form items to a blank leveled list? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 1, 2015 Share Posted February 1, 2015 You can take the forms that you obtain with GetFormFromFile and do whatever you want with them. I have a script where 3/4 of it is nothing but a laundry list of calls to a custom function where I pass in a GetFormFromFile call along with other information so that I can add the forms to specific formlists so that I can pre-fill formlists used to transfer items into and out of specific containers without requiring that the player manually add the items to be registered to the list (tho they can for any item not accounted for from other mods). So I see no reason why you couldn't put the forms you obtain into a list of some sort. An example from the script I mentioned: A list of items from Dawnguard ;alchemy AddToList(PPScript.ItemList004,Game.GetFormFromFile(0x000059ba, "Dawnguard.esm")) ;Ancestor Moth Wing AddToList(PPScript.ItemList004,Game.GetFormFromFile(0x000183b7, "Dawnguard.esm")) ;Chaurus Hunter Antennae AddToList(PPScript.ItemList004,Game.GetFormFromFile(0x0000b097, "Dawnguard.esm")) ;Gleamblossom AddToList(PPScript.ItemList004,Game.GetFormFromFile(0x000185fb, "Dawnguard.esm")) ;Poison Bloom AddToList(PPScript.ItemList004,Game.GetFormFromFile(0x00002a78, "Dawnguard.esm")) ;Yellow Mountain Flower ;smithing - temper AddToList(PPScript.ItemList001,Game.GetFormFromFile(0x000195aa, "Dawnguard.esm")) ;Shellbug Chitin AddToList(PPScript.ItemList001,Game.GetFormFromFile(0x0003ad60, "Skyrim.esm")) ;Void Salts AddToList(PPScript.ItemList001,Game.GetFormFromFile(0x0003ad5f, "Skyrim.esm")) ;Frost Salts AddToList(PPScript.ItemList001,Game.GetFormFromFile(0x0003ad5e, "Skyrim.esm")) ;Fire Salts ;smithing - forge AddToList(PPScript.ItemList001,Game.GetFormFromFile(0x00002993, "Dawnguard.esm")) ;Bone Hawk Skull AddToList(PPScript.ItemList001,Game.GetFormFromFile(0x00002994, "Dawnguard.esm")) ;Bone Hawk Feathers AddToList(PPScript.ItemList001,Game.GetFormFromFile(0x00011cf7, "Dawnguard.esm")) ;Bone Hawk Claw ;tanning AddToList(PPScript.ItemList007,Game.GetFormFromFile(0x0001199a, "Dawnguard.esm")) ;Vale Sabre Cat Hide AddToList(PPScript.ItemList007,Game.GetFormFromFile(0x00011999, "Dawnguard.esm")) ;Vale Deer Hide And the function being called Function AddToList(FormList TheList, Form TheItem) If !(TheList.HasForm(TheItem)) TheList.AddForm(TheItem) Debug.TraceUser("InventoryManagementSystem","Added "+TheItem.GetName()+" to list ["+TheList+"]") Else Debug.TraceUser("InventoryManagementSystem",TheItem.GetName()+" is already on list ["+TheList+"]") EndIf EndFunction Link to comment Share on other sites More sharing options...
Recommended Posts