How to quit multiple actions.

  • #1, by ke4Sunday, 05. July 2015, 12:49 5 years ago
    Hi,

    is there an option to quit multiple actions at once?
    I have a minigame where i combine buttons and there is 48 combinations, for every combination i have action where is loop with animations. And it's all dynamic i don't know which to end so i need to end all of them and then play the new one.

    Can i somehow quit all the actions which are running in the current scene?
    Thanks

    Key Killer

    810 Posts


  • #2, by afrlmeSunday, 05. July 2015, 15:47 5 years ago
    well you could create a lua table I suppose & add all the action names into it & then use a for i = 1, #table_name do loop to iterate through each action. You would probably need to check if action exists in the activeactions table before trying to quit each one as it might return an error.

    https://www.google.com/search?q=quite&ie=utf-8&oe=utf-8 *quit* wink

    Imperator

    6846 Posts

  • #3, by ke4Sunday, 05. July 2015, 15:56 5 years ago
    I'll try it, but if there is something i'm not good at in coding it's for loop! grin

    Yeah quit, excuse me i sometimes write crap.

    Key Killer

    810 Posts

  • #4, by afrlmeSunday, 05. July 2015, 16:03 5 years ago
    for loop is easy enough.
    local t = {"action1", "action2", ...}

    for i = 1, #t do
    if ActiveActions[ t[i] ] then stopAction(ActiveActions[ t[i] ] end
    end
    1
    2
    3
    4
    5
    6

    ... I think. Off the top of my head.

    Imperator

    6846 Posts

  • #5, by ke4Sunday, 05. July 2015, 16:10 5 years ago
    I know, i don't know why they confuse me. Thanks, i'll figure it out somehow :-)

    Key Killer

    810 Posts

  • #6, by ke4Tuesday, 07. July 2015, 14:49 5 years ago
    Ok, it works great! :-) ( one bracket is missing there )
    ...But it turned out that i'm really bad at math and there are 63 combinations instead of 48 grin Damn.
    Thanks

    Key Killer

    810 Posts

  • #7, by afrlmeTuesday, 07. July 2015, 14:55 5 years ago
    Yep , you are right. That's one of the problems with me writing code off the top of my head & directly to the forum (or wherever). If I was writing it in Sublime text, then it would have either auto-added the bracket closer or it would have let me know.

    Imperator

    6846 Posts

  • #8, by ke4Tuesday, 07. July 2015, 16:04 5 years ago
    I've got another issue, it for some reason can't accept the table.

    local t = {"00", "01", "02", "03", "04", "05", "06", "07", "08", "10", "11", "12", "13", "14", "15", "16", "17", "18", "20", "21", "22", "23", "24", "25", "26", "27", "28", "30", "31", "32", "33", "34", "35", "36", "37", "38", "40", "41", "42", "43", "44", "45", "46", "47", "48", "50", "51", "52", "53", "54", "55", "56", "57", "58", "60", "61", "62", "63", "64", "65", "66", "67", "68"}
    1
    2


    The error i'm getting:


    16:02:59: Error: Failed to run string in Lua: [string "VytahPanel: refresh: Execute script 'local t ..."]:10: ')' expected near 'p'

    16:02:59: Error: String content: local t = {"00", "01", ..."67", "68"}


    What's wrong?

    Key Killer

    810 Posts

  • #9, by afrlmeTuesday, 07. July 2015, 16:29 5 years ago
    Might be because you've used numbers? Try renaming them with a letter in front or at the end. Is the error all part of the same script? Can you post the entire script please?

    Imperator

    6846 Posts

  • #10, by ke4Tuesday, 07. July 2015, 16:32 5 years ago
    I will try to rename it ( but it worked with only two "variables" ? in this table )

    local t = {"00", "01", "02", "03", "04", "05", "06", "07", "08", "10", "11", "12", "13", "14", "15", "16", "17", "18", "20", "21", "22", "23", "24", "25", "26", "27", "28", "30", "31", "32", "33", "34", "35", "36", "37", "38", "40", "41", "42", "43", "44", "45", "46", "47", "48", "50", "51", "52", "53", "54", "55", "56", "57", "58", "60", "61", "62", "63", "64", "65", "66", "67", "68"}

    for i = 1, #t do
    if ActiveActions[ t[i] ] then stopAction(ActiveActions[ t[i] ]) end
    end

    local r = getObject("Scenes[VytahPanel].SceneValues[speed]"):getInt(VValueInt)
    local p = getObject("Scenes[VytahPanel].SceneValues[space]"):getInt(VValueInt)
    local action = getObject("Scenes[VytahPanel].SceneActions["p .. r"]")

    startAction(action)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    Key Killer

    810 Posts

  • #11, by afrlmeTuesday, 07. July 2015, 16:49 5 years ago
    local r = Scenes["VytahPanel"].SceneValues["speed"].Int
    local p = Scenes["VytahPanel"].SceneValues["space"].Int
    local act = Scenes["VytahPanel"].SceneActions[ p .. r ]

    startAction(action)
    1
    2
    3
    4
    5
    6

    ... if you are breaking a "string" to add data via a variable then the .. have to go at the beginning & end of the new data...
    local action = getObject("Scenes[VytahPanel].SceneActions[" .. p .. r .. "]")
    1
    2


    P.S: I do not recommend using certain / common words for variable names as some of them might already be exclusively linked to the VS engine or to the Lua language itself. action or Action, Text, Type, etc. etc.

    Imperator

    6846 Posts

Write post