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.
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