mail[Wesnoth-commits] r44321 - /trunk/data/lua/helper.lua


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on July 18, 2010 - 23:39:
Author: silene
Date: Sun Jul 18 23:39:06 2010
New Revision: 44321

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44321&view=rev
Log:
Added two helper functions parsed and literal for handling uniformly WML 
tables and vconfig objects.

Modified:
    trunk/data/lua/helper.lua

Modified: trunk/data/lua/helper.lua
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/lua/helper.lua?rev=44321&r1=44320&r2=44321&view=diff
==============================================================================
--- trunk/data/lua/helper.lua (original)
+++ trunk/data/lua/helper.lua Sun Jul 18 23:39:06 2010
@@ -271,4 +271,26 @@
        return math.max(hdist, vdist + math.floor(hdist / 2))
 end
 
+function helper.literal(cfg)
+       local t = type(cfg)
+       if t == "table" then
+               return cfg
+       elseif t == "userdata" then
+               return cfg.__literal
+       else
+               return cfg or {}
+       end
+end
+
+function helper.parsed(cfg)
+       local t = type(cfg)
+       if t == "table" then
+               return tovconfig(cfg).__parsed
+       elseif t == "userdata" then
+               return cfg.__parsed
+       else
+               return cfg or {}
+       end
+end
+
 return helper




Related Messages


Powered by MHonArc, Updated Sun Jul 18 23:40:11 2010