Murga-Projects Forums
Little converter script enhancement - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: Little converter script enhancement (/showthread.php?tid=18)


Little converter script enhancement - Tobi - 05-11-2007 01:07 AM

Hello folks!

The current convertFluidToMurgaLua.lua script has problems with objects that have a custom name (you can set an object's name in the Name field of the C++ tab).
It does not replace the "->" by ":" for such objects.
But custom named objects make it really cool to use fluid, one can reference them directly in the lua script without the need to create the reference to each local object by hand.
I made a few changes that fix this. In the script find this

Code:
-- Convert object notation
currentLine = string.gsub(currentLine, 'o%->', "object:")


Add the following after this to handle custom named objects:

Code:
-- Convert object notation of named objects
currentLine = string.gsub(currentLine, '%w+%->', "%1:")
currentLine = string.gsub(currentLine, '->:', ":")
-- handle special case where custom object name ends with o (all o's get replaced with object, so need that in the constructor as well)
currentLine = string.gsub(currentLine, "o = fltk:Fl_", "object = fltk:Fl_")


Greetings,

Tobi