About scripting

  • #1, by lennonWednesday, 08. October 2014, 00:14 6 years ago
    I´m new to visionaire and got a few questions about scripts:
    1- How do I do a function that is called on every frame? (that´s the most important question I have)
    2- I´ve seen that you can do some lua scripts and call them in the actions panels. Yet, what happens if I want a different trigger for that function? Say, for example the function needs to be called not while the cursor enters an area, but rather every frame the cursor stays in that area?
    3- Is it possible to see actions made through the editor as writtern in code form? Is there some kind of text document where all the code of my game is written and can be modified?
    4- Any good tutorials (not that much about scripting in lua but rather about using custom scripts in the editor)?

    Newbie

    6 Posts


  • #2, by AlexWednesday, 08. October 2014, 01:12 6 years ago
    1: http://wiki.visionaire-tracker.net/wiki/RegisterEventHandler
    see example 1
    2: this would probably be best handled in the main loop. also depends what you actually want to do in your function
    3: not sure if I understand this question correctly. at the moment the scripts are not stored in external files (if that's what you mean), but that's something I plan for next version
    4: so far the wiki is the best resource, and you find many scripting examples in the forum

    Great Poster

    378 Posts

  • #3, by afrlmeWednesday, 08. October 2014, 01:43 6 years ago
    The good thing about loop handlers is that you can create as many as you like & unregister them when you no longer need them.

    It's also possible to create loops internally via the editor with the jump to x action part action. The best method for this it to add the loop to a called by other action you have created containing the loop & action parts you want to loop; you can even add a pause action part to it if you want to delay the amount of time between loops. Called by other actions can be quit quite easily with the quit action action part or you can wrap loops with if queries containing a condition or value which will break the loop if the query is not met.
    -- editor action parts (not lua script

    -- x --
    if condition 'action_area_active' is true
    add some actions here to loop
    jump to action part #1
    end if
    -- x --
    1
    2
    3
    4
    5
    6
    7
    8
    9

    ...this would create a loop, that will loop until "action_area_active" condition is set to false. So in other words when character enters action area you would set the condition to true & then call the called by other action containing the loop & actions you want to loop. To quit the loop you would on character leaves action area: set the condition to false.

    I prefer using lua myself when possible as I find it much faster to type than selecting action parts one at a time from a list or the popup box.

    @ Alex: As for (3) I believe he was talking about the code generated by the engine itself for his game.

    The .ved project file can be opened with a text editor like sublime text or notepad++ etc, but it's not really code per say, it's more a list of id's & tables that translate into actions. Text such as names & scripts are stored in the .ved file also, however we recommend that you should avoid directly editing your .ved files with a text editor, if possible.

    Finally: if you want to learn about lua scripting & scripting in Visionaire Studio, then I do recommend looking at the wiki as we have quite an extensive amount of scripting related pages, of which I'm constantly updating. I spend too much time on the lua related pages & not enough on the editor documentation.

    Imperator

    6862 Posts

Write post