Greslin Posted April 21, 2011 Share Posted April 21, 2011 (edited) Okay, I give. I can't seem to find this anywhere, and it seems to me that it should be simple. Basically I'm trying to read/manipulate Moira's current cap count from within a script. Shouldn't I be able to do this: set MoiraCaps to VendorChestBuriedMoiraBrown.GetItemCount caps001 or maybe set MoiraCaps to VendorChestBuriedMoiraBrown.GetItemCount VendorChestCapsMedium .. and end up with her current caps? (My plan long term is to use additem/removeitem to change the count as well.) Thing is, when I try the above in the script, it kills the script cold. Nothing after that line runs. I'm not seeing a syntax error, and GECK isn't spitting any errors out - the game just hits that script line and seems to abort the rest of the script. Is what I'm trying to do even possible with this engine? I know the whole box respawns after three days - this is for something a bit different. Edit: Same thing happens when I attempt the GetItemCount caps001 from the MoriaBrown container, rather than the vendor chest. I'm obviously missing something really simple. Everything works fine if I do a player.GetItemCount, but it's not *my* caps I want a count of. :) Edited April 21, 2011 by Greslin Link to comment Share on other sites More sharing options...
Greslin Posted April 21, 2011 Author Share Posted April 21, 2011 I found a brief note about the Oblivion engine that suggests that doing an ItemCount with an invalid ObjectID counts as a return. That's explain the bounces. But aren't I using valid ObjectID's here? Link to comment Share on other sites More sharing options...
Tefnacht Posted April 21, 2011 Share Posted April 21, 2011 Hello. “VendorChestBuriedMoiraBrown” is a base object, not a reference. Container base objects do not actually contain any items. They are just a template that describes what a container looks like, what items (re-)spawn in it, what script is used and so on. The things that actually store items are references to this base object. If you drop the base object from the object window into the render window, a reference is created. You can have many, many container references all using the same base object, but they all can hold different items at any one time. Since a base object does not really contain any items, GetItemCount cannot return anything sensible. It is a little sad that the script compiler does not warn about this or simply returns 0 ... but it explains why the script silently dies. So instead of calling GetItemCount on the base object, you need to call it on the reference AND that reference must be a persistent one. In this case, we're in luck because vendor chests always need to be persistent and since its a vanilla resource it follows the Bethesda naming convention (meaning the reference has the same name as the base object with the letters REF added to the end). Set moiracaps To VendorChestBuriedMoiraBrownREF.GetItemCount Caps001should work just fine. I hope this helps. Link to comment Share on other sites More sharing options...
Greslin Posted April 21, 2011 Author Share Posted April 21, 2011 That worked perfectly. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts