Page 1 of 1

Filter for custom properties

Posted: Thu Jun 06, 2013 8:19 am
by toojee
Hi! I do an importer rube to flash (citrusengine) and I need a system to filter custom properties.
For now, I create a custom properties "citrusClass" with a combobox attributes like Hero, Enemy, Platform, Coin etc... In flash the class is directly created, so for example, a circle with Enemy in Rube, start to move automaticly in flash! The Hero, can move by keyboard key and jump on head of enemy to kill him without any code! Thanks to CitrusEngine :D

But all citrus classes (Hero, Platform etc... ) don't have obsiouly the same properties, for MovingPlatform I need startX, startY, endX and endY. But for a cannon I need fireRate, startingDirection, missileFuseDuration etc...
Right now, with Rube I can do all that, but its pretty messy :D
If we can link combobox properties to others, maybe like shapes tree in fixture, its will be more clear.

But I can do without it! Its a optionnal request :D

Re: Filter for custom properties

Posted: Thu Jun 06, 2013 8:51 am
by iforce2d
Take a look at this thread, which covers almost the same issue: https://www.iforce2d.net/forums/viewtopic.php?f=6&t=38

I'm hoping to add this in one of the next few updates...

Re: Filter for custom properties

Posted: Thu Jun 06, 2013 9:36 am
by toojee
ok cool!
But I copy and paste the code and I have an error and I don't understand why :
line 2, col 14: Expected '('

Re: Filter for custom properties

Posted: Thu Jun 06, 2013 11:12 am
by iforce2d
If you're talking about the first code block in that post, that is only there as a proposal of what the script might look like when that capability is added.

Edit: ah, but that does not explain why the script does not compile... to declare functions in the script you need to also have a void main() somewhere in the script as well. If there is no void main() anywhere, the script will be treated as if the entire thing was inside a void main() function. This is a little unclear perhaps, but you can find more info about this in the main help (F1) in the section "Scripting" -> "Defining your own functions".

Re: Filter for custom properties

Posted: Thu Jun 06, 2013 11:44 am
by toojee
oh ok I was thinking we can do that by script but not directly in the panel.

Re: Filter for custom properties

Posted: Thu Jun 06, 2013 12:45 pm
by iforce2d
Not yet :) It will require the application to pass the body to the script to work with, and the application will also have to read back the result from the script as well, so it's more complicated than just saying "run!" like the script does now, through the main() function which has no parameters, and returns nothing.

Re: Filter for custom properties

Posted: Wed Sep 25, 2013 4:26 pm
by iforce2d
This has been implemented in v1.5. The application calls a script function for each property, so you need to fill in functions like this:

Code: Select all

bool shouldDisplayProperty( body b, const string& in propertyName )
See the "Property display filter" section of this video: http://www.youtube.com/watch?v=K-VzlEtXdJM
... or search for 'shouldDisplayProperty' in the help.