cdcooley Posted December 13, 2014 Share Posted December 13, 2014 On 12/12/2014 at 7:33 PM, thejadeshadow said: Hm, I am getting these errors when I compile: (27,6): required (...)+ loop did not match anything at input 'IsInChest'(29,1): mismatched input 'else' expecting ENDIF(31,1): mismatched input 'endif' expecting ENDEVENTSorry I should have actually run that through the compiler but I was in a hurry this morning. Try this: Scriptname EE_DisplayArmorScript extends ObjectReference Armor Property ItemToPlace1 Auto Armor Property ItemToPlace2 Auto Armor Property ItemToPlace3 Auto Armor Property ItemToPlace4 Auto Armor Property ItemToPlace5 Auto Armor Property ItemToPlace6 Auto ObjectReference Property EE_DisplayMasterChest Auto Actor Property PlayerRef Auto Event OnActivate(ObjectReference akActivator) if akActivator == PlayerRef ; first if it is already in the container try to move it to the player if MoveFromChestToPlayer(ItemToPlace1) || MoveFromChestToPlayer(ItemToPlace2) elseif MoveFromChestToPlayer(ItemToPlace3) || MoveFromChestToPlayer(ItemToPlace4) elseif MoveFromChestToPlayer(ItemToPlace5) || MoveFromChestToPlayer(ItemToPlace6) ; if not, check to see if the player is carrying it and move it to the container elseif MoveFromPlayerToChest(ItemToPlace1) || MoveFromPlayerToChest(ItemToPlace2) elseif MoveFromPlayerToChest(ItemToPlace3) || MoveFromPlayerToChest(ItemToPlace4) elseif MoveFromPlayerToChest(ItemToPlace5) || MoveFromPlayerToChest(ItemToPlace6) endif endif ; update the display static if IsInChest(ItemToPlace1) || IsInChest(ItemToPlace2) || IsInChest(ItemToPlace3) getLinkedRef().enable() elseif IsInChest(ItemToPlace4) || IsInChest(ItemToPlace5) || IsInChest(ItemToPlace6) getLinkedRef().enable() else getLinkedRef().disable() endif EndEvent bool Function IsInChest(Armor item) return item && EE_DisplayMasterChest.getItemCount(item) > 0 EndFunction bool Function MoveFromChestToPlayer(Armor item) if IsInChest(item) EE_DisplayMasterChest.removeItem(item, 1, false, PlayerRef) return true endif return false EndFunction bool Function MoveFromPlayerToChest(Armor item) if item && PlayerRef.getItemCount(item) > 0 PlayerRef.removeItem(item, 1, false, EE_DisplayMasterChest) return true endif return false EndFunction Link to comment Share on other sites More sharing options...
thejadeshadow Posted December 14, 2014 Author Share Posted December 14, 2014 Thanks for the scripting help! Link to comment Share on other sites More sharing options...
thejadeshadow Posted December 14, 2014 Author Share Posted December 14, 2014 I am experimenting with this other script, because it would allow me to combine all my different types of form scripts into one. http://forums.nexusmods.com/index.php?/topic/1235874-item-display-script-problem/ I've spent about 40 hours implementing it into my mod, Elysium Estate, this week. I expanded it to 6 items total and allowing ammo for form 7. It works very well. However, I am getting this error in Papyrus. 04:59:27AM] warning: Assigning None to a non-object variable named "::temp3"stack:[ (040EC726)].EE_UniversalDisplayScript.OnActivate() - "EE_UniversalDisplayScript.psc" Line 87[12/14/2014 - 04:59:27AM] warning: Assigning None to a non-object variable named "::temp3"stack:[ (040EC726)].EE_UniversalDisplayScript.OnActivate() - "EE_UniversalDisplayScript.psc" Line 88[12/14/2014 - 04:59:27AM] warning: Assigning None to a non-object variable named "::temp3"stack:[ (040EC726)].EE_UniversalDisplayScript.OnActivate() - "EE_UniversalDisplayScript.psc" Line 89[12/14/2014 - 04:59:27AM] warning: Assigning None to a non-object variable named "::temp3"stack:[ (040EC726)].EE_UniversalDisplayScript.OnActivate() - "EE_UniversalDisplayScript.psc" Line 90[12/14/2014 - 04:59:27AM] warning: Assigning None to a non-object variable named "::temp3"stack:[ (040EC726)].EE_UniversalDisplayScript.OnActivate() - "EE_UniversalDisplayScript.psc" Line 91[12/14/2014 - 04:59:27AM] warning: Assigning None to a non-object variable named "::temp3"stack:[ (040EC726)].EE_UniversalDisplayScript.OnActivate() - "EE_UniversalDisplayScript.psc" Line 92 The "FAllowedItem01() through FAllowedItem06()", is the culprit. Any insights into why this is happening? I don't want to be spamming people's logs with these warnings. Also, this is on a Skyrim+DG+DB game with no mods installed besides Elysium Estate. Scriptname EE_UniversalDisplayScript extends ObjectReference Bool Property isPlaced = false Auto Hidden ObjectReference Property HiddenChest Auto Actor Property PlayerRef Auto ObjectReference Property StaticItem01 Auto Int Property DisplayType01 = 0 Auto ; 1 = Soul Gem, 2 = Book, 3 = Weapon, 4 = Misc Object, 5 = Potion, 6 = Armor, 7 = Ammo Int Property DisplayType02 = 0 Auto ; 1 = Soul Gem, 2 = Book, 3 = Weapon, 4 = Misc Object, 5 = Potion, 6 = Armor, 7 = Ammo Int Property DisplayType03 = 0 Auto ; 1 = Soul Gem, 2 = Book, 3 = Weapon, 4 = Misc Object, 5 = Potion, 6 = Armor, 7 = Ammo Int Property DisplayType04 = 0 Auto ; 1 = Soul Gem, 2 = Book, 3 = Weapon, 4 = Misc Object, 5 = Potion, 6 = Armor, 7 = Ammo Int Property DisplayType05 = 0 Auto ; 1 = Soul Gem, 2 = Book, 3 = Weapon, 4 = Misc Object, 5 = Potion, 6 = Armor, 7 = Ammo Int Property DisplayType06 = 0 Auto ; 1 = Soul Gem, 2 = Book, 3 = Weapon, 4 = Misc Object, 5 = Potion, 6 = Armor, 7 = Ammo SoulGem Property tSoulGem01 Auto Book Property tBook01 Auto Weapon Property tWeapon01 Auto MiscObject Property tMiscObject01 Auto Potion Property tPotion01 Auto Armor Property tArmor01 Auto Ammo Property tAmmo01 Auto SoulGem Property tSoulGem02 Auto Book Property tBook02 Auto Weapon Property tWeapon02 Auto MiscObject Property tMiscObject02 Auto Potion Property tPotion02 Auto Armor Property tArmor02 Auto Ammo Property tAmmo02 Auto SoulGem Property tSoulGem03 Auto Book Property tBook03 Auto Weapon Property tWeapon03 Auto MiscObject Property tMiscObject03 Auto Potion Property tPotion03 Auto Armor Property tArmor03 Auto Ammo Property tAmmo03 Auto SoulGem Property tSoulGem04 Auto Book Property tBook04 Auto Weapon Property tWeapon04 Auto MiscObject Property tMiscObject04 Auto Potion Property tPotion04 Auto Armor Property tArmor04 Auto Ammo Property tAmmo04 Auto SoulGem Property tSoulGem05 Auto Book Property tBook05 Auto Weapon Property tWeapon05 Auto MiscObject Property tMiscObject05 Auto Potion Property tPotion05 Auto Armor Property tArmor05 Auto Ammo Property tAmmo05 Auto SoulGem Property tSoulGem06 Auto Book Property tBook06 Auto Weapon Property tWeapon06 Auto MiscObject Property tMiscObject06 Auto Potion Property tPotion06 Auto Armor Property tArmor06 Auto Ammo Property tAmmo06 Auto Form AllowedItem01 Form AllowedItem02 Form AllowedItem03 Form AllowedItem04 Form AllowedItem05 Form AllowedItem06 EVENT OnActivate(objectReference akActivator) If akActivator == PlayerRef if(isPlaced == FALSE) FAllowedItem01() FAllowedItem02() FAllowedItem03() FAllowedItem04() FAllowedItem05() FAllowedItem06() if PlayerRef.getItemCount(AllowedItem01) >= 1 isPlaced = TRUE StaticItem01.enable() PlayerRef.removeItem(AllowedItem01, 1,False,HiddenChest) elseif PlayerRef.getItemCount(AllowedItem02) >= 1 isPlaced = TRUE StaticItem01.enable() PlayerRef.removeItem(AllowedItem02, 1,False,HiddenChest) elseif PlayerRef.getItemCount(AllowedItem03) >= 1 isPlaced = TRUE StaticItem01.enable() PlayerRef.removeItem(AllowedItem03, 1,False,HiddenChest) elseif PlayerRef.getItemCount(AllowedItem04) >= 1 isPlaced = TRUE StaticItem01.enable() PlayerRef.removeItem(AllowedItem04, 1,False,HiddenChest) elseif PlayerRef.getItemCount(AllowedItem05) >= 1 isPlaced = TRUE StaticItem01.enable() PlayerRef.removeItem(AllowedItem05, 1,False,HiddenChest) elseif PlayerRef.getItemCount(AllowedItem06) >= 1 isPlaced = TRUE StaticItem01.enable() PlayerRef.removeItem(AllowedItem06, 1,False,HiddenChest) else debug.notification("You lack the required item.") endif else isPlaced = FALSE StaticItem01.disable() HiddenChest.removeItem(AllowedItem01, 1,False,PlayerRef) StaticItem01.disable() HiddenChest.removeItem(AllowedItem02, 1,False,PlayerRef) StaticItem01.disable() HiddenChest.removeItem(AllowedItem03, 1,False,PlayerRef) StaticItem01.disable() HiddenChest.removeItem(AllowedItem04, 1,False,PlayerRef) StaticItem01.disable() HiddenChest.removeItem(AllowedItem05, 1,False,PlayerRef) StaticItem01.disable() HiddenChest.removeItem(AllowedItem06, 1,False,PlayerRef) endif EndIf endEvent Bool Function FAllowedItem01() If (DisplayType01 == 1) AllowedItem01 = tSoulGem01 ElseIf (DisplayType01 == 2) AllowedItem01 = tBook01 ElseIf (DisplayType01 == 3) AllowedItem01 = tWeapon01 ElseIf (DisplayType01 == 4) AllowedItem01 = tMiscObject01 ElseIf (DisplayType01 == 5) AllowedItem01 = tPotion01 ElseIf (DisplayType01 == 6) AllowedItem01 = tArmor01 ElseIf (DisplayType01 == 7) AllowedItem01 = tAmmo01 EndIf EndFunction Bool Function FAllowedItem02() If (DisplayType02 == 1) AllowedItem02 = tSoulGem02 ElseIf (DisplayType02 == 2) AllowedItem02 = tBook02 ElseIf (DisplayType02 == 3) AllowedItem02 = tWeapon02 ElseIf (DisplayType02 == 4) AllowedItem02 = tMiscObject02 ElseIf (DisplayType02 == 5) AllowedItem02 = tPotion02 ElseIf (DisplayType02 == 6) AllowedItem02 = tArmor02 ElseIf (DisplayType02 == 7) AllowedItem02 = tAmmo02 EndIf EndFunction Bool Function FAllowedItem03() If (DisplayType03 == 1) AllowedItem03 = tSoulGem03 ElseIf (DisplayType03 == 2) AllowedItem03 = tBook03 ElseIf (DisplayType03 == 3) AllowedItem03 = tWeapon03 ElseIf (DisplayType03 == 4) AllowedItem03 = tMiscObject03 ElseIf (DisplayType03 == 5) AllowedItem03 = tPotion03 ElseIf (DisplayType03 == 6) AllowedItem03 = tArmor03 ElseIf (DisplayType03 == 7) AllowedItem03 = tAmmo03 EndIf EndFunction Bool Function FAllowedItem04() If (DisplayType04 == 1) AllowedItem04 = tSoulGem04 ElseIf (DisplayType04 == 2) AllowedItem04 = tBook04 ElseIf (DisplayType04 == 3) AllowedItem04 = tWeapon04 ElseIf (DisplayType04 == 4) AllowedItem04 = tMiscObject04 ElseIf (DisplayType04 == 5) AllowedItem04 = tPotion04 ElseIf (DisplayType04 == 6) AllowedItem04 = tArmor04 ElseIf (DisplayType04 == 7) AllowedItem04 = tAmmo04 EndIf EndFunction Bool Function FAllowedItem05() If (DisplayType05 == 1) AllowedItem05 = tSoulGem05 ElseIf (DisplayType05 == 2) AllowedItem05 = tBook05 ElseIf (DisplayType05 == 3) AllowedItem05 = tWeapon05 ElseIf (DisplayType05 == 4) AllowedItem05 = tMiscObject05 ElseIf (DisplayType05 == 5) AllowedItem05 = tPotion05 ElseIf (DisplayType05 == 6) AllowedItem05 = tArmor05 ElseIf (DisplayType05 == 7) AllowedItem05 = tAmmo05 EndIf EndFunction Bool Function FAllowedItem06() If (DisplayType06 == 1) AllowedItem06 = tSoulGem06 ElseIf (DisplayType06 == 2) AllowedItem06 = tBook06 ElseIf (DisplayType06 == 3) AllowedItem06 = tWeapon06 ElseIf (DisplayType06 == 4) AllowedItem06 = tMiscObject06 ElseIf (DisplayType06 == 5) AllowedItem06 = tPotion06 ElseIf (DisplayType06 == 6) AllowedItem06 = tArmor06 ElseIf (DisplayType06 == 7) AllowedItem06 = tAmmo06 EndIf EndFunction Link to comment Share on other sites More sharing options...
Terra Nova Posted December 14, 2014 Share Posted December 14, 2014 There's a bug with using typed functions that do not return a value. Remove the type Bool from your functions associated with that error. Secondly, Bool properly isPlaced = false auto hidden. Remove the hidden flag so you can change it in the CK. While it does look like you're assigning false this way, you're actually not. Change this to false in the CK. It can still be changed at run-time when you need it to. If you still recieve errors, you may need to check that the contents of those functions are actually having an object assigned. In other words, verify that ALL properties are filled. Link to comment Share on other sites More sharing options...
cdcooley Posted December 14, 2014 Share Posted December 14, 2014 The generalized version of a script that will work with any type of item is just a matter of using Form instead of a more specific type like this: Scriptname EE_DisplayItemScript extends ObjectReference Form Property ItemToPlace1 Auto Form Property ItemToPlace2 Auto Form Property ItemToPlace3 Auto Form Property ItemToPlace4 Auto Form Property ItemToPlace5 Auto Form Property ItemToPlace6 Auto ObjectReference Property EE_DisplayMasterChest Auto Actor Property PlayerRef Auto Event OnActivate(ObjectReference akActivator) if akActivator == PlayerRef ; first if it is already in the container try to move it to the player if MoveFromChestToPlayer(ItemToPlace1) || MoveFromChestToPlayer(ItemToPlace2) elseif MoveFromChestToPlayer(ItemToPlace3) || MoveFromChestToPlayer(ItemToPlace4) elseif MoveFromChestToPlayer(ItemToPlace5) || MoveFromChestToPlayer(ItemToPlace6) ; if not, check to see if the player is carrying it and move it to the container elseif MoveFromPlayerToChest(ItemToPlace1) || MoveFromPlayerToChest(ItemToPlace2) elseif MoveFromPlayerToChest(ItemToPlace3) || MoveFromPlayerToChest(ItemToPlace4) elseif MoveFromPlayerToChest(ItemToPlace5) || MoveFromPlayerToChest(ItemToPlace6) endif endif ; update the display static if IsInChest(ItemToPlace1) || IsInChest(ItemToPlace2) || IsInChest(ItemToPlace3) getLinkedRef().enable() elseif IsInChest(ItemToPlace4) || IsInChest(ItemToPlace5) || IsInChest(ItemToPlace6) getLinkedRef().enable() else getLinkedRef().disable() endif EndEvent bool Function IsInChest(Form item) return item && EE_DisplayMasterChest.getItemCount(item) > 0 EndFunction bool Function MoveFromChestToPlayer(Form item) if IsInChest(item) EE_DisplayMasterChest.removeItem(item, 1, false, PlayerRef) return true endif return false EndFunction bool Function MoveFromPlayerToChest(Form item) if item && PlayerRef.getItemCount(item) > 0 PlayerRef.removeItem(item, 1, false, EE_DisplayMasterChest) return true endif return false EndFunctionThat still assumes you have an activator (with the script) for each item you want to place and a (potentially) shared storage container. It's also limited to no more than 6 versions of the object. A single activator that could be used to store and retrieve an entire set of things like all of the black books, dragon priest masks, or a particular set of armor (that you have found so far) is more complicated, especially if some of the items are leveled like the ones this script is designed to handle. The biggest complication is deciding what action to take if the player holds some of the items and others are already on display. Frankly, if you're giving the player access to individual activators and also to the shared container it would be far easier to create a container script that uses the individual activator scripts when the player adds or removes items from the container. Here are truly generic versions of the activator script and container script that could be used for a collectionof items. Reveal hidden contents First, here is the array version of the activator script that optionally allows you to set a property instead of the linked ref. (If the property isn't set the linked ref will still be used.) ScriptName ItemDisplay_ActivatorScript extends ObjectReference {Generic ItemDisplay script for an activator object that stores an item (or one of a set of leveled items) in a master container and displays a matching static version in the world.} Actor Property PlayerRef Auto ObjectReference Property MasterContainer Auto {The container (possibly shared with other activators) that will hold the real items.} ObjectReference Property ItemToDisplay Auto {The display item to be enabled or disabled. If not filled, the reference linked in the CK will be used instead.} Form[] Property ItemToPlace Auto {An item (or group of leveled items) that can be stored in the container and displayed.} Event OnActivate(ObjectReference akActionRef) {Exchange item between player and MasterContainer (on player activation) and always sync display with contents of MasterContainer. Is activated by MasterContainer to force the display sync if player adds or removes the item without using the activator.} if akActionRef == PlayerRef && MasterContainer && ItemToPlace bool searching = true ; first if it is already in the container try to move it to the player int i = ItemToPlace.Length while i > 0 && searching i -= 1 if MasterContainer.GetItemCount(ItemToPlace[i]) > 0 MasterContainer.RemoveItem(ItemToPlace[i], 1, false, PlayerRef) searching = false endif endwhile ; if not, check to see if the player is carrying it and move it to the container i = ItemToPlace.Length while i > 0 && searching i -= 1 if PlayerRef.GetItemCount(ItemToPlace[i]) > 0 PlayerRef.RemoveItem(ItemToPlace[i], 1, false, MasterContainer) searching = false endif endwhile endif ; update the display version (if any) if !ItemToDisplay ItemToDisplay = GetLinkedRef() endif if ItemToDisplay bool shouldHide = true int i = ItemToPlace.Length while i > 0 && shouldHide i -= 1 if MasterContainer.GetItemCount(ItemToPlace[i]) > 0 shouldHide = false endif endwhile if shouldHide ItemToDisplay.Disable() else ItemToDisplay.Enable() endif endif EndEvent bool Function CanDisplayItem(Form akBaseItem) {Can the item be displayed by this activator? Used by the MasterContainer.} int i = ItemToPlace.Length while i > 0 i -= 1 if ItemToPlace[i] == akBaseItem return true endif endwhile return false EndFunction Here's a version of a matching master container script optionally won't allow the player to store items that don't match something one of its activators can't display.ScriptName ItemDisplay_MasterContainerScript extends ObjectReference {Generic ItemDisplay script for a container object that stores items and is linked to activators which display matching static versions based on what is in the container.} Actor Property PlayerRef Auto ItemDisplay_ActivatorScript[] Property DisplayActivator Auto {The activators that are using this as their container.} bool Property AllowOnlyDisplayableItems = false Auto {Defaults to false, but if set to true container will return any items that can't be displayed by one of its activators.} Event OnActivate(ObjectReference akActionRef) if akActionRef == PlayerRef && DisplayActivator while !Utility.IsInMenuMode() Utility.WaitMenuMode(0.1) ; wait for container to open endwhile Utility.Wait(0.01) ; and then close again ; now signal all of the activators to update their matching display items int i = DisplayActivator.Length while i > 0 i -= 1 DisplayActivator[i].Activate(self) endwhile endif EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) {Ensure nothing is stored in this container that can't be displayed by one of the activators (if configured).} if AllowOnlyDisplayableItems && akSourceContainer bool mustGiveBack = true if DisplayActivator int i = DisplayActivator.Length while i > 0 && mustGiveBack i -= 1 if DisplayActivator[i].CanDisplayItem(akBaseItem) mustGiveBack = false endif endwhile endif if mustGiveBack RemoveItem(akBaseItem, aiItemCount, true, akSourceContainer) endif endif EndEventI haven't actually run these, but I did at least compile them this time. Link to comment Share on other sites More sharing options...
thejadeshadow Posted December 14, 2014 Author Share Posted December 14, 2014 I've set up this last script you mentioned, the array, but the only property I don't understand is the ItemToDisplay formlist on ItemDisplay_ActivatorScript. I can't drop and drag forms into it... the only things it will let me put in are "CommanderActorPersistanceForm" and "Papyrus Persistance Form". Shouldn't I be able to assign the object reference or a form I want them to place? Edit: Also, I assume with this script, the user "has" to put the item into the master container for it to display? Because right now with my errored Bool Function script I posted above, the player clicks on on activator and it automatically removes the item from the player's inventory to sort it. Link to comment Share on other sites More sharing options...
cdcooley Posted December 15, 2014 Share Posted December 15, 2014 Yes, you should be able to add any item into the ItemToDisplay list. I've never even seen the two things you mention. Maybe someone else has an idea whats happening with that. The CK seems to be having trouble creating a complete list of form items. As a workaround you can change the type on that script from Form to Armor (or Weapon, Potion, etc.) and recompile, then add items in the CK, and then change the type back to Form and recompile again before loading the game. Once the ItemToDisplay values are filled correctly clicking on the activator should trigger the swap between the player and master container. Link to comment Share on other sites More sharing options...
thejadeshadow Posted December 15, 2014 Author Share Posted December 15, 2014 Hey, you are right cdcooley...If I replace the "Form" word with "SoulGem", I get a list of soulgems to place in the property instead of...nothing. So do I need a new script for each property type (weapon, armor, soulgem, miscitem etc)? Or is there a way to keep this all in one script?Form[] Property ItemToPlace Auto {An item (or group of leveled items) that can be stored in the container and displayed.}SoulGem[] Property ItemToPlace Auto {An item (or group of leveled items) that can be stored in the container and displayed.} Link to comment Share on other sites More sharing options...
thejadeshadow Posted December 15, 2014 Author Share Posted December 15, 2014 Oh...figured it out. It should say "Formlist" not "Form". Not it is letting me set all the forms as properties. Nice :smile: Or I can set it as individual properties as well, of course. Edit: Ah, setting individual properties would bring a whole host of changes I'd need to make. I'll see if I can just set up formlists for each item. Edit: If I set it as SoulGem property, and set the specific item, and then change it back to Formlist...it does not work. I think it reverts to None after I switch it back to Formlist. Link to comment Share on other sites More sharing options...
thejadeshadow Posted December 15, 2014 Author Share Posted December 15, 2014 After some more testing, it's only when I change formlist to "armor" or "weapon" properties etc that the script will work properly. if I use a formlist (my own or the game's premade forms), the item won't display properly, come out of my inventory or go to the master chest. Sorry for all the nagging. This seems to go on and on. But...can this script be expanded to include the main 7 types of properties? Or do you have any other advice? This script is exactly what I have been looking for for years. I love it. Just so close! ArmorWeaponMiscObjectBookSoulGemAmmoPotion Link to comment Share on other sites More sharing options...
Recommended Posts