Dahveed Posted April 16, 2021 Share Posted April 16, 2021 Hello, I'm trying to add a new item to a (hidden) chest which sort of keeps track of an NPC's loot that she'll collect in the game. This happens during a dialogue event in the game. I basically say "you keep this garnet" and then she'll say "ok fine" and then a garnet will appear in her private chest (not her inventory, so I can't just trade it back). This seems like an easy thing to accomplish in theory but I have very little clue about how to script. Everyone always explains things to me like everything is super-obvious, i.e. like I've already been scripting for 14 years. I don't know how to define variables or anything. I just want to be able to be like, NPCchest.additem garnet(1) or something, in the little script box at the bottom right side of the dialogue screen. But nothing I've found online and no explanations work. 99% of scripting tutorials out there are just godawful and don't teach newbies as though they were newbies, but as though they were already seasoned programmers who do this for a living. So, the name of my chest is called _DOM_BrownieCounterChest and I want to add a garnet to it at the end of this dialogue line. I've added it as a property in the quest's "scripts" section as a container, and I've called the property "DomGiftChest". But now I'm stuck. No matter what I do the script won't compile, keeps giving me weird errors that might as well be in Chinese. I never would have thought something so simple - putting a thing into a container - could possibly be this complicated and mystifying. No wonder Bethesda games are so full of bugs... Thanks in advance for any help Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted April 16, 2021 Share Posted April 16, 2021 A few terminology problems: the property for the chest needs to be on the script that will use the chest, not on the quest script. Also, you don't "call" properties, you "define" them. (As they are special kind of public variables, not functions). That's just wording of course, but it might help understand since you wrote you have some problems with that. :) A short explanation of why we need properties: a property is just like any variable on a script, a piece in the computer's memory that stores some data that you can manipulate and use. It has a type, so we know what kind of data it is. What we don't know, is what it is exactly. When you compile the code, all we know is that we have a variable of this type.This is what Auto means at the end of your properties: it means that their value is decided when the game actually runs, and you set this starting value with the creation kit in the properties window. This is how you make the script use your exact item you made in the CK (or just a vanilla item if that's what you want).Also, properties are public so can be accessed by other scripts and the CK. So in the dialogue script, bottom right box, just input a comment ;-sign, compile, script will show up. Select that for properties, and add your chest, and also the item you want to add. The type for the chest is ObjectReference, and for the item, that depends on how you store it. If this dialogue is specific to gems, then it's probably a MiscObject. Okay, so after your properties are set up, the code just needs to be: DomGiftChest.AddItem( Garnet, 1 ) where again, you have an ObjectReference DomGiftChest property set up to the container, and a MiscObject Garnet property set to the garnet or gem or whatever. In the future, you might want to change this from specific-item-dialogues to opening the gifting menu window like during regular trading. If you want to do that, I can give an example for that as well. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 16, 2021 Share Posted April 16, 2021 To further add, if this garnet is being given by the player and the dialog option is conditioned to only appear if the player has 1 or more garnets. You could do the following: Game.GetPlayer().RemoveItem(Garnet,1,true,DomGiftChest)This will take one garnet from the player and transfer it to the designated container. But using the gift menu or the inventory menu to hand them the stuff would be ideal. The player can give more items or as many of an item as they wish. If you know what items you want the NPC to store in their loot chest, you can put a script on an quest's reference alias that is pointing to the NPC. On that script you would use the OnItemAdded event and compare the incoming akBaseItem against a formlist containing all the desired items. Link to comment Share on other sites More sharing options...
Dahveed Posted April 16, 2021 Author Share Posted April 16, 2021 Thanks guy, I'll pop open the hood again. yes, @IsharaMeradin that is exactly how my little quest works, there will only be certain gift items that work and the dialogue is conditioned for these items. That part I have figured out, that way she has a reaction to each specific item in dialogue. for example with the garnet, it's a cheap gem so she's like "I don't want this junk" (but takes it anyway XD) then a separate script will put gold in her chest ("brownies"), so the number of gold in that chest will tell me what the player's relationship score is. I use this gold amount to determine conditions for other dialogue options later. Link to comment Share on other sites More sharing options...
Dahveed Posted April 16, 2021 Author Share Posted April 16, 2021 A few terminology problems: the property for the chest needs to be on the script that will use the chest, not on the quest script. Also, you don't "call" properties, you "define" them. (As they are special kind of public variables, not functions). That's just wording of course, but it might help understand since you wrote you have some problems with that. :smile: A short explanation of why we need properties: a property is just like any variable on a script, a piece in the computer's memory that stores some data that you can manipulate and use. It has a type, so we know what kind of data it is. What we don't know, is what it is exactly. When you compile the code, all we know is that we have a variable of this type.This is what Auto means at the end of your properties: it means that their value is decided when the game actually runs, and you set this starting value with the creation kit in the properties window. This is how you make the script use your exact item you made in the CK (or just a vanilla item if that's what you want).Also, properties are public so can be accessed by other scripts and the CK. So in the dialogue script, bottom right box, just input a comment ;-sign, compile, script will show up. Select that for properties, and add your chest, and also the item you want to add. The type for the chest is ObjectReference, and for the item, that depends on how you store it. If this dialogue is specific to gems, then it's probably a MiscObject. Okay, so after your properties are set up, the code just needs to be: DomGiftChest.AddItem( Garnet, 1 ) where again, you have an ObjectReference DomGiftChest property set up to the container, and a MiscObject Garnet property set to the garnet or gem or whatever. In the future, you might want to change this from specific-item-dialogues to opening the gifting menu window like during regular trading. If you want to do that, I can give an example for that as well.I just did exactly what you said. I typed a ";" then compile, then brought up the properties window. I selected "objectreference" and called it BrownieChest I click okay to close the add property window, then the CK vomits this at me: Starting 1 compile threads for 1 files...Compiling "_DOM_TIF__070A2EB5"...F:\Skyrim Special Edition\Data\Source\Scripts\_DOM_TIF__070A2EB5.psc(3,0): missing SCRIPTNAME at 'ObjectReference'F:\Skyrim Special Edition\Data\Source\Scripts\_DOM_TIF__070A2EB5.psc(3,16): required (...)+ loop did not match anything at input 'Property'F:\Skyrim Special Edition\Data\Source\Scripts\_DOM_TIF__070A2EB5.psc(3,45): mismatched input '\\r\\n' expecting STATEF:\Skyrim Special Edition\Data\Source\Scripts\_DOM_TIF__070A2EB5.psc(0,0): filename does not match script name: objectreferenceNo output generated for _DOM_TIF__070A2EB5, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on _DOM_TIF__070A2EB5 And I have no idea what any of this means. In the properties window, I had "type" which I selected as ObjectReference (as you said) Beside that was a checkbox "array" which I left unticked. The "Name" was "BrownieChest" The Initial Value I left blank because I don't know what I would put there. I left "Hidden" unchecked because I don't know what that does. And Documentation String I also left blank, I don't know what that is either. Link to comment Share on other sites More sharing options...
Dahveed Posted April 16, 2021 Author Share Posted April 16, 2021 Also, now even after I delete the script and leave everything blank and close the dialogue quest entirely, then reopen it (scripts are blank), I can't even try to compile another empty ";" script without it saying: Starting 1 compile threads for 1 files...Compiling "_DOM_TIF__070A2EB5"...F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__070A2EB5.psc(3,0): missing SCRIPTNAME at 'ObjectReference'F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__070A2EB5.psc(3,16): required (...)+ loop did not match anything at input 'Property'F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__070A2EB5.psc(3,45): mismatched input '\\r\\n' expecting STATEF:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__070A2EB5.psc(0,0): filename does not match script name: objectreferenceNo output generated for _DOM_TIF__070A2EB5, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on _DOM_TIF__070A2EB5 Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted April 16, 2021 Share Posted April 16, 2021 I typed a ";" then compile, then brought up the properties window. There's the problem, sorry, I forgot to mention this piece. The CK is stupid and you need to work around it.You see, it only saves the source code for the created fragment script once you exit the topic window. Until you do that, the script only exists in the CK and not in a saved source, and you cannot attach properties to it. Also, since you did close then the window, now the half-broken source is there, and that's the reason now you can't even compile a comment. Go to your Scripts/Source folder (if you're in LE, I assume that from that this is the LE forum, otherwise in SE that'll be Sources/Script), and find the _DOM_TIF__070A2EB5.psc and delete it. Then you can start clear. So you have to type ;, hit compile, then OK the topic window. This is the missing part. Then you can reopen the dialogue again, and NOW you'll be able to add your property. Link to comment Share on other sites More sharing options...
Dahveed Posted April 16, 2021 Author Share Posted April 16, 2021 Ah yes, the CK being a douche. I've gotten used to that XD I'll try that and report back. Link to comment Share on other sites More sharing options...
Dahveed Posted April 16, 2021 Author Share Posted April 16, 2021 EUREKA! Good gods I was losing hope for a minute. I spent the last several days messing around with various scripts for different purposes and I was beginning to think my smooth-ass brain would never be able to compile a single bloody script. But it finally works! Please pat yourself on the back with the knowledge that you may have just helped me develop my follower's entire relationship level framework :) If I can use this same technique to add and remove gold to this chest, then that gold will become "currency" for tracking player interactions with my follower. Her dialogue will have GetItemCount gold (in my brownie points chest) as a condition for her responses. Noice! Thank you, thank you, thank you, THANK YOU!!! Link to comment Share on other sites More sharing options...
Dahveed Posted April 16, 2021 Author Share Posted April 16, 2021 Is it possible to add these properties more "globally" in the scripts section of the entire quest window? Or do I have to define these properties repeatedly for each individual dialogue option? Link to comment Share on other sites More sharing options...
Recommended Posts