Skip to content

Commit

Permalink
Added a ~lua: prefix for flagging non-WML errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
silene committed Jul 25, 2010
1 parent 4ab0dcb commit e5562a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion data/lua/wml-tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ function wml_actions.lua(cfg)
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)
Expand Down
6 changes: 6 additions & 0 deletions src/scripting/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ bool luaW_pcall(lua_State *L
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';
Expand Down

0 comments on commit e5562a1

Please sign in to comment.