[CF 1489] TMW Public API to set a counter value?
tmw-issue-import opened this issue ยท 7 comments
I am using a WA script to track the number of available soul fragments for VDH since the game info has a built in delay. Currently I am thinking of writing a simple addon that will add a public SetSoulFragments and GetSoulFragments functions so that I could use that data on a TMW LUA condition, but I would have loved to just be able to set a TMW counter from WA so that I could use it for both conditions and display.
Is such a thing possible? Would you consider adding such an API to allow external sources to provide info for TMW?
Posted by CurseForge user ariehg | Imported from CurseForge issue #1489 | Raw
Alternatively, is there a way to set variables writing a LUA snippet that can be accessible to TMW (since all this script does is listen to a WoW event)
Posted by CurseForge user ariehg
In my spammy nature - to update what I've currently done - I've ported the WA script to a LUA snippet that exposes a function, then created a set of notifications that set the value of a counter.
However, this is very awkward, since it requires a notification per value (6 in my case since I have values from 0 to 5). Maybe what I'm missing is a way to set a tag?
Posted by CurseForge user ariehg
this is the final result btw - https://pastebin.com/Ry7P70qS - #1 and #2 are the LUA snippet and the icon that sets the counters
Posted by CurseForge user ariehg
Not a simple, single API call, but you can do it like this:
local name = "CounterName"
TMW.COUNTERS[name] = someValue
TMW:Fire("TMW_COUNTER_MODIFIED", name)
Posted by CurseForge user Cybeloras
ah. Sounds reasonable enough. Will just make a function that can be reused and copy-paste it :) Any chance of adding a updateCounter method in the future that does this (just to make things DRY)?
What about the ability to set tags inside snippets? I mean - above method would probably work just as well as adding tags, but might be interesting
Update - I have tried that - the variable is updating properly (I used LUA console to check TMW.COUNTERS[counter_name]) but the counter does work on my icons (I've obviously tried reloading etc).
Update 2 - got it working. One issue was that I needed to set the counter on initialization. The other (I think) was that the name I chose was too long? Can this be an issue ("SoulFragmentsCounter")?
Edited May 6, 2018
Posted by CurseForge user ariehg
Name length doesn't matter. Not likely that I'll add some other function that both sets the counter and then fires the event, since there'd be no use of it in out-of-the-box TMW.
I don't know what you mean by "set tags". Do you mean creating a DogTag? You're free to use the DogTag API for that. https://www.wowace.com/projects/libdogtag-3-0/pages/api/lib-dog-tag-3-0-lua#title-3
Posted by CurseForge user Cybeloras
Cool! Yeah I just meant the various values I can access in the text fields of the icons. Will play around with it.
I'm mostly interested in expanding the use case for LUA snippets. Right now it's quite difficult to get the values generated by them to the icons and groups, so their functionality is a bit limited out of the box, although the power potential for them is quite high.
I'll see if I can come up with some other use cases but will probably come to a different issue since this has already went out of scope :)
Have also started learning the codebase a bit so maybe I'll start working with PRs instead if that's something you're ok with.
Posted by CurseForge user ariehg