Feliks Posted September 8, 2015 Posted September 8, 2015 So I'm polishing up some weird code but I've ended up in this situation: I use code (or a magic effect in an older stupider version) to add an item (armor) to an actor. This item sits hidden in the inventory and runs it's own code over time. If I need a bit of code to run right away so another code can keep track of all these little items what's the best way to do that? I wanted to use an OnInit() event in the armor script, but I have no idea when that would run outside of a quest. My assumption would be whenever the item is created, and for now that's how I'm going to handle it in the code. This is mainly important because I'm using a sneaky workaround (demonstrated by jbezorg, kind of, in a thread somewhere around here) to store these items in an array in a framework-type script and using that to point to the separate instances of the scripts. Obviously it's kind of important to keep track of which item is which. Any help or guidance here would be greatly appreciated as every example of OnInit() I can find is in the context of a quest.
Feliks Posted September 8, 2015 Author Posted September 8, 2015 Followup question because I've organized this poorly, how would you go about finding the actor who currently possessed an item the script was attached to from within that script?
sen4mi Posted September 10, 2015 Posted September 10, 2015 Followup question because I've organized this poorly, how would you go about finding the actor who currently possessed an item the script was attached to from within that script? That is tricky, because items in inventory do not exist. Instead, they are references in a list on the actor. So you either need to inspect the actors, or tie into whatever event or circumstance that placed the item in inventory in the first place (which does not really exist for leveled lists, if I understand them properly). And that (along with performance requirements - if you do too much processing you crash the game) leads to frameworks like sexlab which have been tuned to do a decent job of scanning nearby actors.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.