Jump to content

Script help


GowiHasti

Recommended Posts

I'm trying to make a script so that you can harvest water when you have a misc item I call Water Harvester in inventory, but can't figure out how to do it. Unfortunately my scripting knowledge is a bit limited, especially in this area. All I've managed to do is make it so you harvest 1 water when near water and equip a ring with the script attached and


Event OnEquipped(Actor akActor)


If akActor == PlayerRef

as part of the script. I know this is what causes it to work when equipped but thats as far as my knowledge gets me. Can someone help me make it so you can harvest it if you have the appropriate misc item in inventory without having to equip a ring, etc? Or can someone think of a better way? I don't want this dependent on other mods as its not exactly for any Needs mod but another purpose I have.

Link to comment
Share on other sites

Misc Objects will receive the OnEquipped event. You can apply the script to the misc object and then when the player "equips" / "uses" the misc object either in inventory or when assigned to a favorites slot, water will be harvested.

 

For my Inventory Management System mod I use this script to catch when the various items (including misc objects) are used by the player in order to access the appropriate container.

 

 

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

 

With some adaptation it would work for your needs.

 

PS. Gotta love how the forum screws up the tab spacing. Everything was neatly lined up in Sublime Text. Oh well...

Link to comment
Share on other sites

  • Recently Browsing   0 members

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