params trouble

Hello,

i have a problems with global functions and params

in main.lua i have:
[lua]local ui = require(“ui”)

ui.foo{name = img}[/lua]

and in ui.lua:
[lua]module(…,package.seeall)

local img3 = display.newCircle(0,0,50)
img3:setFillColor(0,255,0)
img3.isVisible = false

function foo(params)
local name = params.name
name.isVisible = true
end[/lua]

i cant figure out why its not working, i anyone can help- it will be hugely appreciated [import]uid: 16142 topic_id: 15536 reply_id: 315536[/import]

Are you trying to show/hide the img3 in the ui.lua?

if yes,

  1. it is called img3
  2. it is local to ui.lua only, not accessible from outside

so, what you need to do is

  1. change main.lua to
local ui = require("ui")  
local img3 = display.newCircle(0,0,50)  
img3:setFillColor(0,255,0)  
img3.isVisible = false  
  
ui.foo {name=img3}  

and ui.lua to

module(...,package.seeall)  
   
function foo(params)  
 local name = params.name  
 name.isVisible = true  
end  

that should work for you.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 15536 reply_id: 57429[/import]

is there any way to hide/show image that stored specificly in ui.lua? i want it to stay there, because its an interface that must be shown across all screens

or am i doing something wrong, and this kind of interface must be done another way?

thanks anyway) [import]uid: 16142 topic_id: 15536 reply_id: 57474[/import]

bump i guess… i dont exactly need this approach, but it still very interesting to know if there is a way to pass parameters to external functions like that [import]uid: 16142 topic_id: 15536 reply_id: 57656[/import]