# HG changeset patch # User belphegorr # Date 1343060159 -10800 # Node ID 644eabbc9218e93db1ad3829d53c9e5174a05537 # Parent 158f8fb74deddb075d070adbaee2bc71e2613b16 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once. diff -r 158f8fb74ded -r 644eabbc9218 share/hedgewars/Data/Scripts/Animate.lua --- a/share/hedgewars/Data/Scripts/Animate.lua Sat Jul 21 01:54:41 2012 +0300 +++ b/share/hedgewars/Data/Scripts/Animate.lua Mon Jul 23 19:15:59 2012 +0300 @@ -11,7 +11,7 @@ skipFuncList[anim] = {sfunc = func, sargs = args} end -function RemoveSkipFunctin(anim) +function RemoveSkipFunction(anim) skipFuncList[anim] = nil end @@ -323,6 +323,18 @@ stageEvents[seNum].evType = evType end +function AddNewEvent(condFunc, condArgs, doFunc, doArgs, evType) + local i + for i = 1, seNum do + if stageEvents[i].cFunc == condFunc and stageEvents[i].cArgs == condArgs and + stageEvents[i].dFunc == doFunc and stageEvents[i].dArgs == doArgs and + stageEvents[seNum].evType == evType then + return + end + end + AddEvent(condFunc, condArgs, doFunc, doArgs, evType) +end + function RemoveEvent(evNum) if stageEvents[evNum] ~= nil then seNum = seNum - 1