How to create Actions via Lua?

  • #1, by propapandaMonday, 01. April 2019, 19:50 A year ago
    I'm pretty familiar with Lua and actually prefer scripting certain things over setting them up in the VS GUI. However, in the spirit of not reinventing the wheel, I would still like to make good use of Visionaire's existing Action Parts wherever possible. 

    At this point I'm still having some trouble wrapping my head around the VS API: I've been through the wiki and forums multiple times but can't seem to find an example of how to create an action through Lua. 

    I understand that I can run an action I previously defined in the Editor via 'startAction(foo).'

    But what I'm missing is a way to define actions via Lua. As a practical example, I'd like to read and parse text files and then based on the results create actions for my characters to act out using existing action parts such as "Display Text", "Move Object to", "Play Animation" and so on.

    Is there any way to do this? Or am I trying to bend the system to do things it's not intended to do?

    Newbie

    6 Posts


  • #2, by afrlmeMonday, 01. April 2019, 20:31 A year ago
    It's possible to create certain things with Lua script, but in general I don't think it's a good idea as the data/action parts/events/conditions/values, etc that you create in the editor get saved as xml data in the ved/vis files & in the save game files.

    You can however do a lot of stuff with Lua script itself as you can read/write 100's of existing parameters/tables, & there a lots of built in exclusive functions available too; now with that said, Simon is currently working on programming a custom scripting language for Visionaire, that should be a lot more flexible/faster than Lua script & will eventually completely replace the current Lua script system.

    Display texts you can't do via Lua script, but you can display texts via Lua draw. Animations/actions you can call/play/quit/stop via existing functions. You can move objects/animations with Lua script as well - immediately, or tweened/transitioned over time with the to() function, which also supports looping, pendulum looping, & easing.

    Anyway, to answer your question in regards of trying to bend the system to do things it was never intended to do... I do this all the time. I'm very good at figuring out workarounds/solutions to things that were not intended to be done with the engine, but you have to take into consideration that this engine was built with a strong emphasis on visual development as opposed to scripting/programming, because the engine was created for artists/non-programmers/scripters - the engine didn't even have any scripting/extensibility support until Visionaire 3.x, as far as I'm aware.

    Imperator

    6842 Posts

  • #3, by sebastianMonday, 01. April 2019, 20:48 A year ago
    regarding your custom action parts :
    you would need to create an own lua plugin to make them available, which will then run also lua in the background while the game is running. 
    But currently there is no documentation about the plugin creation.
    But its pretty straight forward if you kook at the existing plugins which you can activate for your project in the plugins tab. 
    Jusz activate e. g. the movie plugin and check inside you project folder for new created files. These can be dublicated and edited. 

    ~Sebastian 

    Thread Captain

    2337 Posts

  • #4, by propapandaMonday, 01. April 2019, 21:57 A year ago
    Thanks for the pointers, I'll be sure to check them out.

    I understand the tool is aimed at less programming-oriented users. That's good because in fact I'm working with an artist friend and my main task is to make his life as easy as possible smile 

    The main issue he currently has with VS is that of dialogue/text entry. He comes from a Visual Novel background where basic dialogue is apparently written in a simple text format, e.g.:
    A: Hey, what are you doing here?
    B: I'm selling these fine leather jackets.
    A: What?! Get out of here, you!
    1
    2
    3
    Not sure how they'd handle branching dialogue, but you get the idea. 

    As you can probably imagine, such dialogue is really easy to jot down in a plain text editor and much quicker than clicking through a GUI editor. So my idea was that I'd let him write wherever he wants, take his text files, run them through a parser and then bring it all into Visionaire with minimal manual overhead.

    Seems like a fairly common sense approach to me. Has anyone else tried doing something along these lines? Perhaps it's already there and I just missed it?

    Newbie

    6 Posts

  • #5, by afrlmeMonday, 01. April 2019, 22:15 A year ago
    You can script them to a degree using tables. I did some freelance for an upcoming visual novel myst-like hybrid called "Minotaur", a little while back. They wanted some method for writing dialogs along with different parameters to display specific character portraits/moods/animations instead of having to create 1000's of display text action parts. If I remember correctly, what we ended up doing was creating a display text action part which we linked to the string parameter of a VS value & we checked at dialog start how many lines there were in the table so that it would iterate/loop through each one by incrementing a value.

    I'm not going to explain how I sorted it out, but it's something that you could look into, & based on your other posts, it sounds like you are no stranger to programming/scripting.

    Imperator

    6842 Posts

  • #6, by sebastianMonday, 01. April 2019, 22:16 A year ago
    difficult. Because Actionparts are stored in a different table than the actions which hold them. Actions just "link" to the action parts and everything has an ID.

    When you copy an Action (part) and paste it into a text editor, you see what you probably need to "create" , so that you can paste the content back into VS.

    Thread Captain

    2337 Posts

Write post