Hello Everyone!
I've been struggling with scripting an idea. I'm an experienced Skyrim player (1200+ hours) and am now just getting into the immersion and environment, and don't
really want to deal with all the mundane gibberish anymore; just play! So, the idea was, rather than having to go around, and find all the various merchants (and hope
they have enough gold to buy anything), I thought having a "sell barrel" which is scripted to give base value to the player for every item put into it, would save a lot of
time and heartache. So, here's the basic concept:
---=== Begin Concept ===---
There's a barrel (or chest) into which the player can place items; there is a button on/near the container, which when pressed, gives the player the options of: "Sell
the Items", "Get Rid of the Items", and "Exit".
If the player selects "Sell the Items", the "totalgold" variable is zeroed, then the items in the barrel/chest are evaluated item for item, the value of each is asses to the
"totalgold" variable, and then the item is deleted from the container's inventory; once all the items are gone, then the sum of gold is given to the player, and the script
ends and returns the player to the game.
If the player selects "Get rid of the Items", then each item is deleted from the container's inventory; once all the items are gone, the script ends and returns the player
to the game.
If the player selects "Exit", then the script ends and returns the player to the game.
---=== End Concept ===---
Making the button, barrel, and the basic form of the activator and event is done, and the skeleton functions. (barrel and "ImpButton01" as the button).
Giving the player the options on the screen is working fine. The "delete" portion is already done and tests as working as expected, as are the responses onto the
screen. I'll probably change the "MessageBox" to "Trace" just to make a little less need for interaction after-the-fact.
The problem is in the "Sell the Items" portion of the script, as I really can't seem to conceptualize how to do an efficient, looped and selective process for figuring out a random inventory and evaluating it. FList's and direct references don't really seem applicable, as there's no easy way to determine what a player might dump into the container. So, I don't know how to script the inventory handling and such, and would like to see if anyone has any ideas and/or examples.
Here's the script so far:
Scriptname KentiItemSellBarrel extends ObjectReference
{script to "sell" or delete items from an in-game container on button activation}
import game
import debug
ObjectReference Property SellBarrelContainerREF auto ; the actual container being referenced where the player places the items
MiscObject Property gold001 auto
Message Property KentiItemBarrelMsg auto ; message used in-game to place options onto the screen
int SellGoldValue
int ItemGoldValue
int TotalInventoryItems
int ItemCount
Event OnActivate(ObjectReference akActivator)
int ibutton = KentiItemSellBarrelMsg.Show()
If ibutton == 0 ; "Sell" all items in the container
SellGoldValue = 0 ; reset the value to be sure its zeroized
TotalInventoryItems = [functionvalue] ; total number of items in container
; begin loop; while TotalInventoryItems > 0 continue
[ select next object from current inventory ] = CurrentItemREF
ItemCount = CurrentItemREF.GetItemCount()
ItemGoldValue = CurrentItemREF.GetGoldValue()
SellGoldValue = SellGoldValue + ( ItemGoldValue * ItemCount )
SellBarrelContainerREF.RemoveItem(CurrentItemREF)
TotalInventoryItems = TotalInventoryItems - ItemCount
; end loop; aka go to next item in the container
Game.GetPlayer().AddItem(Gold001, SellGoldValue) ; give the player the value in gold
Debug.MessageBox("All the items have been purchased by Khajiit Traders and Thieves Guild contacts.")
ElseIf ibutton == 1 ; delete all items in the container
SellBarrelContainerREF.RemoveAllItems()
Debug.MessageBox("All the items in the barrel have been donated to charity.")
ElseIf ibutton == 2
return
EndIf
EndEvent
Thank you in advance for the guidance and assistance, and any wisdom you can bestow on me is most appreciated.