Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

How to quit multiple actions.

  • #1, by ke4 11 years ago Zitieren
    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
  • #2, by afrlme 11 years ago Zitieren
    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
  • #3, by ke4 11 years ago Zitieren
    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.
  • #4, by afrlme 11 years ago Zitieren
    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
    

    ... I think. Off the top of my head.
  • #5, by ke4 11 years ago Zitieren
    I know, i don't know why they confuse me. Thanks, i'll figure it out somehow :-)
  • #6, by ke4 11 years ago Zitieren
    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
  • #7, by afrlme 11 years ago Zitieren
    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.
  • #8, by ke4 11 years ago Zitieren
    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"}
    


    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?
  • #9, by afrlme 11 years ago Zitieren
    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?
  • #10, by ke4 11 years ago Zitieren
    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)
    
  • #11, by afrlme 11 years ago Zitieren
    local r = Scenes["VytahPanel"].SceneValues["speed"].Int
    local p = Scenes["VytahPanel"].SceneValues["space"].Int
    local act = Scenes["VytahPanel"].SceneActions[ p .. r ]
    
    startAction(action)
    

    ... 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 .. "]")
    


    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.