Jump to content

[LE] [HELP] Checking items/references using a formlist


DdsLedg

Recommended Posts

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)
endif

The 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 = 0
while iCurrentArrayIndex < DecorationsLibrary.length
if DecorationsLibrary[iCurrentArrayIndex].IsDisabled()
MI_LibraryIncomplete.SetValue(1)
endif
iCurrentArrayIndex = iCurrentArrayIndex + 1
endWhile
if MI_LibraryIncomplete.GetValue() == 0
MI_LibraryCompleted.SetValue(1)
endif
MI_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 by DdsLedg
Link to comment
Share on other sites

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[] RefID
Int Digit

RefID[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 += 1
EndIf

 

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 = 23
ObjectReference ThisRef = Game.GetFormEx(RefID[iDKLetsPick23Ref]) as ObjectReference
Bool 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

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)
endif

my approach

if (DecorationsLibraryList.GetSize() == 0)
    MI_LibraryCompleted.SetValue(1)                ; all decoration objects has been paid and build
endif


Merry Christmas..

Edited by ReDragon2013
Link to comment
Share on other sites

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)
endif

my 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 by DdsLedg
Link to comment
Share on other sites

  • Recently Browsing   0 members

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