Get an item count from a container?

Post » Sat Nov 17, 2012 12:56 am

Okay... It's probably something really simple, but I have been trying to get an item count from a referenced container using the getitemcount command. Everything appears as if it should work, but it doesn't. I'll attach my script and see if you guys can tell me what I'm doing wrong. Take note the reference is a barrel that I have attached as a linked ref to a pull chain.

Scriptname JTTestScript001 extends ObjectReference{Please work...}import Debugint GoldOreCountint GoldBarCountObjectReference Property JTTestKeyword001 AutoMiscObject Property OreGold AutoMiscObject Property IngotGold AutoEvent OnActivate(ObjectReference akActionRef)if akActionRef == Game.GetPlayer()  GoldOreCount = (JTTestKeyword001.GetItemCount(OreGold))  debug.Notification(GoldOreCount)  if GoldOreCount > 2      SmeltGold()  endifendifEndEventFunction SmeltGold()GoldBarCount = GoldOreCount/2JTTestKeyword001.AddItem(IngotGold, GoldBarCount, true)JTTestKeyword001.RemoveItem(OreGold, GoldOreCount, true)EndFunction
User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Fri Nov 16, 2012 5:28 pm

Did you make sure to resolve your properties to the objects your properties are pointing to in the Creation Kit?

Edit: Also you've imported Debug at the top; you don't need to declare it any longer throughout the script, so debug.notification can just be notification.

Edit2: You have an ObjectReference property with the name Keyword... that may get confusing later.
User avatar
Beast Attire
 
Posts: 3456
Joined: Tue Oct 09, 2007 5:33 am

Post » Sat Nov 17, 2012 12:22 am

1. I did resolve the properties and it works when I use World.GetPlayer().GetItemCount(GoldOreCount)
2. Thanks!
3. Agreed, but this is just a testing script and testing references, after I apply the actual script I will be rewriting all references with more obvious names, as the script will be much much longer.

*Edit* Correction, I had forgot to resolve the properties for the reference :o It works now, thanks so much for you help!
User avatar
Hayley Bristow
 
Posts: 3467
Joined: Tue Oct 31, 2006 12:24 am

Post » Fri Nov 16, 2012 8:49 pm

-- DELETED --
User avatar
Robert Bindley
 
Posts: 3474
Joined: Fri Aug 03, 2007 5:31 pm


Return to V - Skyrim