Hi I’m getting nuts with this error, please can anybody assist:
Runtime error
…tK0iCwFUOGTxnGoM+l4k+++TI/TemporaryItems/10/main.lua:43: attempt to call field ‘targetNearestEnemy’ (a nil value)
stack traceback:
[C]: in function ‘targetNearestEnemy’
…tK0iCwFUOGTxnGoM+l4k+++TI/TemporaryItems/10/main.lua:43: in function <…tk0icwfuogtxngom>
?: in function <?:214>
I just want to call a function from the module:
main.lua<br>...<br><br>local enemy = display.newRect( game, 100, 20, 30, 25 )<br>enemy.enemyType = "cell_enem_normal";<br>tab_enemigos[#tab_enemigos+1]= enemy;<br><br>local function mover(event)<br> transition.to( player, { time=1500, x=event.x, y=event.y } )<br>end<br><br>Runtime:addEventListener("touch", mover)<br><br>local function duplicar(event)<br> if event.phase == "ended" then<br> local newCell = celula.new({cellType="cell_division", x=player.x, y=player.y});<br> game:insert(newCell)<br> print(#tab_enemigos)<br> newCell.targetNearestEnemy(tab_enemigos);<br> end<br>end<br><br>
module celula<br><br>module(..., package.seeall);<br><br>function new(params)<br>...<br>end<br><br>function targetNearestEnemy(enemigosTab)<br> <br> local enemigosCercanos = {};<br> <br> for i,enemActual in ipairs(enemigosTab) do<br> --local enemActual = enemigosTab[i];<br> print(enemActual.enemyType)<br> <br> end<br> <br>end<br>
Thanks!. [import]uid: 8933 topic_id: 7648 reply_id: 307648[/import] </…tk0icwfuogtxngom>