Instanced commands aren't loading

Relevant level1.lua code

function scene:enterScene( event )  
 local group = self.view  
 physics.start()  
 playerMove = controls.determineDirection  
 controls.toggleDetection({yes="true", target=playerMove})  
end  

The full controls.lua

module(..., package.seeall);  
  
function determineDirection(e)  
 if (e) then  
 print("it exists!")  
 end  
 local changeInY = e.yStart - e.y  
 local changeInX = e.xStart - e.x  
 if (e.phase == "ended") then  
 if (math.abs(changeInX) \> math.abs(changeInY)) -- Change in X is greater then change in Y  
 then  
 if (changeInX \> 0) -- Change in X is positive  
 then  
 print("Moving Left")  
 Player:applyLinearImpulse(0,0,Player.x,Player.Y)  
 elseif (changeInX\< 0) -- Change in X is negative   
 then  
 Player:applyLinearImpulse(0,0,Player.x,Player.Y)  
 print("Moving Right")  
 else -- If neither produce an error  
 end  
 elseif (math.abs(changeInX) \< math.abs(changeInY)) -- Change in Y is greater then change in X  
 then  
 if (changeInY\> 0) -- Change in Y is positive  
 then  
 Player:applyLinearImpulse(0,0,Player.x,Player.Y)  
 print("Moving Up")  
 elseif (changeInY\< 0) -- Change in Y is negative   
 then  
 Player:applyLinearImpulse(0,0,Player.x,Player.Y)  
 print("Moving Down")  
 else -- If neither produce an error  
 end  
 else -- If neither produce an error  
 end  
 end  
end  
function toggleDetection(param)  
 if (param.yes == true)then  
 Runtime:addEventListener("touch", param.target)  
 elseif (param.yes == false)then  
 Runtime:removeEventListener( "touch", param.target)  
 end  
 print(param.yes)  
 print(param.target)  
 if (param.target == determineDirection)  
 then  
 print("They're the same")  
 end  
end  

Terminal Output

true  
FUNCTION: 0E93F98  
They're the same  

Basically I’m trying to create a modular control scheme. Because due to the nature of our game we want more then 1 way to control the player.

Currently we have a player.lua which returns a “player” display object with all the physics and what not applied.

We have a control.lua which has two functions. One enables and disable movement for a specific target, in this case it’s the player. And another which interprets the touch information and adds an impulse the “player”.

In the level.lua we create an instance of control.lua function that determines the direction and adds impulse, and then we toggle touch detection on.

The problem is that “e” for some reason never reaches the instanced function and I have no idea why. Alternatively, is it possible to change the properties of something in one module from another without instancing the function? (E.G. Change “Player”'s [Which is located in level1.lua) velocity by adding impulse to it from (controls.lua)? [import]uid: 123782 topic_id: 22410 reply_id: 322410[/import]