Jump to content

[LE] Scripting issue creating & using a Container object (can't add item and maybe I don't have to)


Tenor1411

Recommended Posts

So I am trying to add a lower level light armor version of the Boots of Muffling. The earliest light armor version one can get is the glass one at level 37. I've created a hide version and have been able to add it to the appropriate leveled lists on game load (so as not to interfere with other mods) using the script from Bert's Bits and Bobs but my concern is that looking up the vanilla boots I see they are all in a container called QAEnchantedArmorContainer. To make sure my boots work correctly I have been trying to add them to this container via the same script.

 

Here is the code snippet for object instantiation:

Container Property Chest01 Auto

And here is the call to that object:

Chest01.AddItem(myBoots, 1)

The way this script works is that it's attached to an object in a game cell, in this case a rock just outside Riverwood. The script is attached to the rock via the CK which passes the leveled list and container names to the script as a variable. The problem I'm having is that the script won't compile. The error I get is:

AddItem is not a function or does not exist

So obviously I'm using the container object incorrectly, my question is two-fold: Firstly, do I even need to add it to this container for it to work or is just adding it to the leveled list enough? Secondly, if I do need to add it to the container how would I go about doing that? All my searches either bring up adding it via the CK instead of scripting (which completely defeats the purpose of the script), or simply mentions adding it to a leveled list which I've already done. Nothing I've found actually explains what functions a container object can use.

 

I'm hoping the answer to my first question is no since it would mean less work for me, but if it is yes then any help would be appreciated.

Link to comment
Share on other sites

instead of

Container Property Chest01 Auto

use that

ObjectReference Property Chest01 Auto  ; fill with CK

and for the boots, you could use next part, if needed

LeveledItem Property myBoots Auto     ; fill with CK

You asked: "..adding it to the leveled list enough?" YES

Edited by ReDragon2013
Link to comment
Share on other sites

Tenor: Your problem is that Containers are a type of Form, which can be thought of as the prototype of all the ObjectReferences you see in the world. It defines common properties.Stuff you can change individually, in world, is almost always part of the ObjectReference branch of trees.

So the way it works is a single given chest in the world is an ObjectReference with a base object type of Container. AddItem() is an ObjectReference function, and doesn't exist on generic Forms or on the Container subtype of Form, which is why the compiler is complaining at you.

This page lays things out in a tree form, which might help you: https://www.creationkit.com/index.php?title=Category:Script_Objects

Link to comment
Share on other sites

You asked: "..adding it to the leveled list enough?" YES

 

Well that solves 90% of my problem and the other 10% is made completely moot, at least insofar as this particular issue. Many thanks!

 

 

Tenor: Your problem is that Containers are a type of Form, which can be thought of as the prototype of all the ObjectReferences you see in the world. It defines common properties.Stuff you can change individually, in world, is almost always part of the ObjectReference branch of trees.

So the way it works is a single given chest in the world is an ObjectReference with a base object type of Container. AddItem() is an ObjectReference function, and doesn't exist on generic Forms or on the Container subtype of Form, which is why the compiler is complaining at you.

This page lays things out in a tree form, which might help you: https://www.creationkit.com/index.php?title=Category:Script_Objects

I see my mistake now. I thought addItem was inherited into Container from Forms when it doesn't exist at all. That reference tree will help me for future things I'm sure. Many thanks!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...