Elitist Jerks
Register
Blogs
Forums


Go Back   Elitist Jerks » User Interface and AddOns

Reply
 
LinkBack Thread Tools
Old 09/29/07, 5:18 PM   #1
Disquette
1) press clutch and break 2) turn key
 
Disquette's Avatar
 
Human Rogue
 
Sargeras
Addon authoring help? Willing to pay.

If you converted my going hourly rate to the amount of time I've spent working on this, I've already spent a few hundred dollars, so while it's not exactly the same, I'm perfectly willing at this point to paypal $20 to a person who will write a mod for me to help me understand scheduling and unscheduling events within the Ace2.0 framework.


********* edit, solution found **************
**** the rest of this post is left so that ********
**** others with the same problem ***********
**** have a record of how to deal with it *******

The solution was originally posted here:
Is there a good resource for timing Events in Ace?

You can see a specific example of this in reply #3 in this thread.

***** original post follows ***************




The mod should:

- Use the built in Ace2.0 Event library/mixin for the timers

- Start a repeating event, printing to the console every 5 seconds, on detecting a certain spell cast (spell a).

- Start another scheduled event countdown, for a non-recurring event, to happen in 10 seconds after a different certain spell was cast (spell b).

- When spell b is cast, the repeating event from (spell a) is nixed, and the print message will not happen again.

- you may not use :CancelAllScheduledEvents() You must use :CancelScheduledEvent(_)

The code must be short and do only these things. I expect 30 lines or less should do it, probably closer to 15 :p

I'll be happy to provide any code that you'd like for the specifics of my situation, or just so you have a skeleton of an addon that works. Currently it does all scheduling just fine, for one time and recurring events. It's the unscheduling that is kicking my arse.

Please send me a PM if this stuff is cake to you, and you want a quick $20 via paypal (amazon.com gift certificates are fine too if you'd prefer that).

Last edited by Disquette : 09/30/07 at 3:23 PM.

United States Offline
Reply With Quote
Old 09/30/07, 5:55 AM   #2
sarf
Great Tiger
 
sarf's Avatar
 
Fars
Human Paladin
 
No WoW Account (EU)
Unfortunately, I'm not too used to the whole Ace paradigm. The following is the result of me doing some digging in the code at a time when I should probably be drooling in my tea instead.

Hope it helps!
-- Skipped AceEvent initialization as that is a murky depth to me. It's also early.

-- Assuming that you have created a cool funky addon named DisquetteAddon. 
local addon = DisquetteAddon;

-- Spell names
local spellA = "Five Second Thingy";
local spellB = "Ten Second Thingy";

-- Event names for scheduling and unscheduling
local fse = "DisquetteFiveSecondEvent";
local tse = "DisquetteTenSecondEvent";

-- Used to determine when a spell is cast.
-- Thanks to Human Laziness (tm) I used the least bothersome event to detect spellcasting from.
function addon:SPELLCAST_START(spell, castingTime)
	if ( spell == spellA ) then
		addon:ScheduleRepeatingEvent(fse, 5);
	elseif ( spell == spellB ) then
		addon:CancelScheduledEvent(fse);
		addon:ScheduleEvent(tse, 10);
	end
end

-- Five second event, recurring after spell a.
-- In order to avoid having to use special register variables, name is the same as the event.
function addon:DisquetteFiveSecondEvent()
	DEFAULT_CHAT_FRAME:AddMessage("5 second print!");
end

-- Ten second after spell b
function addon:DisquetteTenSecondEvent()
	DEFAULT_CHAT_FRAME:AddMessage("Something should be done here, but was not specified by disquette.");
end

function addon:DisquetteEventRegistration()
	-- OK, the big shebang, setup-wise.
	addon:RegisterEvent("SPELLCAST_START")
	
	-- Note that the fse and tse are non-Blizzard events.
	addon:RegisterEvent(fse);
	addon:RegisterEvent(tse);
end

addon:DisquetteEventRegistration();

Offline
Reply With Quote
Old 09/30/07, 2:31 PM   #3
Disquette
1) press clutch and break 2) turn key
 
