greatgiginthesky Posted September 10, 2010 Share Posted September 10, 2010 Hello again helpful residents,After getting some exposure to scripting, I'm coming back to the idea of modding a way to convert items into a portion of their gold value. The most elegant thing I could come up with is a spell, which opens a container when cast. The player (aka me!) can place items in the container to be turned into gold. I've set up an always-on gamemode script which I want to check the contents of that container every x seconds, and if there are items present, do calculations to assess value like [(value / 2) * (alterationskill / 100)] then remove the items and give that much gold to the player. As I understand it, currently the best way to handle inventory functions is using GetItems(?) I got frustrated trying to figure out how to implement GetItems and thought I would ask if anyone has experience using this OBSE function and could help me understand how to use it. Would I, in each periodic check of the container, do:myArray CreateArrayset myArray to myContainer.GetItemsif ArraySize myArray > 0loop <array size> times to tally value of each itemmyArray DestroyArraymyContainer.RemoveAllItemsplayer.additem gold001 <tallied value> I miss C# Thanks for reading and for any help you can give or alternative suggestions. :) Link to comment Share on other sites More sharing options...
ARLADRIS Posted September 10, 2010 Share Posted September 10, 2010 Looks like you are familiar with C, so I will not give you exact script(I am lazy...), but can give you some advices(Hope you know basics of CS scripting):Quest Script:I prefer using while - loop, however iterators may be used as well, however I personally hate Java language and prefer using C, C++.You do not have to use Pluggy, OBSE provides everything. array_var ChestItems short DoOnceshort ArraySizefloat fQuestDelayTime ref Itemref Chest Begin GameMode if DoOnce == 0 set DoOnce to 1 set Chest to MyChest ;container ref set fQuestDelayTime to 1.0endif let ChestItems := ar_Construct Arraylet ChestItems := Chest.GetItemslet ArraySize := ar_Size ChestItemswhile(ArraySize > 0) let Item := ChestItems[0] ;now you have item, perform any action you want Chest.RemoveItem Item 1 ;maybe be more than 1 item, can produce bugs, quantity can be measured with GetItemCount function ar_Erase ChestItems 0 set ArraySize to ArraySize - 1looplet ChestItems := ar_Null End Link to comment Share on other sites More sharing options...
greatgiginthesky Posted September 10, 2010 Author Share Posted September 10, 2010 Wow! This is terrific. Within minutes of trying, I was completely successful at adapting this for my use. Heck, you did everything but compile it for me and do my taxes. I really can't thank you enough. And now I understand how to work with arrays in CS script to boot. +kudos! let me just... ARLADRIS.mod karma 5, additem gold 1000000.. Link to comment Share on other sites More sharing options...
Recommended Posts