ZombicideII Posted July 8, 2018 Share Posted July 8, 2018 Hello, I was wondering if anyone could help me edit this script I have to make it functional...and a few others. If a form list is easier I will do so. I am an absolute beginner when it comes to scripting so I'm not sure the method I chose is easiest. I left out scriptname and extends on purpose. I don't want to give away the script just yet (even though most of you can recreate it with ease). I'm wanting to check the item count in the player inventory, and if it is greater then or equal to 1, it gets moved into a container reference. The way the script is now, it doesn't compile. I'm sure it's an easy fix, I'm just not sure what to fix. I tried to follow the wiki for Papyrus as best as I could, I'm missing key terms... ObjectReference Property akActionRef ObjectReference Property akOtherContainer Const MiscObject Property akItem Const Event OnActivate(ObjectReference akActionRef) ;Item if (Game.GetPlayer().GetItemCount(akItem) == 0) Debug.Trace("Player doesn't have ...") else if (Game.GetPlayer().GetItemCount(akItem) >= 1) Game.GetPlayer().RemoveItem(akItem, int aiCount = 1, bool abSilent = false, ObjectReference akOtherContainer = None) EndIf EndEvent Link to comment Share on other sites More sharing options...
Magicockerel Posted July 8, 2018 Share Posted July 8, 2018 (edited) When asking for help with getting a script to compile, people typically need to know the error you're getting, and the full script. Still, it's likely that there error is that you've separated "ElseIf" into two lines, such as: If () ElseIf() EndIfYou'll also want to assign the properties at least an "Auto" flag, you can read about them here. I'm not sure why you're defining event and function parameters as properties, akActionRef and akOtherContainer, so I'd remove them. You've also defined the parameter type when calling the function, which you can't do. At most write out the parameter names.This should help you out some: ; I use the Auto Hidden flags if I'm altering the property via script ; You won't be able to edit the property if it has the Const flag, as that holds the property constant ; If you're setting the value of the property via the property window, I'd use the Auto Const Mandatory flags ; How have you set the akItem property? MiscObject Property akItem Auto Hidden Event OnActivate(ObjectReference akActionRef) ; akItem is a parameter of the GetItemCount() function ; If you haven't assigned the property anywhere outside of this script then it's holding a NONE value ; If you've just defined the akItem parameter as a property like the others, then remove it ; You'll have to set the item somewhere though, whether it's from this script or another If (Game.GetPlayer().GetItemCount(akItem = akItem) == 0) ; This text will only show in logs if you have tracing enabled Debug.Trace(asTextToPrint = "Player doesn't have ...") ElseIf (Game.GetPlayer().GetItemCount(akItem = akItem) >= 1) ; You don't define parameter type in the function itself, just the parameter name, and even then only if you feel like it Game.GetPlayer().RemoveItem(akItemToRemove = akItem, aiCount = 1, abSilent = false, akOtherContainer = None) EndIf EndEvent Edited July 8, 2018 by KernalsEgg Link to comment Share on other sites More sharing options...
Hoamaii Posted July 8, 2018 Share Posted July 8, 2018 KernalsEgg is correct. I would only add a few notes:1. As it is, your script will remove the object from the player's inventory, but it'll never be transferred to another container as you mention in your post because you did not define that other container. You need to define it like this: Container Property MyOtherContainer Auto 2. akItem and akActionRef are functions parameters, for the sake of clarity and security, it's better that you give your properties other names than these universal paramaters, something that will be easier to find in the CK and which tells you you're the only one who has modified or created these assets, like "Zomb_ItemToRemove" and "Zomb_HoldingContainer" for instance. Give them a keycode name that'll be only yours if you see what I mean. 3. akActionRef is, like I said, a parameter, and it's usually (but not always) an actor, referring to the form which activates your scripted form. If in your script, your container is meant to be activated by the player for the item to be transferred, I would go as simple as that: MiscObject Property Zomb_ItemToRemove Auto Container Property Zomb_HoldingContainer Auto Actor Property PlayerRef Auto Event OnActivate(ObjectReference akActionRef) If akActionRef == PlayerRef ; This prevents the item to be removed from the player in case something else activates your object If PlayerRef.GetItemCount(Zomb_ItemToRemove) >= 1 PlayerRef.RemoveItem(Zomb_ItemToRemove, 1, false, Zomb_HoldingContainer) Debug.Notification("Player has the item, item transferred to cntainer") Else Debug.Notification("Player doesn't have the item to remove") EndIf EndIf EndEvent A few more things: 1. you don't really need to define your "If PlayerRef.GetItemCount(Zomb_ItemToRemove) == 0, if it is not >= 1, the only possibility left is it is equal to zero anyway. 2. If you're new to scripting, I'd go with Debug.Notification("...") rather than trace, it just makes it easier to know what's going on instantly in game when you're testing your script. 3. again, if you're new to scripting, I wouldn't bother with auto, or const, or conditional properties just yet, just try to understand how basic scripts work, then you'll get to it. Link to comment Share on other sites More sharing options...
payl0ad Posted July 8, 2018 Share Posted July 8, 2018 Shouldn't the Container be an ObjectReference type? Container is the base type but the actual container in the game is an ObjectReference. Link to comment Share on other sites More sharing options...
ZombicideII Posted July 8, 2018 Author Share Posted July 8, 2018 (edited) As I said, complete beginner with scripting, when reading Wiki help about, it made sense reading it but, not how to set it up. I was referring off of other scripts and how they were set up and this one became a jumbled mess. I'm trying to leave the properties as a blank ref so i know what term is what and how it's suppose to function. I will fill in personal reference later (I did this in another script of mine). I will try this out in the CK. If I was trying to sort multiple objects into multiple containers, is a form list easier? Edited July 8, 2018 by ZombicideII Link to comment Share on other sites More sharing options...
ZombicideII Posted July 8, 2018 Author Share Posted July 8, 2018 (edited) Container Property akOtherContainerMiscObject Property akItemActor Property PlayerRef Event OnActivate(ObjectReference akActionRef);ItemIf akActionRef == PlayerRef;This prevents the item to be removed from the player in case something else activates your objectIf PlayerRef.GetItemCount(akItem) >= 1PlayerRef.RemoveItem(akItem, 1, false, akOtherContainer)Debug.Notification("Player has the item, item transferred to cntainer")ElseDebug.Notification("Player doesn't have the item to remove")EndIfEndEvent No compile, error received (5,10): mismatched input 'Property' expecting FUNCTION <-- I knew this was a big error but, wasn't sure which line was the function.(0,0): error while attempting to read script ...Script: Object reference not set to an instance of an object. If akItem refers to GetItemCount. What parameter/property refers to the item I want to remove? I tried inputting an item instead of zomb_ItemToRemove and still recieved the compile error. Sorry about the coding, the box bugged out on me Edited July 8, 2018 by ZombicideII Link to comment Share on other sites More sharing options...
Hoamaii Posted July 8, 2018 Share Posted July 8, 2018 You need to add "Auto" after each property, like I did, so that the script knows what its functions are pointing to, and fill the property tab afterwards. Or else papyrus expects a function - thus the error. Should be: Container Property Zomb_Container AutoMiscObject Property Zomb_MyObject AutoActor Property PlayerRef Auto Please, do yourself a favour, do not use universal parameters like akActionRef or akContainer as properties - I assure you this will lead you to a lot of errors. Give them UNIQUE names. The property which refers to the item you want to remove is your Zomb_MyObject Property. And yes, the container could be an objectReference, it depends on how you want to use that script. If you place many containers instances in the world you want to attach your script to the base form, if there's only one instance in the world and you want to move your item into that container, then use the placed ObjectReference as property. Zombicidell, there are plenty of beginners scripting tutorials on YouTube, wathc a few of them, that'll help you understand what is what and what it all means ;) Link to comment Share on other sites More sharing options...
ZombicideII Posted July 9, 2018 Author Share Posted July 9, 2018 I feel dumb kind of dumb about the parameters, it makes PERFECT sense now. I pondered it while at work and the script, and realized what all of you meant by it. I rewrote the script and it compiled perfectly. However, for whatever reason the mesh I'm using as a Container, doesn't act like a container in game. There is no activation to it. I know it's not the script as it was like that before I had the script on there. Any idea why it's like that? Link to comment Share on other sites More sharing options...
Hoamaii Posted July 12, 2018 Share Posted July 12, 2018 What mesh are you using? Link to comment Share on other sites More sharing options...
ZombicideII Posted July 12, 2018 Author Share Posted July 12, 2018 It was a custom mesh, I just ended up using another. Link to comment Share on other sites More sharing options...
Recommended Posts