timsterse Posted July 3, 2019 Share Posted July 3, 2019 (edited) Going though some issues with my mod. Notably, vanilla scripts are resource intensive so I found this old discussion and am attempting to utilize the scripts in there. http://www.gamesas.com/universal-item-display-script-weapons-shields-potions-etc-t259977.html Short copy of instructions from original post: new activator (worldobjects/activators), unique ID, label, choose nif mesh, save - mind z0.0 bug new container (worldobjects/containers), unique ID, label, choose nif mesh (search 'dummy' for mesh URLs), save select container new trigger from Tmenu icon, form DefaultBlankTrigger, primitive tab: L_TRIGGER - mind z0.0 bug container edit base, add script [need script source from my nexus forum post] new message, unique ID, tick Message Box, enter sensible language for fail message / alternatively use deaultLackTheItemMSG message open script properties, set DisplayType [1-8], messageCount and MessageWarning (rest optional/ see code for details) activator, new script, unique ID, paste code [from nexus forum post] go back to instance, not base(!), script tab: script properties: itemChest is container, itemTriger is trigger box The container script was garbled on the original post, so I went though the effort to troubleshoot line by line until it compiled successfully. Bool Property Blocked = False Auto Message Property MessageWarning Auto Message Property MessageCount Auto Keyword Property ArmorShield Auto Keyword Property WeapTypeDagger Auto Keyword Property WeapTypeSword Auto Keyword Property WeapTypeGreatSword Auto Keyword Property ClothingRing Auto Keyword Property VendorItemPotion Auto Keyword Property VendorItemPoison Auto FormList Property GemList Auto FormList Property ClawList Auto FormList Property WhitePhial Auto Form Property ItemSlot = None Auto Hidden Int Property PlacedItem = 0 Auto Hidden Int Property DisplayType Auto ; 1 = Weapon rack, 2 = Dagger case, 3 = Jewel display, 4 = Shield plaque, 5 = Potion/poison, 6 = Dragon claw, 7 = COA weapon, 8 = Book Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Actor PlayerRef = Game.GetPlayer() If (akSourceContainer == PlayerRef) If (AllowedItems(akBaseItem)) If (aiItemCount == 1) && (PlacedItem == 0) PlacedItem += aiItemCount ItemSlot = akBaseItem RegisterForSingleUpdate(0.1) Else MessageCount.Show() PlacedItem += aiItemCount Self.RemoveItem(akBaseItem, aiItemCount, False, PlayerRef) EndIf Else MessageWarning.Show() PlacedItem += aiItemCount Self.RemoveItem(akBaseItem, aiItemCount, False, PlayerRef) EndIf Else Self.RemoveItem(akBaseItem, aiItemCount, False, akSourceContainer) EndIf EndEvent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If (akDestContainer == Game.GetPlayer()) UnregisterForUpdate() EndIf PlacedItem -= aiItemCount EndEvent Event OnUpdate() MountCurrentItem(ItemSlot) EndEvent Function MountCurrentItem(Form akBaseItem) Int i = 0 ObjectReference MountedItem = DropObject(akBaseItem) If (MountedItem != None) Blocked = True While(!MountedItem.Is3DLoaded()) && (i < 10) Utility.Wait(0.1) i += 1 EndWhile MountedItem.SetMotionType(Motion_Keyframed, False) MountedItem.TranslateToRef(Self, 2000.0, 0.0) Utility.Wait(1) Blocked = False EndIf EndFunction Bool Function AllowedItems(Form akBaseItem) If (DisplayType == 1) Return (akBaseItem as Weapon) ElseIf (DisplayType == 2) Return (akBaseItem.HasKeyword(WeapTypeDagger)) ElseIf (DisplayType == 3) Return ((akBaseItem.HasKeyword(ClothingRing)) || (GemList.HasForm(akBaseItem))) ElseIf (DisplayType == 4) Return (akBaseItem.HasKeyword(ArmorShield)) ElseIf (DisplayType == 5) Return ((akBaseItem.HasKeyword(VendorItemPotion)) || (akBaseItem.HasKeyword(VendorItemPoison)) || (WhitePhial.HasForm(akBaseItem))) ElseIf (DisplayType == 6) Return (ClawList.HasForm(akBaseItem)) ElseIf (DisplayType == 7) Return ((akBaseItem.HasKeyword(WeapTypeSword)) || (akBaseItem.HasKeyword(WeapTypeGreatSword))) ElseIf (DisplayType == 8) Return (akBaseItem as Book) EndIf EndFunction this is the activator script but requires the container script given name as reference: ObjectReference Property ItemChest Auto ObjectReference Property ItemTrigger Auto Event OnActivate(ObjectReference akActionRef) If (akActionRef == Game.GetPlayer()) If ((ItemTrigger.GetTriggerObjectCount() == 0) && ((ItemChest as ;;;container script name;;;).Blocked == False)) ItemChest.Activate(akActionRef) EndIf EndIf EndEvent For now, I'm posting for reference but I assume I'll run into trouble as usual and will need to ask the community some questions. And if (amLucky=1) Return as Tutorial ;P Edited July 3, 2019 by timsterse Link to comment Share on other sites More sharing options...
ReDragon2013 Posted July 5, 2019 Share Posted July 5, 2019 (edited) The first thing is understanding syntax of papyrus scripting. EACH line, one command exception: character \ as last char in a line, which anounce the compiler to use next line too all chars after character ; will be threated as comment exception: multiline comment BEGIN ;/ END with /; In the following scripts I changed somethings:xyzGenericDisplayScript Scriptname xyzGenericDisplayScript extends ObjectReference {comment here} ; modding Skyrim SE ; https://forums.nexusmods.com/index.php?/topic/7786588-attempting-a-generic-item-display-script/ Message PROPERTY MessageWarning auto Message PROPERTY MessageCount auto Keyword PROPERTY ArmorShield auto Keyword PROPERTY WeapTypeDagger auto Keyword PROPERTY WeapTypeSword auto Keyword PROPERTY WeapTypeGreatSword auto Keyword PROPERTY ClothingRing auto Keyword PROPERTY VendorItemPotion auto Keyword PROPERTY VendorItemPoison auto FormList PROPERTY GemList auto FormList PROPERTY ClawList auto FormList PROPERTY WhitePhial auto Form PROPERTY ItemSlot auto Hidden ; [default=None] Bool PROPERTY bBlocked auto Hidden ; [default=False] Int PROPERTY PlacedItem auto Hidden ; [default=0] Int PROPERTY DisplayType auto ; [ddefault=0] all available ; 1 = Weapon rack ; 2 = Shield plaque ; (4) ; 3 = COA weapon ; (7) ; 4 = Dagger case ; (2) ; 5 = Jewel display ; (3) ; 6 = Dragon claw ; 7 = Potion/poison ; (5) ; 8 = Book ; -- EVENTs -- EVENT OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) IF (akSourceContainer == Game.GetPlayer() as ObjectReference) ELSE self.RemoveItem(akBaseItem, aiItemCount, False, akSourceContainer) RETURN ; - STOP - not the player, item added by someone else give all back to source ENDIF ;--------------------- myF_Add(akSourceContainer, akBaseItem, aiItemCount) ENDEVENT EVENT OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) IF (akDestContainer == Game.GetPlayer() as ObjectReference) UnRegisterForUpdate() ; *U* ENDIF PlacedItem = PlacedItem - aiItemCount ENDEVENT EVENT OnUpdate() MountCurrentItem() ENDEVENT ; -- FUNCTIONs -- 3 ;---------------------------------------------------------- FUNCTION myF_Add(ObjectReference playerRef, Form fm, Int i) ;---------------------------------------------------------- IF myF_FoundItem(fm) PlacedItem = PlacedItem + i IF (i == 1) && (PlacedItem == 0) ItemSlot = fm RegisterForSingleUpdate(0.1) ; *** RETURN ; - STOP - ENDIF ; ---------------------- MessageCount.show() ELSE MessageWarning.show() ENDIF self.RemoveItem(fm, i, False, PlayerRef) ENDFUNCTION ;----------------------------------- Bool FUNCTION myF_FoundItem(Form fm) ;----------------------------------- IF (DisplayType == 1) RETURN (fm as Weapon) ENDIF ;--------- IF (DisplayType == 2) RETURN fm.HasKeyword(ArmorShield) ENDIF ;--------- IF (DisplayType == 3) RETURN fm.HasKeyword(WeapTypeSword) || fm.HasKeyword(WeapTypeGreatSword) ENDIF ;--------- IF (DisplayType == 4) RETURN fm.HasKeyword(WeapTypeDagger) ENDIF ;--------- IF (DisplayType == 5) RETURN fm.HasKeyword(ClothingRing) || GemList.HasForm(fm) ENDIF ;--------- IF (DisplayType == 6) RETURN ClawList.HasForm(fm) ENDIF ;--------- IF (DisplayType == 7) RETURN fm.HasKeyword(VendorItemPotion) || fm.HasKeyword(VendorItemPoison) || WhitePhial.HasForm(fm) ENDIF ;--------- IF (DisplayType == 8) RETURN (fm as Book) ENDIF ;--------- Return False ; safety first ENDFUNCTION ;-------------------------- FUNCTION MountCurrentItem() ;-------------------------- objectReference oRef ; oRef = MountedItem IF ( ItemSlot ) oRef = self.DropObject(ItemSlot) Utility.Wait(0.03) ENDIF IF (oRef) && oRef.GetBaseObject() ELSE RETURN ; - STOP - something went wrong, trouble comes true by weapons which have a script attached! ENDIF ;--------------------- bBlocked = TRUE int i = 10 WHILE (i) ; (we are waiting for 3D) OR (i <= 0) i = i - 1 IF oRef.Is3DLoaded() oRef.SetMotionType(Motion_Keyframed, False) oRef.TranslateToRef(self, 2000.0, 0.0) Utility.Wait(0.9) i = -1 ENDIF Utility.Wait(0.1) ENDWHILE bBlocked = False ENDFUNCTION xyzGenericActivatorScript Scriptname xyzGenericActivatorScript extends ObjectReference {comment here} ; modding Skyrim SE ; https://forums.nexusmods.com/index.php?/topic/7786588-attempting-a-generic-item-display-script/ ObjectReference PROPERTY ItemChest auto ObjectReference PROPERTY ItemTrigger auto ; -- EVENT -- EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not player activated ENDIF ;--------------------- IF (ItemTrigger.GetTriggerObjectCount() > 0) RETURN ; - STOP - object already triggered ENDIF ;--------------------- IF (!ItemChest) || ((ItemChest as xyzGenericDisplayScript).bBlocked) RETURN ; - STOP - missing property OR chest is currently blocked ENDIF ;--------------------- ItemChest.Activate(akActionRef) ; send activate command for player ENDEVENT Edited July 5, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
Recommended Posts