access object defined in module from main

Given the following:

example.lua
-----------
module(..., package.seeall)

function xyz()
local pgBtn = display.newRoundedRect(125, 400, 100, 70, 12)
pgBtn.strokeWidth = 3
pgBtn:setFillColor(51, 0, 255)
pgBtn:setStrokeColor(51, 153, 255)

midBtn:insert(pgBtn)

local pgBtntext = display.newText(abc, 145,415, native.systemFont, 50)

midBtn:insert(pgBtntext)
end
--------
main.lua
--------
require("example")

1. how can I change the value of "abc" from main ?
2. how can I change the fillcolor & strokecolorfrom main ?

in main.lua use
abc = whatevervalue

and in example.lua use
_G.abc

thats it. :)

check the below example...
this sample will give you a better idea

main.lua

1
2
3
4
5
6
7
8
9
10
11
12
13
local file2 =require("file2")
--global variable a
a = 10
 
file2:fn1()
--prints 10 -- we din't set _G.a in fn1
print(a)
 
 
file2:fn2()
 
--prints 25-- we set _G.a in fn2
print(a)

@renvis@technowand

Thx's, just what I needed.

views:1425 update:2011/10/7 17:24:19
corona forums © 2003-2011