Disquette's Avatar
 
Human Rogue
 
Sargeras
Going to play with this, expect a PM if it works

Ok, so the solution is found from a person on another board. Here is how unscheduling an event works, and what is missing from the documentation. I had been using the following code to schedule and unschedule an event:

function myAddon:OnEnable()
	self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end

local wfevent = "myAddon_WFTotem"

function myAddon:myAddon_WFTotem()
	self:Print("WF Totem Tick")
end

function myAddon:UNIT_SPELLCAST_SUCCEEDED(arg1, arg2, arg3)
	if arg2 == "Stormstrike" then
		self:CancelScheduledEvent(wfevent)
	elseif arg2 == "Windfury Totem" then
		self:Print("WF Totem Dropped")
		self:ScheduleRepeatingEvent(wfevent, 5) <-----------
	end
end
note the line with the <-----

While that works for scheduling events, in order to unschedule them, you must use a more verbose method of scheduling the event. In this case, I replaced that line with:
self:ScheduleRepeatingEvent("WindfuryTotemSux", wfevent, 5, self)
Then, when I wanted to unschedule the event, I used:
self:CancelScheduledEvent("WindfuryTotemSux")
Thanks to the two people who responded, and juding from sarf's attempt at the code, he had the same problem with the documentation that I did, as it's not clear how to do this. Apparently as wowace gets updated, the documentation is auto-regen'd, so if anyone had corrected their wiki before, it got lost with one of the Ace2 updates.

Last edited by Disquette : 09/30/07 at 3:35 PM.

United States Offline
Reply With Quote
Old 09/30/07, 6:26 PM   #4
sarf
Great Tiger
 
sarf's Avatar
 
Fars
Human Paladin
 
No WoW Account (EU)
Hmm... this seems like a major bug.

Are you sure it's just not because of the lack of addon:RegisterEvent(wfevent); in your code?

It seems unreasonable to me that it would be impossible to unschedule repeating events if someone does a standard schedule-repeating setup call... of course, it may be that there are no such standard calls.

Edit:
Sorry, read the thread you linked and saw that you had, indeed, used the approved Sarf way of coding.
This seems like it merits a siren alert - I do not understand why it should fail to work as expected.
Are generic repeating events mostly used as some sort of "pulses" and the common view is just that you should do a check if you're interested (if not INTERESTED_IN_PULSE_THIS_TIME then return; end) at the start of the repeating function or what? I mean, seriously, come on. <shakes head>

If you feel up to it, put up a jira issue on this one, or I will - perhaps with the "compromise" of adding a :CancelScheduledRepeatingEvent(t) if needed.

Edit2:
Fixed first part for clarity. My first message was made bad due to being too early, this one is too late. Oh well!

Last edited by sarf : 09/30/07 at 6:35 PM.

Offline
Reply With Quote
Old 10/04/07, 9:29 AM   #5
Malan
Mind the gap.
 
Malan's Avatar
 
Malan
Tauren Shaman
 
No WoW Account
Disquette what sort of addon are you writing that you need to know when WF is ticking?

United States Offline
Reply With Quote
Old 10/05/07, 1:05 AM   #6
Disquette
1) press clutch and break 2) turn key
 
Disquette's Avatar
 
Human Rogue
 
Sargeras
Been away from the boards for a while, sorry Malan. I just want a better way to manage everything so I'm not spamming key clicks while shocks or SS is on cooldown, and I want to make a better twisting mod.

So, I'm rolling them all up in to one package.

United States Offline
Reply With Quote
Reply

Go Back   Elitist Jerks » User Interface and AddOns

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pet ability addon. aquacadet User Interface and AddOns 2 07/06/07 10:16 PM
Addon for afk Astmathic User Interface and AddOns 6 06/27/07 5:10 AM
Castbar Addon Toukon User Interface and AddOns 4 05/12/07 1:19 PM
Which addon is this? Bias User Interface and AddOns 3 04/17/07 1:19 PM
Looking for an addon Astmathic Public Discussion 4 09/20/06 11:38 AM