mail[Wesnoth-commits] r44678 - in /trunk: data/lua/wml-tags.lua src/scripting/lua.cpp


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

Header


Content

Posted by guillaume . melquiond on July 25, 2010 - 17:34:
Author: silene
Date: Sun Jul 25 17:34:04 2010
New Revision: 44678

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44678&view=rev
Log:
Added a ~lua: prefix for flagging non-WML errors.

Modified:
    trunk/data/lua/wml-tags.lua
    trunk/src/scripting/lua.cpp

Modified: trunk/data/lua/wml-tags.lua
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/lua/wml-tags.lua?rev=44678&r1=44677&r2=44678&view=diff
==============================================================================
--- trunk/data/lua/wml-tags.lua (original)
+++ trunk/data/lua/wml-tags.lua Sun Jul 25 17:34:04 2010
@@ -272,7 +272,9 @@
        args.y2 = ev.y2
        table.insert(args, ev[1])
        table.insert(args, ev[2])
-       assert(loadstring(cfg.code or ""))(args)
+       local bytecode, message = loadstring(cfg.code or "")
+       if not bytecode then error("~lua:" .. message, 0) end
+       bytecode(args)
 end
 
 function wml_actions.music(cfg)

Modified: trunk/src/scripting/lua.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/scripting/lua.cpp?rev=44678&r1=44677&r2=44678&view=diff
==============================================================================
--- trunk/src/scripting/lua.cpp (original)
+++ trunk/src/scripting/lua.cpp Sun Jul 25 17:34:04 2010
@@ -392,6 +392,12 @@
                        m += 5;
                        char const *e = strstr(m, "stack traceback");
                        lg::wml_error << std::string(m, e ? e - m : 
strlen(m));
+               } else if (allow_wml_error && strncmp(m, "~lua:", 5) == 0) {
+                       m += 5;
+                       char const *e = NULL, *em = m;
+                       while (em[0] && ((em = strstr(em + 1, "stack 
traceback"))))
+                               e = em;
+                       chat_message("Lua error", std::string(m, e ? e - m : 
strlen(m)));
                } else {
                        chat_message("Lua error", m);
                        ERR_LUA << m << '\n';




Related Messages


Powered by MHonArc, Updated Sun Jul 25 17:40:14 2010