Jump to content


Photo

Starting lua


    5 replies to this topic

    #1 Mrbelvedere

    Mrbelvedere

      Newbie

    • Members
    • Pip
    • 4 posts

      Posted 28 August 2014 - 02:06 PM

      I'm not sure if this is the right place to post this, so I appologize if not, and request it be moved to the proper location.

       

      I'm new to windower addon development, and have recently (last night) I started attempting to learn the windower specific Lua and put it into practice to see if I can come up with some good addon ideas ( I haven't done lua anything since some very basic addons I made in the days of Tribes 2... so I'm very rusty & sloppy ).  I make a little bit of progress, and then inevitably enter something in a way windower doesn't like, and suddenly I can no longer use "//lua load test" or "//lua unload test" etc.  It seems normal addons I can still load / unload just fine.  Is there an easy way I can reinitialize the "lua engine" (for lack of a better term) so I don't have to restart FFXI every time I make a mistake?  Or is there a better approach than I am taking in general that leads me to end up in this situation?

       

      Thanks,

      Mr Belvedere



      #2 Iryoku

      Iryoku

        Advanced Member

      • Windower Staff
      • 488 posts

        Posted 28 August 2014 - 05:25 PM

        If you block forever (infinite loop) in the global scope or an event callback you can prevent the addon from unloading (you may even deadlock the game). Make sure you always return promptly from events (or call coroutine.yield if you need to perform a long-running operation). You can try //reload luacore to reset everything, but if the addon is really blocked then that probably won't work either.



        #3 Arcon

        Arcon

          Advanced Member

        • Windower Staff
        • 1189 posts
        • LocationMunich, Germany

        Posted 28 August 2014 - 06:15 PM

        Also, I'd be curious to know how you got into that situation. You should drop by our IRC channel (irc.windower.net, #lua) to discuss addon development and if it's something that can be prevented we can incorporate it into LuaCore. But as Iryoku said, if it's an infinite loop there's little we can do about it.



        #4 Mrbelvedere

        Mrbelvedere

          Newbie

        • Members
        • Pip
        • 4 posts

          Posted 28 August 2014 - 08:15 PM

          Hi, thanks for the heads up.

           

          I had been performing a function that was likely improper, I don't recall exactly but I think I was trying to output my current target to chat.  I'm currently reading from wiki and the windower's 'Lua guide' thread... which IDK, maybe I'm totally nuts, but it seems like a lot of that is out of date and doesn't match up with the API at all, so that may have been part of the problem.  I've instead been tearing apart other people's scripts now to learn how they do things, and working from the wiki exclusively instead of relying on that thread.

           

          Still having oddities though, I'm curious, are the 'emote' event's out of order or something?  When I do this:

           

           

           

          function event_emote(senderId, targetId, emoteId, motionOnly)
          windower.add_to_chat(207, 'Sender:' .. senderId .. '   Target:' .. targetId .. '   Emote:' .. emoteId)    
          end
          windower.register_event('emote', event_emote)
          

           

          I get unexpected results.

           

          Judging by what the forum on lua for windower says, in thier example:

           

          function event_emote(senderId, targetId, emoteId, motionOnly)
                  if(emoteId == 8 and targetId == get_player()['target_id']) then -- /wave has ID 8
                          local name = get_mob_by_index(senderId)['name']
                          -- Do something with name here
                  end
          end

           

          emoteId should be 8 for /wave.  But, in my sample (since thiers didn't work for me) I'm getting the number '8' for "SenderID" (presumably this is supposed to be the eventID?) ... a 6 digit number for "TargetID" (presumably this is the senderID??)  and the "EmoteID" seems to be either an 8 digit number (if something is targeted) and 0 if not (so I'm assuming this is functioning as the targetID?)

           

          I'm new to this, so perhaps I'm overlooking something, but these little bumps are making my entry into this very confusing.

           

           

          I.E. If I have a target selected I'm getting:

           

          Sender:8   Target:234598   Emote:17923490

           

          I think I should be instead expecting:

           

          Sender:234598   Target:17923490   Emote:8

           

           

           

          Update:

           

          I changed

          function event_emote(senderId, targetId, emoteId, motionOnly)

           

          to

          function event_emote(emoteId, senderId, targetId, motionOnly)

           

          (swapping emoteid to front) and it now seems to function as expected, and I can print them in any order.  I wasn't aware that the order mattered, but if I revert back to the other order the issue crops back up, so it must...

           

          If the order is intentionally neccesary, is the order always going to follow that in which they are listed in the event api ( http://dev.windower....pi:events:start ), as it seems to work this way for the emote event?



          #5 Arcon

          Arcon

            Advanced Member

          • Windower Staff
          • 1189 posts
          • LocationMunich, Germany

          Posted 28 August 2014 - 08:52 PM

          None of the event_* functions work anymore. That thread is completely outdated, we removed those over a year ago. You should go by the wiki exclusively (and by other currently working addons).

           

          Every event_<bla> function was changed to windower.register_event('<bla>', function), see how other addons do it for help on that.



          #6 Mrbelvedere

          Mrbelvedere

            Newbie

          • Members
          • Pip
          • 4 posts

            Posted 28 August 2014 - 09:19 PM

            Thank You Arcon & Iryoku for your assistance






            1 user(s) are reading this topic

            0 members, 1 guests, 0 anonymous users