DdsLedg Posted December 24, 2021 Share Posted December 24, 2021 (edited) EDIT: FIXED Hi, I am creating a Hearthfire build your own home style house for my mod, Midwood Isle. The house works great, however I have run into a problem regarding checking if a room is complete (so that the option to pay to decorate it disappears).I currently have it set up so that when the misc object is created at a workbench, it enables the reference in the room and runs the Function CheckCompletionStatus()This function is setup like this (the example being the library room): if Game.GetPlayer().GetItemCount(MI_CheckLibraryList) == MI_CheckLibraryList.GetSize()MI_LibraryCompleted.SetValue(1)endifThe MI_CheckLibraryList is a formlist of all the Misc objects that can be created in the library - currently 35 objects. However, this seems to be very inconsistent.For some of the rooms, it sets the global when I have created like half the objects, and for some it never sets the global once all are created.Additionally, I tried changing it to be == 35, however this also doesnt work. The weird part is when I set it to == 5, sometimes it works and sometimes it doesn't.I was wondering if anyone knew of a problem with using formlists for GetItemCount or GetSize? After banging my head against a wall I tried coming up with a different approach (a bit messy):MI_LibraryIncomplete.SetValue(0)int iCurrentArrayIndex = 0while iCurrentArrayIndex < DecorationsLibrary.lengthif DecorationsLibrary[iCurrentArrayIndex].IsDisabled()MI_LibraryIncomplete.SetValue(1)endifiCurrentArrayIndex = iCurrentArrayIndex + 1endWhileif MI_LibraryIncomplete.GetValue() == 0MI_LibraryCompleted.SetValue(1)endifMI_LibraryIncomplete.SetValue(0)For this, the DecorationsLibrary points to an array of ObjectReferences (all the references that are enabled in the room). My thinking here was the script would quickly run through the array, and if any are disabled it sets a global that it is incomplete. At the end, if the global hasnt been set, the room is complete.The weird thing here is it causes the exact same issues as the first one. The same rooms that were completed early are still completed early, and the rooms that didn't complete still dont complete. From what I can tell, all the globals, formlists and arrays are identical to each other (except what they contain). The MiscObjects you create at the workbench all have the script calling the function CheckCompletionStatus() - so I have no idea whats different about the rooms. Alternatively, is there a better way for me to remove the dialogue to pay to decorate a room when it is completed? Hearthfire doesn't actually have this feature - so I'm almost tempted to just leave it, but it'd be nice to have. I'm completely lost in this, so would appreciate any advice! Edited December 24, 2021 by DdsLedg Link to comment Share on other sites More sharing options...
Sphered Posted December 24, 2021 Share Posted December 24, 2021 Disclaimer I more or less have always avoided the HF housing system so this is more general info on a useful way to track refs. What I like about this method is it doesnt even make them persistent (if that matters to you) and you simply store digits to track refs when needed and relevant Int[] RefIDInt DigitRefID[Digit] = Whatever.PlaceAtMe(WhateverBase).GetFormID()Digit += 1 Or if interacting with a ref that you want to now track with this method.... ObjectReference IAmLookingAt = Game.GetCurrentCrosshairRef()If IAmLookingAt as Bool RefID[Digit] = IAmLookingAt.GetFormID() Digit += 1EndIf So long as you have 128 or less refs in play here one array will suffice to track them all. Need more? Just do another array. And so on To fetch one... Int IDKLetsPick23Ref = 23ObjectReference ThisRef = Game.GetFormEx(RefID[iDKLetsPick23Ref]) as ObjectReferenceBool Seen = ThisRef as Bool && !ThisRef.IsDisabled()Etc... For your purposes it could be scanned in batch to verify active refs and if they are visible. You can easily remove a ref by declaring that Int a 0. You can tally them up by seeing how many are not 0. Wrote this kinda fast. Hope it helps a bit Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 24, 2021 Share Posted December 24, 2021 (edited) I would think you could use a new formlist to check for objects left, which are not build.1) Create a new empty formlist with CreationKit, name it like "DecorationsLibraryList"!2) Fill this list at the begin of your house quest with all the misc objects from MI_CheckLibraryList. int i = 0 WHILE (i < MI_CheckLibraryList.GetSize()) DecorationsLibraryList.AddForm( MI_CheckLibraryList.GetAt(i) ) i = i + 1 ENDWHILE 3) Whenever a new object was created remove the entry in "DecorationsLibraryList" with https://www.creationkit.com/index.php?title=RemoveAddedForm_-_FormListyour approach if Game.GetPlayer().GetItemCount(MI_CheckLibraryList) == MI_CheckLibraryList.GetSize() MI_LibraryCompleted.SetValue(1) endifmy approach if (DecorationsLibraryList.GetSize() == 0) MI_LibraryCompleted.SetValue(1) ; all decoration objects has been paid and build endif Merry Christmas.. Edited December 24, 2021 by ReDragon2013 Link to comment Share on other sites More sharing options...
DdsLedg Posted December 24, 2021 Author Share Posted December 24, 2021 (edited) I would think you could use a new formlist to check for objects left, which are not build. 1) Create a new empty formlist with CreationKit, name it like "DecorationsLibraryList"!2) Fill this list at the begin of your house quest with all the misc objects from MI_CheckLibraryList. int i = 0 WHILE (i < MI_CheckLibraryList.GetSize()) DecorationsLibraryList.AddForm( MI_CheckLibraryList.GetAt(i) ) i = i + 1 ENDWHILE 3) Whenever a new object was created remove the entry in "DecorationsLibraryList" with https://www.creationkit.com/index.php?title=RemoveAddedForm_-_FormList your approach if Game.GetPlayer().GetItemCount(MI_CheckLibraryList) == MI_CheckLibraryList.GetSize() MI_LibraryCompleted.SetValue(1) endifmy approach if (DecorationsLibraryList.GetSize() == 0) MI_LibraryCompleted.SetValue(1) ; all decoration objects has been paid and build endif Merry Christmas..Merry Christmas to you as well!Thanks for the idea, I gave it a go and it seemed to work for the library! Time to check with the other rooms!Edit: It seems to have worked! Thank you very much! Edited December 24, 2021 by DdsLedg Link to comment Share on other sites More sharing options...
Recommended Posts