Chris wrote:To accomplish what? Not being indignant, I'm just curious why you need the equipped item to be separate from the inactive ones, especially if it's just going to be re-stacked when unequipped and not store some kind of instance-specific state.
That's fine.
I'm making a mod. Part of it is that the PC can find special items. When the PC equips such an item a spell is added to it's list of known spells - when it's unequipped or
served it's purpose (conjuring a creature and more) the spell is removed.
When you have more than two instances of that item stacked in the PCs inventory you can not achieve that anymore because you can not address the equipped item to remove the spell (and itself). Instead the script on the item seems to be executed
twice per stack. IIRC Equipping sets "equipped" for the whole stack, not only the equipped item. OnPCEquip will return a wrong value in a circumstance that will occur often. When the spell is cast the active - and only the active item - shall do other things. This includes stack-distinct, own variable values. You can find an example where you can see from the MessageBox output that equipping an item causes the same message be shown twice.
like here: "Variables seem to have the same value at all instances?!"
viewtopic.php?f=2&t=3140
What I tried was to workaround this stacking problem by making only one active (the equipped) item exist at a time and manage it's work by using GetEffect and other functions for managing conversion from/to an active item. So there is an item_inactive(-stack) and a unique item_active. That specific instance can be addressed now.
A fix would be to make
all (stacked) instances execute the script separately, each having their own variables. The one that has
OnPCEquip == true could be addressed by this or a selfmade ID and do the tasks the one (the active, equipped) instance shall do. Of course OnPCEquip should only be true for the single equipped instance then.
Otherwise this is not possible.
Any instance is taken for executing the script. Even it you use OnPCEquip - out of 3 stacked items in the inventory - the script is only executed for some instance - lets say - number one and number two, but the equipped would be number 3… And even if it worked in one frame the engine may choose to use instance 1 for the next frame.
There is already a thread about this:
"scripting stacked items in container/inventory is a bad idea"
viewtopic.php?f=2&t=3192
The essence is:
Zini wrote:It all comes down to being compatible with the original engine. At least to my knowledge we are replicating it correctly here. We can look at the situation again after 1.0 but for now it is what it is.
A workaround would be to make like 30 unique items (different IDs) - all looking the same, having the same name and script. When an instance is found a global script is used to determine, if there is already another instance existing - e.g. ring a3 is in the PCs inv and a3 is found in the just opened container. If the instance in the container is unique the item can be taken, otherwise … well, if I think about it, you can not temporarily exclude items from levelled lists, right?
Apart from that it's a dirty solution, what should be done when the PC collects 31 items? It's not dynamic and the items have to do vice-versa checks (~ 30^2 - 31) - or at least a global script would have to do it - for 30 item-IDs. And 30 items would be shown in the inventory.
Another idea would be to give the modder access to the equipped item by using my_item_equipped - so the engine would provide access to the item my_item that is equipped by extending its ID. But this would be a special case again.
Please, just let each instance (stacked or not) execute it's script. The modder has to make sure that this doesn't lead to a mess.
This touches this topic somewhat:
viewtopic.php?f=2&t=3178
EDIT:
I can post the mod if you think it would help to see what I want to do, but it's only half done (e.g. conversation is done to 1%).