Problems with animations

  • #1, by zapso87Friday, 20. February 2015, 15:34 7 years ago
    Hi, i have started to develop a game, and it has a minigame.
    The minigame its like "Simon sais" game.
    But im having some troubles displaying the animations correctly.
    I have 3 diferent animations (AnimLA, AnimLV, AnimLR) and i want to run them in a especific oder, but only works with first animation, or display the 3 animations at same time.

    I tryed to use wait() or sleep() functions with os.time(), but it only freezes the game during X seconds.
    Is there a way to make the script wait until an animation ends?

    Also tryed to create an action that calls the animation, but it continues doing the same, showing ony the first animation or all at same time.

    Please, if anyone can help me with my problem or tell me a better way to do a "simon says" without scripting, I will be grateful.

    PD: sorry about my english isnt the best. grin



    function cargarSimon()
        local simon = {}
        for i= 1, 10, 1 do
            simon[i] = math.random(1,3) 
            --print("ARRAY SIZE"..variable.." ".. simon[i])        
        end
        return simon
    end
    
    function wait(seconds)
      local start = os.time()
      repeat until os.time() > start + seconds
    end
    function sleep(n)
      os.execute("sleep " .. tonumber(n))
    end
    
    function startSimon()
        arraysimon = cargarSimon() --fills the array
        local rojoC =getObject("Conditions[LuzRCon]")
        local amarilloC =getObject("Conditions[LuzACon]")
        local verdeC =getObject("Conditions[LuzVCon]")
        --rojoC:setValue(VConditionValue, true)
        --amarilloC:setValue(VConditionValue, true)
        --verdeC:setValue(VConditionValue, true)
        print(rojoC)
        print(amarilloC)
        print(verdeC)
        --startAnimation("Scenes[fabrica].SceneObjects[luz_amarilla].ObjectAnimations[AnimLA]")
        for i = 1,10,1 do
            print(arraysimon[i] )            
                if arraysimon[i] ==1 then
                amarilloC:setValue(VConditionValue, true)
                startAction("Scenes[fabrica].SceneActions[p1]")
                amarilloC:setValue(VConditionValue, false)
                --startAnimation("Scenes[fabrica].SceneObjects[luz_amarilla].ObjectAnimations[AnimLA]")
                
    
                print("animacion 1 "..i)
                end
                if arraysimon[i] ==2 then
                verdeC:setValue(VConditionValue, true)
                startAction("Scenes[fabrica].SceneActions[p2]")
                verdeC:setValue(VConditionValue, false)
                --startAnimation("Scenes[fabrica].SceneObjects[luz_verde].ObjectAnimations[AnimLV]")
                
    
                print("animacion 2 "..i)
                end
                if arraysimon[i] ==3 then
                rojoC:setValue(VConditionValue, true)
                startAction("Scenes[fabrica].SceneActions[p3]")
                rojoC:setValue(VConditionValue, false)
                --startAnimation("Scenes[fabrica].SceneObjects[luz_roja].ObjectAnimations[AnimLR]")
                
    
                print("animacion 3 "..i)
                end
    
    
    
        end
    --amarilloC:setValue(VConditionValue, false)
    --verdeC:setValue(VConditionValue, false)
    --rojoC:setValue(VConditionValue, false)
    --wait(5)
    --sleep(50)
    
        --rojoC:setValue(VConditionValue, false)
        --amarilloC:setValue(VConditionValue, false)
        --verdeC:setValue(VConditionValue, false)
        print ("Array size"..table.getn(arraysimon))
    
    
    
    
    end
    
    

    Newbie

    1 Posts


  • #2, by afrlmeFriday, 20. February 2015, 15:58 7 years ago
    When you trigger an animation via an action part there is a wait until animation has finished parameter. There's also action parts available for telling the system to wait until an animation or sound has finished playing or character reaches destination, etc...

    The pause & wait for action parts only pause the action list in which the action is found.

    Lua script however does not have a pause function, for pausing between each line of code. It is considerably more complicated than that. You could write a function that checks system time against x time & or use tables to iterate through a list of actions, but it's considerably more complicated than using actions & action parts for pausing between actions.

    I'm guessing your Simon Says game is some kind of pattern generation thing, in which the player has to remember the order that something was played in?

    Would you be willing to send me the .ved file & resources for this mini-game, so that I can get a clearer understanding of what it is that you are trying to do?

    Imperator

    7052 Posts