IsharaMeradin Posted May 16, 2014 Share Posted May 16, 2014 Mixing your display item formlist between items and sub-formlists is not a good idea. Trying to figure out whether the current is a formlist or some other type would be a nightmare to code. Better to do sub-formlists for all display items (gives later flexibility in case you want to add additional items somewhere) Code would be something like this. Scriptname DBM_DisplaySortScript extends ObjectReference FormList Property DisplayActivators Auto FormList Property DisplayItems Auto ;list containing sub-formlists for each display activator ObjectReference Property HoldingContainer Auto Function ActivateValidDisplays() Int DASize = DisplayActivators.GetSize() Int index = 0 While index < DASize FormList CurrentDIList = DisplayItems.GetAt(index) Int CDIsize = CurrentDIList.GetSize() Int ix = 0 Bool HaveMatch = false While ix < CDIsize If HoldingContainer.GetItemCount(CurrentDIList.GetAt(ix)) > 0 HaveMatch = true ix = CDIsize ;got a hit so get out Else HaveMatch = false EndIf If HaveMatch == true (DisplayActivators.GetAt(index) as ObjectReference).Enable() Else (DisplayActivators.GetAt(index) as ObjectReference).Disable() EndIf ix += 1 EndWhile index += 1 EndWhile EndFunction Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) ActivateValidDisplays() endevent My code counts from 0 up rather than the end down. So you may want to fill your sub-formlists with the higher leveled versions starting at 0. That way, the highest leveled version that they player obtained would be used instead of a lower leveled version. That of course would be the case if the player could actually have two different versions of the object in question. Link to comment Share on other sites More sharing options...
icecreamassassin Posted May 21, 2014 Author Share Posted May 21, 2014 Thanks for this, I'll have to investigate it more and see if I can utilize this. But in the meantime I'm having some hitches with implementing the original version. here is what I am currently using: Scriptname DBM_DisplaySortScript extends ObjectReference FormList Property DisplayActivators Auto FormList Property DisplayItems Auto ObjectReference Property HoldingContainer Auto Event OnActivate(ObjectReference akActionRef) Int DASize = DisplayActivators.GetSize() Int index = 0 While index < DASize If HoldingContainer.GetItemCount(DisplayItems.GetAt(index)) > 0 (DisplayActivators.GetAt(index) as ObjectReference).Enable() Else (DisplayActivators.GetAt(index) as ObjectReference).Disable() EndIf index += 1 EndWhile endevent and I have it attached to the holding container itself. So effectively it will only poll properly if you place stuff inside it, then exit, and then activate the container once more. I was having issues with the "OnItemAdded" event, because it was basically restarting the function each time an item was added to the list and displays were not getting enabled properly. I switched to an OnActivate and it works great.... if you open and shut the container an extra time. I thought there was some kind of "on ending inventory menu" event but I can't seem to find any reference to it, but swear there was something I saw once about it. The other reason that OnItemAdded won't work for this is because the displays can all still be placed and removed at the display itself, and the item is stored to the same container, which causes it to blink in and out once, and sometimes fail to enable. At any rate, any suggestion on a single function to properly poll the chest after you leave it would be great :) Link to comment Share on other sites More sharing options...
icecreamassassin Posted May 21, 2014 Author Share Posted May 21, 2014 so looking at your code above, am I right in thinking that basically the DisplayItem formlist will be a list of sub forms which each has a single item or list of the leveled item? so the ebony armor would have a form list that has just the ebony armor listed and chillrend would have a formlist that lists all 6 leveled versions for instance? that seems like a LOT of work to separate each item into it's own formlist XP If that's the case, I'll just tell people "stick it on the rack yourself you lazy *(&^%&!" lol Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 21, 2014 Share Posted May 21, 2014 so looking at your code above, am I right in thinking that basically the DisplayItem formlist will be a list of sub forms which each has a single item or list of the leveled item? so the ebony armor would have a form list that has just the ebony armor listed and chillrend would have a formlist that lists all 6 leveled versions for instance? that seems like a LOT of work to separate each item into it's own formlist XP If that's the case, I'll just tell people "stick it on the rack yourself you lazy *(&^%&!" lolYup, pretty much sums it up. Now if you know beyond a shadow of a doubt which index is what (either item or leveled list) then you could have a mixed list for the display items. You would have to break the process up with at least two if statements. One to handle normal items and one to handle the leveled items. Right now, I can't even think of that off the top of my head. An alternative process might be to use the 1 to 1 ratio form lists for normal items and do specific entries for the leveled items. At any rate, any suggestion on a single function to properly poll the chest after you leave it would be greatSKSE's OnMenuClose. That would be the event to use to get when the container menu has been closed. The thing to remember tho is that if you are doing a lot at the OnActivate event, it may not all be finished by the time the menu is closed. It might be better to use OnMenuClose for activating the displays because then you are assured that all the items that are in the container will be there for the processing. OnActivate most often gets only what is there when it has been opened and not what the player has added in. Link to comment Share on other sites More sharing options...
jaxonz Posted May 21, 2014 Share Posted May 21, 2014 I realize I'm chiming in on this late. The mechanism for moving items to a special holding container while you enable/disable statics on your displays could be avoided if you just leverage the standard weapon rack scripts, WeaponRackTriggerSCRIPT and WeaponRackActivateSCRIPT. These scripts have the checks for item types set up as properties and move the actual item to the desired location. This would turn much of your effort into a modeling and property setting exercise with no coding for managing individual items. Caveats:weapon rack scripts assume the items are of type that can be equipped, so if you are displaying things like Dwemer cogs, a custom variation of the script would need to be created.your display placements may put the objects out of reach of the playerthese scripts are known to be fickle, exhibiting issues when activators are perfectly aligned (z angle 0/90/180/270) or sometimes not allowing objects to be recoveredLooks like you have most of the code written and working already. Congrats! Maybe this will be good advice to a subsequent reader with a similar need. Cheers. Link to comment Share on other sites More sharing options...
icecreamassassin Posted May 21, 2014 Author Share Posted May 21, 2014 Yeah I'm aware on the pitfalls of onactivate, and yeah on menu close would work for what I need, that's the one I was thinking of now that you mention it. My plan was to call the action from it rather than an activation and see how it works Link to comment Share on other sites More sharing options...
icecreamassassin Posted May 22, 2014 Author Share Posted May 22, 2014 ok, noob question, but how do I get SKSE working with the CK so it will compile properly? I have it installed for game use, but haven't delved into using it for the mod yet. Couldn't find a good answer online :P too many damned hits for followers and companions on EVERY search I make.... uhhhggg Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 22, 2014 Share Posted May 22, 2014 Are you familiar with Gopher's video for installing SKSE? If you follow his instructions to the letter, it will be set up appropriately. To delve into specifics, you need to make sure that not only do you install the PEX files for the game to use but also install the PSC files for the Creation Kit's use. Link to comment Share on other sites More sharing options...
icecreamassassin Posted May 22, 2014 Author Share Posted May 22, 2014 Great I'll check it out thanks. Link to comment Share on other sites More sharing options...
icecreamassassin Posted May 24, 2014 Author Share Posted May 24, 2014 So got SKSE working for CK, and I have the following code, which compiles and seems to be right but it for some reason still activates only when activating the container rather than when leaving it Scriptname DBM_DisplaySortScript extends ObjectReference FormList Property DisplayActivators Auto FormList Property DisplayItems Auto ObjectReference Property HoldingContainer Auto Event OnInit() RegisterForMenu("ContainerMenu") EndEvent Event OnMenuClose(String MenuName) If MenuName == "ContainerMenu" Int DASize = DisplayActivators.GetSize() Int index = 0 While index < DASize If HoldingContainer.GetItemCount(DisplayItems.GetAt(index)) > 0 (DisplayActivators.GetAt(index) as ObjectReference).Enable() Else (DisplayActivators.GetAt(index) as ObjectReference).Disable() EndIf index += 1 EndWhile endif endevent Link to comment Share on other sites More sharing options...
Recommended Posts