# HG changeset patch # User Matthew Wild # Date 1247110495 -3600 # Node ID 0f895c06e03f7c6addbaba6166eaa023ff416e9a # Parent 330b8437ac354e6e574cc68b2b53fc20c6dcb2fa mod_console: Check for commands when not executing in the global environment diff -r 330b8437ac35 -r 0f895c06e03f plugins/mod_console.lua --- a/plugins/mod_console.lua Wed Jul 08 16:53:59 2009 +0100 +++ b/plugins/mod_console.lua Thu Jul 09 04:34:55 2009 +0100 @@ -65,7 +65,10 @@ (function(session, data) local useglobalenv; - if data:match("[!.]$") then + if data:match("^>") then + data = data:gsub("^>", ""); + useglobalenv = true; + else local command = data:lower(); command = data:match("^%w+") or data:match("%p"); if commands[command] then @@ -74,11 +77,6 @@ end end - if data:match("^>") then - data = data:gsub("^>", ""); - useglobalenv = true; - end - session.env._ = data; local chunk, err = loadstring("return "..data); @@ -97,6 +95,11 @@ local ranok, taskok, message = pcall(chunk); + if not (ranok or message or useglobalenv) and commands[data:lower()] then + commands[data:lower()](session, data); + return; + end + if not ranok then session.print("Fatal error while running command, it did not complete"); session.print("Error: "..taskok);