CakeBandit Posted July 1, 2017 Author Share Posted July 1, 2017 That's because your self, in that script, is the ReferenceAlias. RemoveItem is expecting a Form, which nearly everything has as a base type; ReferenceAliases are one of the few exceptions. The Form you plug into the first parameter is the item that should be removed, the second parameter is how many of that to take out. If this script is attached to an alias pointing at the note, you want to use "PlayerRef.RemoveItem(Self.GetReference().GetBaseObject(), 1)" instead, or, alternatively and probably a better option, store the base form in a property and use that. That seems to have gotten it to compile, thank you, but the note is not getting removed when I read it nor is the NPC being placed. It seems that the on Read Event isn't working... though maybe I set up the script wrong. Do you just add the script to the item you want it to work for? Is there a certain property I need to set? Link to comment Share on other sites More sharing options...
CakeBandit Posted July 2, 2017 Author Share Posted July 2, 2017 I found the issue, I had to use ObjectReference instead of ReferenceAlias and Game.GetPlayer() instead of assigning it to a variable which didn't work for some reason. I also could not get the item removing to work using Self or Self.GetBaseObject() (GetReference doesn't seem to work with ObjectReference). I made another property for the item and had that get removed instead and was able to get that to work. Link to comment Share on other sites More sharing options...
foamyesque Posted July 2, 2017 Share Posted July 2, 2017 Okay, it sounds like you don't have a solid grasp on how scripts get attached. So, in the header of a script, there's an "extends" line. That means that whatever script you write has access to all the functions and events and properties of whatever script it extends (and any script that extends, and so on), but it also means you can only have it work correctly if you attach it to an item of that type. For practical purposes, the three major things your scripts will extend will be ObjectReferences, ReferenceAliases, and Quests. Stuff that extends ObjectReferences can be added either to the base form -- in which case every reference of that form in the game will now have your script -- or to specific references via the cell editors, in which case only that reference will have that script. The properties of those scripts can be set independently on each reference in either case, so the behaviour can be customised as needed. Scripts that extend Quests are attached to the Quest as a standalone script or through stage fragments. You can have the same script attached to multiple quests, with independent properties, but it's much less common than with ObjectReferences or ReferenceAliases, since Quest scripts are generally unique. Scripts that extend ReferenceAlias will only function when attached to a ReferenceAlias through a Quest's Alias tab. Multiple aliases can and often will use the same scripts (usually only within a particular quest, but not always). Again, the properties can be set independently on each, if desired. From your description of the problem it would seem to me that you tried to attach your original ReferenceAlias script to the base object. That would fail. Changing it to ObjectReference would solve that, but because by doing so you change what functions, etc you can inherit from the script object you're extending, you lose access to ReferenceAlias- and Alias-specific functions, of which GetReference() is one. You can assign the player to a variable through Game.GetPlayer() or you can create a property for it, and assign that through the property interface. In general Game.GetPlayer() is preferred. Simply declaring a variable or property is not enough, in Skyrim, to fill it with anything. You must explicitly give it a value, or it will default to none, false, zero, "", etc Link to comment Share on other sites More sharing options...
irswat Posted July 2, 2017 Share Posted July 2, 2017 you need to fill the properties in creation kit Link to comment Share on other sites More sharing options...
Recommended Posts