Jump to content

ForceRefTo problem


Recommended Posts

Here is some code:

Function dz_check_item_in_inventory(Actor akActor,Form akItem,String type)
If akActor.GetItemCount(akItem As Form) == 0            ;is the item in the actor's inventory
  ;DEBUG_NOTIFY(akActor,akItem.GetName()+" is not in inventory")
  dz_outfits_msg_alias.ForceRefTo(akActor)
  dz_outfits_msg_alias2.ForceRefTo(akItem As ObjectReference)
  dz_outfits_msg28.Show()
  debug.notification(akItem.GetName()+" is no longer in the inventory for "+actor_name+", "+type+" outfit is incomplete.")
  ;akActor.Additem(akItem)              ;move the item to the actor's inventory
EndIf
EndFunction

both ref aliases dz_outfits_msg_alias and dz_outfits_msg_alias2 are set up correctly. The dz_outfits_msg28 has the text:

<Alias=dz_outfits_msg_alias2> is no longer in the inventory for <Alias=dz_outfits_msg_alias>

but no matter what I do the dz_outfits_msg_alias2 is only ever filled with the cooking pot that it is initially filled with in the alias tab in the quest in the CK. I know the aliases are set up right becasue if the function instead read:

dz_outfits_msg_alias2.ForceRefTo(akActor)
dz_outfits_msg_alias.ForceRefTo(akItem As ObjectReference)

then dz_outfits_msg_alias2 is properly filled with the passed in actor and the actors name displayed in the message.

I can only assume that I'm doing something wrong in forcing an aliasref to an objectreference that is not an actor, the passed in 'akItem' is a form.

Any suggestions?

 

 

diziet

 

 

Link to comment
Share on other sites

In your passed in form akItem, it must be an objectreference to force it into an alias. Problem is that object references lose their reference when they are in an inventory, unless the object reference is set as a script property. If you are passing in a base form for akItem, such as miscObject or Armor ect, you can do something like this:

 

ObjectReference Property EmptyCellRef Auto ;ObjectReference in an empty dummy cell

Function dz_check_item_in_inventory(Actor akActor,Form akItem,String type)
    If akActor.GetItemCount(akItem As Form) == 0            ;is the item in the actor's inventory
      ;DEBUG_NOTIFY(akActor,akItem.GetName()+" is not in inventory")
      dz_outfits_msg_alias.ForceRefTo(akActor)
      
      ObjectReference MessageRef = EmptyCellRef.PlaceAtMe(akItem, 1) ;place new ObjectReference of base form in empty cell.
      
      dz_outfits_msg_alias2.ForceRefTo(MessageRef)
      dz_outfits_msg28.Show()
      debug.notification(akItem.GetName()+" is no longer in the inventory for "+actor_name+", "+type+" outfit is incomplete.")
      Utility.Wait(1) ;wait till menu is closed 
      
      ;delete temp ObjectReference
      MessageRef.Disable() 
      MessageRef.Delete() 
      MessageRef = None 
      ;akActor.Additem(akItem)              ;move the item to the actor's inventory
    EndIf
EndFunction
Link to comment
Share on other sites

Ah, I see. Since the akitem comes from a formlist of items that were equipped on an actor and therefore in their inventory that is where the reference is lost. Thanks for your workaround. :smile:

 

diziet

 

edit: the dummy cell doesn't have to be actually empty does it? I already have a custom cell in the mod that holds a couple of items, it seems I could use that?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...