Here is my situation:
main.lua – requires A.lua and B.lua
A.lua – requires B.lua
is the above bad? What happens exactly when i do the above? Does B get included once or twice?
Below is what i am trying to do. A and B are modules, however B module does nothing aside from letting main.lua and A.lua share variable information.
-- main.lua
-- click on red square to deduct health
local b = require "B"
local a = require "A"
b.health = 100
local function HIT( event )
if event.phase == "ended" then
a.deductHealth()
print( s.health )
end
end
local function main()
local img = display.newImage( "redsquare.png" )
img.x = display.contentWidth / 2
img.y = display.contentHeight/ 2
img:addEventListener( "touch", HIT )
end
main()
-- A.lua
local b = require "B"
local a = {}
local function test()
b.health = b.health - 1
end
a.deductHealth = test
return a
[code]
– B.lua
local b = {}
return b
[/code] [import]uid: 74723 topic_id: 26220 reply_id: 326220[/import]