Edit: there is a workaround that was posted on the forums. A solution to this is to make your Max charges different to your Start charges on the item. Dont know how this changes anything but it works:S
My items have different max,start charges so that shouldn`t be the issue.
Modifying the charges of items that are in an inventory works without problems, however when I try to set charges on an item that is on the ground this bug occurs (the item is set to max charges and won`t decrement charges when used)
I took a look at the map, and it definitely seems to be a data editor bug that I don't know how to handle yet. If I were Zy I might be able to do a bit better in fixing it but I have no idea how the item charges work. I delayed the click by .1 seconds so that I could try dropping items. Whenever I had the bugged item in my inventory, it would bug every other item I picked up. When I was able to drop it, every item I picked up after was just fine.
FatCat, there is a workaround I know of, but its kind of silly, and not in the spirit of this library.
Create an invisible dummy unit with an inventory ability with a drop range the size of the map. Then, whenever you would use "Create item at point", use "Create item in inventory" of the dummy unit instead, set the charges there, and issue an order to drop the last created item at the point you want.
If you want, I can modify the test map to include some new functions to do this.
I found some sort of ... bug. If you use the library function to add/set charges on an item it works correctly, but if you use the function to show the number of charges left on the item whose charges you just modified it will return its old number of charges. However if the item is used, even one time, the number of charges will be returned correctly.
This has also implications over the stack item function. If you stack some items, not use their charges, gather another item of that type and stack again the result will be bugged.
This is awesome man, I was having major trouble manipulating the charges on an item until now! I gotta beg you though, please remove the functionality that destroys an item if its charges reach 0, from the actions that remove charges. There is a flag on every item in the data itself to destroy when depleted, so that functionality is really not necessary, plus if you have an item that you dont want destroyed if it reaches 0 then you cant use your library here 8(, either that or you have to make it so it never goes below 1, but I really need them to start at 0 so, if you would sir please 8-).
Can anyone tell me how to use this? For those GUI users like me, do I need the SC2 library? I saw it, I opened the map but I dont know what you do to make these things with the inventory, I saw only few triggers and changes in the Data editor so I didnt ses what you did. I need to have an inventory Ammo that when clicked/used and it is effect based, it adds charges to the inventory item (the weapon) also effect based. I dont mind if inventory ammo isnt effect-based but should remain inventory item. So how do you use that map to do what you said?
To install a library, you need to right click on the top-left pane of the trigger editor and then click Import Library. If you want a library from another map, you have to first export that library (right click it in the same top-left pane), then import it into your map.
Oh I see, that makes sense why the map was so emtpy. But I also solved my problem which was how to add a charge to an item with triggers as I didnt see an action which was 'Add Charge Used For Unit' action using a negative value. Still I could find use in it since in order to disallow wasting ammo that charges an already full weapon, I need like war3's Charges Remaining condition. Thanks
Btw one should add to the Library an Issue Order Drop Item From Inventory and rather, Drop Item from Inventory without the unit doing any command to drop it.
This looks useful and well-coded. I'd like to see this approved, after the following issues are addressed.
This makes good use of GUI functions and actions to provide the same functionality of the custom script content, but the GUI content is just duplicate code; you can make more efficient use of the script by having those GUI actions and functions work by wrapping custom script content, a single Custom Script action that calls / returns the galaxy script function.
Make use of for instead of while loops; for loops are natively supported in galaxy.
Update the submission post to comply with the new submission guidelines.
Given the age of this topic and the time since the submitter's last login, it is likely this library will time out of the submission process before the submitter responds. As such, I would encourage anyone interested in seeing a library like this to submit their own.