[SOLVED] variable params?

In Director 1.3 you can use params, like:

director:changeScene( { level="1" } , "level", "crossFade" )  

How can you make level=“1” variable?

I tried:

local Level = "1"  
local Test = "level=" .. string.char(34) .. Level .. string.char(34)  
director:changeScene( { Test } , "level", "crossFade" )  

Although i don’t get any errors, the level param on the receiving file is not detected. Test in this case contains level=“1”

The file level.lua starts with:

if type( params ) == "table" then  
 --  
 if type( params.level ) == "string" then  
 Level = params.level   
 print ("Level received: " .. Level )  
 end  
end  

Anybody know how to do this?

[import]uid: 50459 topic_id: 12726 reply_id: 312726[/import]

@rmbsoft,
I guess you need to read up a bit on tables.

what you are after can be achieved as

local test = {}
test[“level”] = “1” –

now pass this to director

director:changeScene( test, “level”, “crossFade” )

to change it, just use test.level = "2"
or test.level = "whatever you want"

hope that was what you were after…

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 12726 reply_id: 46654[/import]

Hi,

I tried that, but the level= parameter is still not detected in level.lua

[import]uid: 50459 topic_id: 12726 reply_id: 46661[/import]

what did you try mate?

you have tried this code,

[lua]local test = {}
test[“level”]=“1”

director:changeScene( test, “level”, “crossFade”) [/lua]

and it does not work? Paste your code if possible…
BTW, I have not yet had a play with Director, maybe the problem is how you pass it to director and what it expects.
cheers,

?:slight_smile: [import]uid: 3826 topic_id: 12726 reply_id: 46662[/import]

and should the file level.lua receive the parameters?? I need to look at the new version of Director.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 12726 reply_id: 46663[/import]

I tried this:

local test = {}  
test["level"]="1"  
  
director:changeScene( { test } , "level", "crossFade" )  

And here’s how level.lua starts trying to detect the parameter:

if type( params ) == "table" then  
 --  
 if type( params.level ) == "string" then  
 Level = params.level   
 print ("Level received: " .. Level )  
 end  
end  
  

[import]uid: 50459 topic_id: 12726 reply_id: 46667[/import]

How can you make level=“1” variable?

num = ‘“1”’ level = “level=”…num
[import]uid: 53445 topic_id: 12726 reply_id: 46665[/import]

@rmbsoft,
Mate, see you are not copying the code I send you, you are trying to modify it your way. I said read up on tables.

I ask you to pass the table test as ( test, “level”…)
but you keep sending it as ( {test}, “level” … )

what you are doing is making a table out of a table, where as I am asking you to pass the table.

in my example, you will get

param.level=“1”

in your example, you will get

param.test.level=“1”

that is why it is not working,

Please copy it right and it will work for you,

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 12726 reply_id: 46740[/import]

I see the error now!

I guess i read up on tables indeed :wink:

Thanks mate, it’s working!

[import]uid: 50459 topic_id: 12726 reply_id: 46810[/import]