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

... 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

1
2
3
4
5
6
7
8
9
10
11
12
-- 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

oh that's funny... and awesome! thanks!

I think we posted at the same time. I hope it's close to what you were after.

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!

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.

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 ;-)

-FS.

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 :-)

views:1460 update:2011/10/13 16:39:51
corona forums © 2003-2011