Jump to content

Modding Help: How to display items when put into a container


Recommended Posts

Hello! I was wondering if someone could help me with some modding problems I have been working on for a while.

  1. I would like to display multiple items by putting them in a container and then them showing up somewhere else instead of going through a script to place them individually. Example: placing food in a container and it shows up in a bowl, one by one.

  2. I would also like to display books either by using the same method or have a script search my inventory and display them that way. Also cant this be done with other items as well?

My goal is to try and to do display like legacy of the dragonborn. I have tried to look at the scripts but I dont know how to set anything help. I would like to display everything!

 

If anyone can help me out I really appreciate it.

Thanks

 

Edit Thanks everyone for the help! I was able to find what i needed on this page: https://www.nexusmods.com/skyrim/articles/51550.

It is not exact but will fit my needs.

Edited by petdoc1991
Link to comment
Share on other sites

Hey, I don't know how legacy does it, but you can put xmarkers where you want objects to display and then use PlaceAtMe to display object at the markers. Here's an example script that will display up to 4 objects. Put the script on your container.

 

 

 

ObjectReference Property DisplayMarker1 Auto ;marker placed in the creation kit.
ObjectReference Property DisplayMarker2 Auto
ObjectReference Property DisplayMarker3 Auto
ObjectReference Property DisplayMarker4 Auto

ObjectReference  DisplayObj1 
ObjectReference  DisplayObj2 
ObjectReference  DisplayObj3 
ObjectReference  DisplayObj4 

Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) 
    If DisplayObj1 == None 
        DisplayObj1 = DisplayMarker1.PlaceAtMe(akBaseItem, 1) ;place a world ref of added object added at marker and save it's reference to DisplayObj1. 
        DisplayObj1.SetMotionType(4) ;set to keyframed - makes object static. 
        DisplayObj1.BlockActivation() ;prevent activating.
        
    Elseif  DisplayObj2 == None 
        DisplayObj2 = DisplayMarker2.PlaceAtMe(akBaseItem, 1) 
        DisplayObj2.SetMotionType(4) 
        DisplayObj2.BlockActivation() 
        
    Elseif  DisplayObj3 == None 
        DisplayObj3 = DisplayMarker3.PlaceAtMe(akBaseItem, 1) 
        DisplayObj3.SetMotionType(4) 
        DisplayObj3.BlockActivation() 
        
    Elseif  DisplayObj4 == None 
        DisplayObj4 = DisplayMarker4.PlaceAtMe(akBaseItem, 1) 
        DisplayObj4.SetMotionType(4) 
        DisplayObj4.BlockActivation() 
        
    Endif 
EndEvent  

Event OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) 
    If DisplayObj1.GetBaseObject() == akBaseItem
        DisplayObj1.Disable() 
        DisplayObj1.Delete() 
        DisplayObj1 = None 
        
    ElseIf DisplayObj2.GetBaseObject() == akBaseItem
        DisplayObj2.Disable() 
        DisplayObj2.Delete() 
        DisplayObj2 = None 
      
    ElseIf DisplayObj3.GetBaseObject() == akBaseItem
        DisplayObj3.Disable() 
        DisplayObj3.Delete() 
        DisplayObj3 = None 
      
    ElseIf DisplayObj4.GetBaseObject() == akBaseItem
        DisplayObj4.Disable() 
        DisplayObj4.Delete() 
        DisplayObj4 = None 
      
    Endif
EndEvent

 

 

Link to comment
Share on other sites

For multiple items you can use arrays, and a form list to check if you want to display the item or not. Use a script something like this:

 

 

 

Scriptname TM_ObjectRefScript extends ObjectReference 

ObjectReference[] Property DisplayMarkers Auto ;array of placed markers in the creation kit
ObjectReference[] DisplayObjects ;array of display references
Form[] DisplayedForms ;Array of displayed objects base forms.
Formlist Property AllowedDisplayForms Auto; Fill this formlist with forms that you want to be displayed

Event OnInit() 
    DisplayObjects = New ObjectReference[128] ;initialize array with 128 possible entries.
    DisplayedForms = New Form[128] ;initialize array with 128 possible entries.
EndEvent

Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) 
    If AllowedDisplayForms.HasForm(akBaseItem) ;can we display the item added to this container?
        Int I = 0 
        Int M = aiItemCount
        While I < M
            Int EmptyDisplaySlot = DisplayObjects.Find(None) ;find empty display slot 
            If EmptyDisplaySlot > -1 ;if there is an empty display slot 
                DisplayedForms[EmptyDisplaySlot] = akBaseItem ;save displayed form for use in OnItemRemoved event.
                DisplayObjects[EmptyDisplaySlot] = DisplayMarkers[EmptyDisplaySlot].PlaceAtMe(akBaseItem, 1) ;{place a new display object at the display marker and save its reference   
                DisplayObjects[EmptyDisplaySlot].BlockActivation() 
                DisplayObjects[EmptyDisplaySlot].SetMotionType(4) ;make object static. May not be necessarry.
            Else 
                I = M ;stop loop if no more display slots are open. 
            EndIf 
            I += 1 
        EndWhile
    Endif          
EndEvent  

Event OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) 
    If AllowedDisplayForms.HasForm(akBaseItem) ;can we display the item removed from this container?
        Int I = 0 
        Int M = aiItemCount
        While I < M
            Int DisplayedSlot = DisplayedForms.Find(akBaseItem) ;find slot where removed object is displayed
            If DisplayedSlot > -1 ;If the removed object is displayed
                DisplayedForms[DisplayedSlot] = None ;clear displayed form
                DisplayObjects[DisplayedSlot].Disable()
                DisplayObjects[DisplayedSlot].Delete()
                DisplayObjects[DisplayedSlot] = None
            Else 
                I = M ;stop loop if no more of the removed item(s) are displayed.
            EndIf 
            I += 1 
        EndWhile
    Endif        
EndEvent

 

 

 

You still have to place xmarker references in the creation kit, then put them in the DisplayMarkers array when filling your script properties. That will display up to 128 items. Name the script something more unique to your mod. You can also check out the vanilla PlayerBookShelfContainerScript. It's pretty similar although it doesn't use arrays.

Link to comment
Share on other sites

Ok so if I understand correctly I need to put x markers where the items would show up at. Example xmarkers in bowl then apples will appear?

Next I would use a formlist to display the items (this would be the static versions or regular?) I kind of need help setting the thing up.

Edited by petdoc1991
Link to comment
Share on other sites

Yes, first you put x markers where the items should show up. After compiling the script, add those markers to the DisplayMarkers array when filling your script properties. In the AllowedDisplayForms formlist, add the items that you want to be displayed. So add the actual FoodApple potion to the formlist to display apples. Also change the 128 in

DisplayObjects = New ObjectReference[128]

To the number of markers you have.

Link to comment
Share on other sites

Bah! I am having a hard time getting this thing set up... I put the x markers in the bowl and connected them to the script but the apples are still not showing up. Do I need to restart the game with a new save or did i set it up wrong?

Link to comment
Share on other sites

The script should be attached to the container, that got the items by players activation (add/remove action here). The script properties have to be filled with the xmarkers you placed to the cell.

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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