September 18, 20178 yr I'm trying to make a small function (maybe plugin) that uses trinkets. And i'm stuck with trinket cd time left. I'd like to use it as a c# condition. Have tried different lua methods, and they always return 0 or False. private bool FirstTrinketReady = Lua.LuaDoString<bool>("local s, d, e = GetInventoryItemCooldown(\"player\",13); t=GetTime(); if s+d<=t then return = \"true\" else return = \"false\" end"); Always return False. private int FirstTrinketMSLeft = Lua.LuaDoString<int>("local s, d, e = GetInventoryItemCooldown(\"player\",13); t=GetTime(); r=s+d-t; if r>0 then return = r else return = 0 end"); Always return 0. Can't understand why. I'm not good at Lua. Do hope that's happening because i'm falling asleep already, or because of some really stupid mistake. Any advices apriciated. And the second thing, i was not able to use an equiped item by ID with wManager.Wow.Helpers.ItemsManager.UseItem(uint itemId). It uses item in inventory, no problem here, but it is not working for equiped items. Right now i'm doing it with lua UseInventoryItem(slot). Is there any way to use equiped items by item id? Thank you for any advices.
September 19, 20178 yr I'm not the greatest with lua, so here is my answer but in C#. int itemID = 123; var itemCooldown = wManager.Wow.Helpers.Bag.GetContainerItemCooldown(itemID); var itemTimer = new robotManager.Helpful.Timer(itemCooldown); itemIsReady.ForceReady(); if (itemTimer.IsReady) { ItemsManager.UseItem((uint)itemID); itemTimer.Reset(); } Also, i'm not really sure about what this does: Bag.GetContainerItemCooldown(itemID) This may actually return the remaining time. I haven't tested. If it DOES return the remaining time, then you can pretty much skip the whole timer thing :). Anyway, let me know! I found an example that does it very similarly to my above snippet: Edited September 19, 20178 yr by Avvi
September 19, 20178 yr Author Thank you for your reply, but the problem is, there is no c# functions (atleast i have not found one) to check CD of equipped items. They works only with items in your bags, but not with equipped one. For example, if you will use a trinket and then put it in your bag, wManager.Wow.Helpers.Bag.GetContainerItemCooldown(itemID) will return correct CD time of that trinket (while it is in your bag). But if you equip that trinket, it will aways return 0, as if you have not such item. btw, just was curious as well, maybe it will usefull for someone. wManager.Wow.Helpers.Bag.GetContainerItemCooldown(itemID) returns time of CD left in milliseconds, for example for 30 minutes trinket it will return 1800000 if you just used it, and 0 if it's ready to use or if there is no such item in your bag.
September 19, 20178 yr Hello, this might help you: /// <summary> /// Used to get the cooldown of an inventory item. /// </summary> /// <param name="slotId">The slot to get from.</param> /// <returns>The left cooldown of the item.</returns> public int GetInventoryCooldown(WoWInventorySlot slotId) { return Lua.LuaDoString<int>( @" local start, duration, enable = GetInventoryItemCooldown(""player"", "+(int)slotId+@") local coolDown = duration-(GetTime()-start); if (coolDown < 0) then return 0; end return coolDown; "); } Usage: Logging.Write("Cooldown of Trinket1: "+GetInventoryCooldown(WoWInventorySlot.Trinket1));
September 19, 20178 yr Author Thank you alot. It is working, return seconds, like lua should. That's funny, because technically it's the same function. I guess my method was broken because of bad return or local variables declaration.
Create an account or sign in to comment