What the...?
scn TestObjectref Containerref ObjectIDlong ItemCount ; let ItemCount := Container.GetItemCount ObjectIDlong FormTypefloat ItemHealth ; (health:float) reference.GetCurrentHealth - (nothing) reference.SetCurrentHealth nuHealth:floatfloat ItemCharge ; (charge:float) reference.GetCurrentCharge - (nothing) reference.SetCurrentCharge newCharge:shortref ItemOwner ; (owner:ref) reference.GetOwner - (nothing) referenced-item.SetOwnership Ownerstring_var RetStringBegin Function {Container, ObjectID, FormType} let RetString := "%e" ;let RetString := sv_Construct "Found at %n
" Container If (FormType == 33) ; Weapon - Breakable, Ownable, Charged let ItemHealth := ObjectID.GetCurrentHealth let ItemCharge := ObjectID.GetCurrentCharge let ItemOwner := ObjectID.GetOwner let ItemCount := Container.GetItemCount ObjectID let RetString := RetString + sv_Construct "
(W) %5.0f - %n's %n H %f, C %f" ItemCount ItemOwner ObjectID ItemHealth ItemCharge ElseIf (FormType == 20) ; Armor - Breakable, Ownable let ItemHealth := ObjectID.GetCurrentHealth let ItemOwner := ObjectID.GetOwner let ItemCount := Container.GetItemCount ObjectID let RetString := RetString + sv_Construct "
(A) %5.0f - %n's %n - H %f" ItemCount ItemOwner ObjectID ItemHealth EndIf SetFunctionValue RetStringEndI Looped over Player.GetItems 33 and Player.GetItems 20 in an OnActivate Block (surely the block doesn't matter here) and got all null values for GetCurrentHealth, GetCurrentCharge, GetOwner
I got errors for "Attempting to call a function on a NULL reference or base object."
With the existance of GetBaseItems, I assumed that GetItems returned references. Was I wrong? If so, is there a way to get the references?
Now let's review http://obse.silverlock.org/obse_command_doc.html on these functions.
Health
GetCurrentHealth - returns the current health of the calling reference
(health:float) reference.GetCurrentHealth
SetCurrentHealth - sets the current health of the calling reference
(nothing) reference.SetCurrentHealth nuHealth:float
GetEquippedCurrentHealth - gets the current health of the object in the specified equipment slot
(health:float) reference.GetEquippedCurrentHealth slot:short
SetEquippedCurrentHealth - sets the current health of the object in the specified equipment slot
(nothing) reference.SetEquippedCurrentHealth nuHealth:long slot:short
Charge
GetCurrentCharge - returns the current charge of the calling reference
(charge:float) reference.GetCurrentCharge
SetCurrentCharge - sets the current charge of the calling reference if it is less than or equal to the maximum charge
(nothing) reference.SetCurrentCharge newCharge:short
GetEquippedCurrentCharge - returns the current charge of the object in the specified slot
(charge:float) reference.GetEquippedCurrentCharge slot:short
SetEquippedCurrentCharge - sets the current charge of the object in the specified slot
(nothing) reference.SetEquippedCurrentCharge nuCharge:long slot:short
According to ShadeMe on http://www.gamesas.com/index.php?/topic/1005280-obse-syntax-base-objects-vs-refs/page__view__findpost__p__14545792:
-SNIP- ... getObjectHealth must be called on an inventory object, and on either a reference or a base record. Same for getCurrentHealth but it can't be called on a base object for obvious reasons. Also, active attributes of inventory objects ( like health and charge ) can only be accessed ( when in a container/inventory ) if it happens to be equipped. -SNIP-
If what ShadeMe says is true, why do the functions GetCurrentHealth, SetCurrentHealth, GetCurrentCharge and SetCurrentCharge exist? What are they for? How do I use them? My need's won't allow for equipping each item and using GetEquippedCurrentHealth, SetEquippedCurrentHealth, GetEquippedCurrentCharge and SetEquippedCurrentCharge.