• 0

    posted a message on Function
    Ah! Thank you very much, Fin.

    That helps a lot.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Function
    I'm not being lazy..

    I've read all the examples. Many times.

    I have downloaded mods and tried different stuff hundreds of times until my head felt like it was going to explode.

    Don't Understand it? Yes.
    Lazy? No.

    Sorry, thought classroom was for when you didn't understand something.

    :(

    Posted in: Lua Code Discussion
  • 0

    posted a message on Function
    I want to call a specific function when the slash command is executed...

    But, I keep getting the following error:


    Message: ..\AddOns\FayAfk\FayAfk.lua line 25:
    attempt to call global 'SetAfk' (a nil value)


    What am I doing wrong...


    From my script:

    FayAfk:RegisterChatCommand({ "/fayafk"}, {
    		type = "execute", name = "cs", desc = "cs",
    		func = SetAfk(),
    	})



    Posted in: Lua Code Discussion
  • 0

    posted a message on Setting AFK
    Aha!

    Exactly what I needed, thank you most kindly!
    Posted in: Lua Code Discussion
  • 0

    posted a message on Setting AFK
    Is there a way to set the afk flag with a custom message?

    (no, I don't want to UN-set - just set).

    I tried: SendChatMessage(self.db.profile.message, "SAY"), with self.db.profile.message set to /afk blah blah

    But, I kind of expected it wouldn't work, and I was right... it didn't.


    Can this be done? I've searched the forums but there's so many people wanting to UNSET afk, I couldn't find anything on setting it.
    Posted in: Lua Code Discussion
  • 0

    posted a message on I'm getting there....
    Well, I ended up borrowing(stealing) code from another mod (hotcandybar or something like that).. and using UNIT_SPELLCAST_SENT instead of SPELLCAST_START. And now it is working! (yay!).

    Thank you to whomever I stole from.

    Not sure why SPELLCAST_START doesn't work for me. Karma, maybe. I killed a cockroach in a previous life?

    I'm very happy though.. my first functioning working mod. :)

    Thanks to all for the /assist.

    Posted in: Lua Code Discussion
  • 0

    posted a message on I'm getting there....
    I did both those things and it still never seems to get there - nothing prints. (it hates me). :(

    function FayRes:SPELLCAST_START(spellname, duration)
     self:Print("Just to see if we got here")
     self:Print("Spell: " .. spellname)
     self:Print("Duration: " .. duration)
    end
    Posted in: Lua Code Discussion
  • 0

    posted a message on I'm getting there....
    Well, I must be doing something wrong, I changed the spell to Lesser Heal, just to test the functions without having to res somebody. :)

    But, It never appears to get hit the function....

    I have:

    function FayRes:OnEnable()
      self:RegisterEvent("SPELLCAST_START")
    end



    and then:

    function FayRes:SPELLCAST_START(spellname, duration)
      self.Print "Just to see if we got here"
      if(string.find(spellname, "LESSER .*")) then
         self.db.profile.message = messages[self.db.profile.msgnum]
         self.db.profile.msgnum = self.db.profile.msgnum + 1
         target = UnitName("target")
         if self.db.profile.msgnum > 10 then
          self.db.profile.msgnum = 1
         end
         SendChatMessage(self.db.profile.message, "SAY")
      end
    end




    What am I missing?
    Posted in: Lua Code Discussion
  • 0

    posted a message on I'm getting there....

    Of course!!! Too easy, no wonder I couldn't figure it out.

    Thank you so much - send me a personal message with your address and I'll send you homemade macadamia nut chocolate chip cookies!

    (Not homemade by me, mind you - I have a cooking skill of 1)..

    :)
    Posted in: Lua Code Discussion
  • 0

    posted a message on I'm getting there....

    All I'm trying to do is send a message from a table of messages to "SAY" whenever I cast the Resurrection spell.

    My mod is written using ACE2 libs at this point.

    I've got the function that spits out the message to work, and it bumps up the index on the table to display the next message.
    I just need to figure out how to call my function when Resurrection is cast.

    Again, I thank you for your assistance, it is very much appreciated.
    Posted in: Lua Code Discussion
  • 0

    posted a message on I'm getting there....

    Thank you so much, Nimbal, for the reply.

    I don't seem to be able to download the SpellStatus library, so in looking at the other link you posted...


    I want to fire my function off whenever I cast Resurrection.

    So, looking at this event from your link.

    "SPELLCAST_START" Category: Spell
    Fired when a spellcast is begun. This event seems to work if the spell has a casting time.
    arg1 Spell Name
    arg2 Duration


    Would I register for the SPELLCAST_START event?

    Then do something like this?
    spell.name, spell.duration = SPELLCAST_START( name, duration )
    if spell.name = "RESURRECTION"
    then
    <etc, etc>
    end

    ?

    Posted in: Lua Code Discussion
  • 0

    posted a message on I'm getting there....

    My mod is almost doing exactly what I want it to do. :)

    I just keep slowly plugging away at it.

    Couple of things are confusing me though...

    I want to do something everytime I cast a particular spell, and I'm not sure how to capture that event?



    Posted in: Lua Code Discussion
  • 0

    posted a message on So Frustrated....

    yes, I have indeed - many times. As well as the individual API docs.

    I'm back at it though, had to just walk away before the computer went sailing out my 2nd story window.

    I'm not new to programming, I've been doing that for the last 20 years. My problem is that I'm old school - I learned the top-down structured approach to these things and this stuff just seems like it's all over the place to me. Have to adjust my brain a bit.

    I'm going to keep plugging away though.

    My frustration stemmed from not being able to even save a variable. And every call to the DB resulted in a 'attempt to access a nil value' error (or something like that - don't remember now).

    The links to all the classes that were once held here are gone?

    Posted in: Lua Code Discussion
  • 0

    posted a message on So Frustrated....

    I have been through the tutorials and written the obligatory "Hello World" mod..

    I have spent the last two days pouring over mods, trying to figure out how they work.

    I went through all the 'classrooms' I could find.

    ...and yet, I still don't seem to be able to do even the simplest of tasks.

    I'm ready to scream.

    Sorry, just needed to vent.

    I'm going to go have some amaretto and watch something mind-numbing on tv.

    :(
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.