I get the mainLoop events & so on but the mouseEvent syntax makes absolutely no sense to me at all ... it looks like bloody gibberish!!!
ok so I understand:
registerEventHandler('mouseEvent', 'function_name')
-- * this syntax example is not very clear at all! * --
registerEventHandler(event, eventHandler [, eventFlags] )
keep an eye on this message as I will be editing this post to link a wiki page - with the correct syntax - which will explain in detail about the registerEventHandler along with various examples!
*** edit: link here! not finished yet mind!
*** ignore this for now too!
same issue ... it skips past any mouseEvents until it gets to the last one ...
for example if I add more than 1 mouse event to a script or even 1 mouse invent per script then ...
registerEventHandler('mouseEvent', 'OnLeftButtonPress', {eEvtMouseLeftButtonDown}) -- skips this one for some unknown reason! :(
registerEventHandler('mouseEvent', 'OnMwUp', {eEvtMouseWheelUp}) -- skips this one for some unknown reason! :(
registerEventHandler('mouseEvent', 'OnMwDown', {eEvtMouseWheelDown}) -- only this one works!
timerInitialized = false
callsList = {}
nextEvent = 0
function onMainLoop()
if nextEvent > 0 and os.clock() > nextEvent then
callsList[1].func()
callsList[1].nextCall = os.clock() + callsList[1].delay
if callsList[1].times > 0 then
callsList[1].times = callsList[1].times - 1
if callsList[1].times == 0 then
table.remove(callsList, 1)
end
end
setNextEvent()
end
end
-- Delay is in seconds. It is a real positive number
function delayCall(delay, func, times)
if delay <= 0 then
return
end
if not timerInitialized then
timerInitialized = true
registerEventHandler('mainLoop', 'onMainLoop')
end
local newCall = {delay = delay, func = func, times = times, nextCall = os.clock() + delay}
table.insert(callsList, newCall)
setNextEvent()
end
function setNextEvent()
if table.maxn(callsList) == 0 then
nextEvent = 0
else
table.sort(callsList, compareDelays)
nextEvent = callsList[1].nextCall
end
end
function compareDelays(callA, callB)
if (callA.nextCall > callB.nextCall) then
return false
else
return true
end
end
delayCall(5, testA, 0)
delayCall(10, testB, 2)
delayCall(15, testC, 1)
function onMainLoop()
-- check if a certain condition is met so that it knows if the function should be called or not ...
if cond or if variable_state = x then
function_name()
end
end