pass lua code via TILED properties

continuation of conversation started in twitter (i should have started here in the first place)…

here’s what we wrote in twitter:

h5apps: @MonkeyDead lime rocks! any way to pass LUA code via tiled properties? like random rotate in attached pic? thx! http://yfrog.com/h4wj4ycj

monkeydead: @h5apps Corona (or Apple?) don’t allow the “dofile()” function. However I have just thought of a possible solution.

adambuchweitz: @MonkeyDead @h5apps Really? I’ve been wanting that forever! Please doshare your solution!

monkeydead: @AdamBuchweitz @h5apps Well it’s more of a sneaky workaround then a solution. http://dl.dropbox.com/u/571145/readme.txt

[import]uid: 24493 topic_id: 6847 reply_id: 306847[/import]

… so my brute force idea was to take the code for printing properties from the 3rd LIME tutorial at http://www.justaddli.me/tutorial.php?t=0&id=2

-- Loop through our tiles for i=1, #tiles, 1 do -- Get a list of all properties on the current tile local tileProperties = tiles[i]:getProperties() -- Loop through the properties, if any for key, value in pairs(tileProperties) do -- Get the current property local property = tileProperties[key] -- Print out its Name and Value print(property:getName(), property:getValue()) end end

then parse property:getName for the string “lua” then if true somehow convert property:getValue into lua’ese like math.Random or something

that’s as far as I got - still playing

[import]uid: 24493 topic_id: 6847 reply_id: 23895[/import]

Hehe, just posted this - http://developer.anscamobile.com/forum/2011/02/19/introducing-seeds [import]uid: 5833 topic_id: 6847 reply_id: 23896[/import]

oh that’s funny… and awesome! thanks! [import]uid: 24493 topic_id: 6847 reply_id: 23897[/import]

I think we posted at the same time. I hope it’s close to what you were after. [import]uid: 5833 topic_id: 6847 reply_id: 23898[/import]

I’m sure it will - i just completed your tutorial on config.files (http://www.justaddli.me/tutorial.php?t=0&id=14) the nested and multiple config files concept is incredible! thanks again! [import]uid: 24493 topic_id: 6847 reply_id: 23943[/import]

Glad you like it!

I really like config files in general, after using then extensively at the company I did my industrial placement at I have used them in near every major project since then.

I fully recommend using them in non Lime projects too so feel free to “borrow” any of the config file code you like for other projects. [import]uid: 5833 topic_id: 6847 reply_id: 23945[/import]

I agree that the nested config files is a great feature.

The only thing that bit me was the subtle difference between “configFile” and “configFiles”, and that one works for the Tiled property only while the other one only inside a config file.

Not sure why that difference is needed -would be nice to have consistency if possible - or at least a bold warning sign to alert newbies on the difference :wink:

-FS.
[import]uid: 8093 topic_id: 6847 reply_id: 23948[/import]

Whoops, that lack of consistency would be another oversight. Will see what I have missed off and get it sorted. Glad you like it though :slight_smile: [import]uid: 5833 topic_id: 6847 reply_id: 23950[/import]