Jump to content

How to activate from the use of an item in inventory


Recommended Posts

Hi all,

 

I am looking for a way to use/cast something when I use an misc item in my inventory.

By now, the effet start when the item is picked up and nothing on the use from inventory.

 

I read some tuto and things here and there and understand that it seems the "activate" would be linked to the item type.

 

Today i am planning to use a trick in which i would equip/unequip to simulate that sort of use but it is not really what i am looking for.

 

Maybe somebody could help me with a way to get it working as intended ?

 

Can someone help me please ?

Edited by Chronepsys
Link to comment
Share on other sites

For anything not consumed when used from the inventory (i.e. not potions, poisons, food or ingredients), OnEquipped is the event used to listen for any "activation" attempts.

 

For example, my inventory management mod for SSE has a series of objects that the player carries in their inventory. When used, these objects open up a container that corresponds with their category. The script used is as follows, feel free to adapt to your needs.

 

 

Scriptname abim_IMS_SatchelEquipScript extends ObjectReference  
 
ObjectReference   Property  TheContainer  = None  Auto
Actor             Property  PlayerRef     = None  Auto
FormList          Property  abim_IMS_RepItemList  Auto
Int               Property  RepItemIndex          Auto
 
Event OnEquipped(Actor akActor)
  If akActor == PlayerRef
    Game.DisablePlayerControls(False, False, False, False, False, True) ; Exit menu
    Utility.Wait(0.01)
    TheContainer.Activate(PlayerRef)                  ; activate container interface
    Utility.Wait(0.01) 
    Game.EnablePlayerControls(False, False, False, False, False, True)  ; Reenable menu   
    If abim_IMS_RepItemList.GetAt(RepItemIndex) as Armor        ; un-equip only if an armor item
      PlayerRef.UnequipItem(abim_IMS_RepItemList.GetAt(RepItemIndex), False, True)
    EndIf
  EndIf
EndEvent

 

 

 

Link to comment
Share on other sites

Unfortunately, i get no effect.

Here is the code i use.

Can you take a look please ?

 

Maybe it comes from the type of item i use (miscItem)

 

 

 

Scriptname LHGlobeTmh extends ObjectReference
;Source by Chronepsys
;--------------Properties----------------------------------
Cell Property LHExtManor Auto
Cell Property LHExtLaboratory Auto
Cell Property IntManor Auto
Cell Property IntLaboratory Auto
Cell Property IntGreenHouse Auto
ObjectReference Property TmhMarkerHouse Auto
ObjectReference Property TmhMarkerBack Auto
Actor Property PlayerRef = None Auto
;-------------------------------------------------------------
;------------Effect------------------------------------------
Event OnEquipped(Actor akActor)
If akActor == PlayerRef
Actor target = Game.GetPlayer()
If ( target.GetParentCell() != LHExtManor ) && ( target.GetParentCell() != LHExtLaboratory ) && ( target.GetParentCell() != IntManor ) && ( target.GetParentCell() != IntLaboratory ) && ( target.GetParentCell() != IntGreenHouse )
TmhMarkerBack.MoveTo(target)
target.MoveTo(TmhMarkerHouse)
Else
target.MoveTo(TmhMarkerBack)
EndIf
EndIf
EndEvent
;-------------------------------------------------------------

Edited by Chronepsys
Link to comment
Share on other sites

  • Recently Browsing   0 members

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