user3352895
user3352895

Reputation: 21

Corona SDK Boolean Value Multiple Lua File

i am new on programming with LUA. i have a problem with multiple lua files. i wanna call a function another lua file but it doesnt. it says boolean value. thanks for your helps. here is code:

Main Lua:

local centerX = display.contentCenterX
local centerY = display.contentCenterY
local _W = display.contentWidth
local _H = display.contentHeight

local background = display.newImage( "facebook_bkg.png", centerX, centerY, true )

local face =require("face")

local postphoto = face.postphoto    

facebutton = display.newImageRect("fbButton184.png",247,46)
    facebutton.anchorX = 0.5
    facebutton.anchorY = 1
    facebutton:scale(3,3)
    facebutton.x = display.contentCenterX
    facebutton.y = display.contentCenterY 


facebutton:addEventListener("touch", postphoto) 

Face Lua:

function postphoto (event)

    display.newText ("12313", centerX,centerY,native.systemFont, 50)

    end

Upvotes: 0

Views: 93

Answers (1)

Advert
Advert

Reputation: 653

First, it's Lua, not LUA. Doing this is akin to walking into a Microsoft convention with Apple products. (Jokes aside, Lua is not an acronym (at 'What's in a name?), really!)

On to your code: In the main.lua file, you're defining local variables. These cannot be seen by anything in the face.lua file (centerX, centerY)

You're also defining postphoto as a global in face.lua, then after you require it, you define a local postphoto.

Try this in face.lua:

local Face = {}

function Face.postphoto (event)
  display.newText ("12313", centerX,centerY,native.systemFont, 50)
end

return Face

Upvotes: 1

Related Questions