Jump to content

[LE] Ingredient Chest Put all script?


greyday01

Recommended Posts

I'm not sure what you're trying to do exactly.

 

If you just want a chest that won't accept any item from the player's inventory unless it's an ingredient, the following script should work (placed on the chest). Basically, every ingredient in the game has the keyword in the script. The script checks if what the player is trying to store is an ingredient. If it is, it is stored. If it isn't, the item is returned to the player's inventory and they are told that the item is invalid. If you want to give the player options to store all of the ingredients that they're carrying in one go, that's a bit more complicated and beyond me.

 

Breezehome by Lupus has that sort of option. the script for it is quite complex and may not be exactly what you want but it should give you an idea of how it is done. Basically, it counts up how many ingredient items the player has and then runs a 'while' loop, removing them one at a time and incrementing an integer until there are none left. That script has several options built into it, such as taking half of each type of ingredient, all of them, or leaving the player with either 1 or 3. If you want to adapt the script, it'd be good manners to check with the mod author and credit them for their contribution if they agree that you can use it. You'd need to make a message with a menu to give the player options when they activate the container.

 

Scriptname MyIngredientsScript extends ObjectReference

 

Keyword Property vendoritemingredient auto

 

Event OnItemAdded (Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
If (akBaseItem.haskeyword(vendoritemingredient))
Debug.notification("Ingredient Stored")
Else
RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
Debug.Messagebox("Invalid Item")
EndIf

EndEvent

 

This is a short script I wrote for the levers in my house. Again, it's not exactly what you need but it shows how you tie the menu from the message into the script. aibutton = 2 tells the script how many options to expect, in this case 2. If you had four options for the player to choose from then aibutton = 4. When you make the message with the options in they start at 0, so 0, 1, 2, 3 etcetera. My case was simple. I just wanted to toggle an x-marker on and off.

 

Scriptname MBSFleverToggleXmarkerScript extends ObjectReference
; Attached to an activator, the script toggles the stat of a chosen x-marker
; When the x-marker is the enable parent of objects, this makes these objects visible or
;invisible to the player.

 

ObjectReference Property XmarkerToToggle auto

Message property MenuToDisplay auto

 

Event OnActivate(ObjectReference akActionRef)
If akActionRef == Game.GetPlayer()
Menu()
Endif
EndEvent

 

Function Menu(int aiButton = 2)
aiButton = MenuToDisplay.show()
If aiButton == 0
XmarkerToToggle.enable()
ElseIf aibutton == 1
XmarkerToToggle.disable()
EndIf
EndFunction

Link to comment
Share on other sites

  • Recently Browsing   0 members

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