Difference between revisions of "Talk:GetEquipmentSlot"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Babij
(Example code)
 
imported>Babij
m (fixed my formatting)
Line 1: Line 1:
Hmm... I wasted a several hours on this damn function. I was writing a script to get a companion character to wear certain clothing depending on particular circumstances. Long story short, I wanted my guy to loop through his inventory and put on a pair of shoes. I finally got the damn thing to work using the following code:
Hmm... I wasted a several hours on this damn function. I was writing a script to get a companion character to wear certain clothing depending on particular circumstances. Long story short, I wanted my guy to loop through his inventory and put on a pair of shoes. I finally got the damn thing to work using the following code:
<nowiki>
<br><br>
short InvPos
<pre>
ref pInvObj
short InvPos
set InvPos to 0
ref pInvObj
Label
set InvPos to 0
set pInvObj to (GaroWorldRef.GetInventoryObject InvPos)
Label
if pInvObj
set pInvObj to (GaroWorldRef.GetInventoryObject InvPos)
set InvPos to (InvPos + 1)
if pInvObj
 
  set InvPos to (InvPos + 1)
;if (pInvObj.GetEquipmentSlot == 5)
  ;if (pInvObj.GetEquipmentSlot == 5)
if(GetEquipmentSlot pInvObj == 5)
  if(GetEquipmentSlot pInvObj == 5)
GaroWorldRef.EquipItem pInvObj
    GaroWorldRef.EquipItem pInvObj
message "I put on my shoes"
    message "I put on my shoes"
endif
  endif
  Goto
Goto
endif
endif</nowiki>
</pre><br><br>
 
The key line of course is ''if(GetEquipmentSlot pInvObj == 5)''. Note the commented out line above it, which is apparently incorrect code, and will always return 0. Probably has something to do with my confusion between references and objectIds, but I figured I'd post this up in case anyone else has this problem.
The key line of course is ''if(GetEquipmentSlot pInvObj == 5)''. Note the commented out line above it, which is apparently incorrect code, and will always return 0. Probably has something to do with my confusion between references and objectIds, but I figured I'd post this up in case anyone else has this problem.

Revision as of 08:13, 20 July 2010

Hmm... I wasted a several hours on this damn function. I was writing a script to get a companion character to wear certain clothing depending on particular circumstances. Long story short, I wanted my guy to loop through his inventory and put on a pair of shoes. I finally got the damn thing to work using the following code:

short InvPos
ref pInvObj
set InvPos to 0
Label
set pInvObj to (GaroWorldRef.GetInventoryObject InvPos)
if pInvObj
  set InvPos to (InvPos + 1)
  ;if (pInvObj.GetEquipmentSlot == 5)
  if(GetEquipmentSlot pInvObj == 5)
    GaroWorldRef.EquipItem pInvObj
    message "I put on my shoes"
  endif
  Goto
endif



The key line of course is if(GetEquipmentSlot pInvObj == 5). Note the commented out line above it, which is apparently incorrect code, and will always return 0. Probably has something to do with my confusion between references and objectIds, but I figured I'd post this up in case anyone else has this problem.