Make function from action parts?

  • #1, by ygmantellThursday, 07. September 2017, 15:58 3 years ago
    So I know some basic Lua, and recently have been utilising that to create functions from a few small VS scripts (that I found on the forum, such as fading brightness, etc).

    But, theres a big chunk of action parts that I use frequently, and instead of copying and pasting them, Is there a way to create a function so I can easily use those action parts without having to either add them manually, or hunt down another instance of them in the game and copy and paste?

    Like, is there a code equivilent for each action part so I can just use the script editor to do this?

    My scripting knowledge for VS is next to none, unfortunately, so I apologize if that didn't make any sense smile (This is coming from my Knowledge of Lua)

    Thanks so much!

    Great Poster

    274 Posts


  • #2, by caligarimarteThursday, 07. September 2017, 16:25 3 years ago
    Most Actionparts have an Equivalent in Lua, in some few Cases the Actionparts are even the more limited Variant and LUA might give you more Possibilities. For Example when you want the Scene-Brightness to fade, you can do that with Actionparts, but only by using Lua you can play with nice Easing-Curves when using the Tweening-Functions. Or, you can send a Character to a Position, to an Object, but not to a Position you have clicked on the Screen -- but with Lua you can (and yes, I actually had to code that for an additional Feature where my Character can also run while you hold the Left-Mousebutton -- that was problematic with Actionparts only).

    Just have a Look at the currently two API-Pages and try to find the Commands that would fit your Actionparts best:



    [EDIT: Also, you might consider making some of your Actionpart-Chunks Actions which you can then call via the "Call Action"-Actionpart -- that is, if the Chunks are always the same, or if the Action includes some If-Statements to account for Variations of how the Action might be used in different Cases.]

    Forum Fan

    145 Posts

  • #3, by ygmantellThursday, 07. September 2017, 17:47 3 years ago
    Right, so I've been looking over both those documents, but I still don't understand how I would go about using the script editor to actually do these things.  

    Actionparts#Send_character_to_position CHARACTER_GOTO_XY -- For example
    1

    Would I use this by writing something like this?
    function sentChar()
       Actionparts#Send_character_to_position playerCharacter_GOTO_360,180 -- For example
    end
    1
    2
    3
    Then just calling my sendChar() function in an execute script?
    Are the capital letters placeholders, as I assumed?

    Forgive me for being totally inept when it comes to these things, I just want to learn as much as possible! smile

    Thanks so much!

    P.S. I totally forgot about calling other actions!

    EDIT:  Or even just putting Actionparts#Quit_game QUIT_GAME into a function does nothing.  Am I missing/misunderstanding something?
    Thanks!

    Great Poster

    274 Posts

  • #4, by sebastianThursday, 07. September 2017, 18:08 3 years ago
    im not quite sure if i understand that correctly. Do you want to reuse actions on several parts or call them via lua? 


    I tend to think this is about the first guess:

    create an action anywhere where it makes sense. Type ist "called by other action". 
    Name it like you wish. 

    In it do the stuff you want to do (send character, etc). 

    Then when you want to use this anywhere else in your project use the action part "call action" and pick the before named action. done. 

    Thread Captain

    2334 Posts

  • #5, by ygmantellThursday, 07. September 2017, 18:17 3 years ago
    Yeah, I just realized I was able to do that, and it would be significantly easier than scripting... but as caligarimarte said, there are things that cannot be done with action parts, so I was wondering how I could go about using scripting to extend the posibilities/do those things and "compress" them into a function that I could call, just as easily as having an action part.

    ...if that made sense.  I apologize if it didn't.

    Thank you!!

    Great Poster

    274 Posts

  • #6, by afrlmeThursday, 07. September 2017, 18:23 3 years ago
    Cheers Ygmantell, you made my day.
    game.CurrentCharacter.CharacterDestination = {x = 500, y = 300}
    1

    Something like that to send the character to a new position.

    I really enjoyed reading your literal #actionpart something other in the code block.

    Please check out this page on the wiki. It covers the basics of how scripting works in Visionaire Studio. That in combination with the data structure page should be all you need to get started. Make sure you read the scripting page fully.

    Sorry to laugh. I know it's probably no laughing matter, but that just cracked me up, so cheers again for that. wink

    Also do what Sebastian said. Create called by other action blocks for generic actions you will be calling all the time, then you can just call them inside of your other action blocks whenever you need them rather than creating & adding the actions to each new block that needs them.

    Imperator

    6804 Posts

  • #7, by sebastianThursday, 07. September 2017, 18:25 3 years ago
    for that go to your scripts section of the editor, create your script. 

    either do a definition script and use functions in it 

    myfunction(attr1) {
        do stuff... 

    which could be called via an "execute a script"  action part where you call the function

    myfunction(3)

    or insert a normal script inside your script section (not a definition script) and use the call script action part to call it 

    Thread Captain

    2334 Posts

  • #8, by caligarimarteThursday, 07. September 2017, 18:31 3 years ago
    The Problem here is...

    1) ... forget about calling Actionparts via Lua -- if you are looking for Lua-Equivalents, that is not what you want. (And yes, it can be a massive Red Herring.)

    2) ... you ask a very vague Question, basically "how do I code?", and that cannot be answered simply. It would be more useful to know that you need something specific, so you can get Help for that particular Matter.
    Line you mentioned was sending a Character to a specific Position. The Lua-Equivalent would be this:
    function SendCharToPos(CHAR,XPOS,YPOS) 
      getObject("Characters[" .. CHAR .. "]"):setValue( VCharacterDestination , { x = XPOS , y = YPOS } )
    end
    1
    2
    3

    Then you would call the Function in another Script somewhere else (or in the same Script, possibly) by simply writing this:
    SendCharToPos("CHARACTER_NAME",600,500)
    1

    I haven't tested the it, but I think it should work.
    And if you want to send the Character to the Position of the Mouse-Cursor, the Line in Lua would look like this (taken straight out of a Script of mine):
    getObject("Characters[INSERT_CHARACTER_NAME_HERE]"):setValue(VCharacterDestination, getCursorPos() 
    1

    I hope that helps.

    [EDIT: Pfft, now you got three different Versions of basically the same Instruction. But hey, different Lights to shine on one Spot, that is also helpful.]

    Forum Fan

    145 Posts

  • #9, by ygmantellThursday, 07. September 2017, 19:02 3 years ago
    Haha! I clearly misunderstood.  I knew something was not right, I just didn't understand what the wiki meant.  
    Thank you all for your replies, and your time!
    I appreciate it.

    Great Poster

    274 Posts

  • #10, by nathan23Friday, 22. September 2017, 05:15 3 years ago
    I tend to think this is about the first guess: new everwing tip apk http://appnaz.com/android/new-everwing-tips-new.everwingguid...

    Newbie

    1 Posts

Write post