RegisterEventHandler(explained)

  • #10, by afrlmeWednesday, 03. April 2013, 14:13 13 years ago
    oh smile
    it is working currently?

    sounds like a very nice function! could you please add the script to the wiki (listed on the menu) when you have done along with some instructions maybe & a pastebin version? cheers wink

    --*--

    register event handlers should really be added to a separate script & their should only be one of each - I've tried adding multiple ones before & it tends to skip all of them until it reaches the last one created.

    for the mainLoop I add functions from other scripts into it:
    function onMainLoop()
    -- check if a certain condition is met so that it knows if the function should be called or not ...
     if cond or if variable_state = x then
      function_name()
     end
    end
    

    Imperator

    7289 Posts


  • #11, by DundilWednesday, 03. April 2013, 16:01 13 years ago
    OK, I'll do it.

    About the event register, I've created a listeners system, like there are in other languages. Something like:

    addEventListener("mainLoop", testA)
    addEventListener("mainLoop", testB)
    addEventListener("mainLoop", testC)
    


    ...so all of them are called on the event. I've not made it for mouse events yet, but I'll make it soon.

    Newbie

    19 Posts

  • #12, by afrlmeWednesday, 03. April 2013, 16:15 13 years ago
    nice one smile

    by the way - I don't really deal with lua related stuff outside of Visionaire Studio itself but I should probably learn some of it so I can learn to create custom functions also.

    hmm ... if the script/function works ok then maybe Alex could implement it into the source code of VS itself to be called/used as a command.

    Imperator

    7289 Posts

  • #13, by DundilWednesday, 03. April 2013, 16:29 13 years ago
    I don't really deal with lua related stuff outside of Visionaire Studio itself

    But... You recommended me to use sublime, didn't you? I supposed you use sublime to create scripts that are out of VS and then import them (as explained by divo in the Wiki).

    Newbie

    19 Posts

  • #14, by afrlmeWednesday, 03. April 2013, 16:37 13 years ago
    yes I use sublime ...
    I meant: I haven't really learned how to create custom functions & libraries.

    most of the scripts I have made are related to Visionaire Studio for controlling various things using the data structure & the player commands etc.

    there's loads of lua functions & libraries on http://love2d.org - some of which sound useful - I'm hoping to see if any of them can be used with VS at some point - seeing as they are all open-source smile

    I wrote the include thing in the wiki - divo added the thing in the second spoiler - he showed me how to include external files though & he wrote the external libraries include wiki page (which I can't say I understood very much)

    Imperator

    7289 Posts

  • #15, by DundilWednesday, 03. April 2013, 16:48 13 years ago
    OK, I see.

    I've added to the wiki the events management system. Why do you put a pastebin? Can't the code be directly copied from the wiki?

    Newbie

    19 Posts

  • #16, by DundilWednesday, 03. April 2013, 17:00 13 years ago
    I have created an article in the Wiki about the events (here).

    Newbie

    19 Posts

  • #17, by afrlmeWednesday, 03. April 2013, 17:07 13 years ago
    cheers smile

    I add a pastebin version because of the color code parser - we have included a pastebin style plugin for the new documentation wiki - (easier to read than full black on white text + only registered members can see the wiki on here)

    Imperator

    7289 Posts

  • #18, by afrlmeWednesday, 03. April 2013, 17:13 13 years ago
    oh! if we use your event handler/listener system, then we can't use the default Visionaire Studio registerEventHandlers?

    to use this we include/require the .lua file or just drop the script into the editor as a definition script?

    Imperator

    7289 Posts

  • #19, by DundilWednesday, 03. April 2013, 17:18 13 years ago
    Yes, it's a lua file to be included.

    About the event registration, of course not, because of the problem with multiple handlers. It seems VS has ONE handler function per event type. That's the reason of your system of having one handler and, from there, call different functions.

    This is just a way to do what you do in a more general way: one handler (in the lua code provided), and you just tell the system which functions are called from that handler. It's just your system in a more "generic" way.

    If you register a different handler, the previous one (the one provided) won't work.

    Newbie

    19 Posts

  • #20, by afrlmeWednesday, 03. April 2013, 17:25 13 years ago
    ok ...

    I finished adding examples & formatting the wiki page earlier the day for the registerEventHandler @ http://wiki.visionaire-tracker.net/index.php?title=RegisterE...

    P.S: where about in Spain are you from? (I have lived in Granada region for the past 10 years)

    Imperator

    7289 Posts