ReCalling a function

Hi, i need to call a function into another function, how can i do that?
This is my code

  
local onUpdate = function(event)  
 local vx,vy = player:getLinearVelocity()  
 if math.abs (vy) \<= 40 and math.abs (vx) \<= 40 then  
  
 --Here i would like to recall my other function "changeDir"  
 else  
 end  
  
 map:setTrackingPoint(player)  
 map:update(event)  
--   
end  
Runtime:addEventListener("enterFrame", onUpdate)  
  
local changeDir = function (event)  
  
end  
  

It should be really simple, but i can’t! :frowning:
Please, help me, i need to recall my function many times in my app.

Thanx!!
Paolo
[import]uid: 30837 topic_id: 6713 reply_id: 306713[/import]

[lua]local changeDir – forward reference

local onUpdate = function(event)
local vx,vy = player:getLinearVelocity()
if math.abs (vy) <= 40 and math.abs (vx) <= 40 then

–Here i would like to recall my other function “changeDir”
else
end

map:setTrackingPoint(player)
map:update(event)

end
Runtime:addEventListener(“enterFrame”, onUpdate)

changeDir = function (event)

end[/lua]

or you could have defined [lua]local changeDir=function[/lua] first before your onUpdate function [import]uid: 6645 topic_id: 6713 reply_id: 23421[/import]

It seems that this doesn’t work properly, i need to call my function changeDir every time i’m in if-block. Is this possible?

[code]
local changeDir – forward reference

local onUpdate = function(event)
local vx,vy = player:getLinearVelocity()
if math.abs (vy) <= 40 and math.abs (vx) <= 40 then

–Here i would like to recall my other function “changeDir”
else
end

map:setTrackingPoint(player)
map:update(event)

end
Runtime:addEventListener(“enterFrame”, onUpdate)

changeDir = function (event)
–block
end [import]uid: 30837 topic_id: 6713 reply_id: 23425[/import]