Pass command to the callback functions
authorMikael Berthe <mikael@lilotux.net>
Thu, 15 Apr 2010 19:21:41 +0200
changeset 18 615c9b336207
parent 17 d941ef833b4a
child 19 96e08713cb6a
Pass command to the callback functions Add mcbot_get_command_list() helper function
mcbot/mcbot_engine.lua
--- a/mcbot/mcbot_engine.lua	Thu Apr 15 19:05:58 2010 +0200
+++ b/mcbot/mcbot_engine.lua	Thu Apr 15 19:21:41 2010 +0200
@@ -17,6 +17,10 @@
     commands[name] = object
 end
 
+function mcbot_get_command_list ()
+    return commands
+end
+
 require "cmds.wtf"
 require "cmds.calc"
 require "cmds.spell"
@@ -38,9 +42,10 @@
         cmd, arg = line:match("^(%w+)%s+(.*)")
     end
     if cmd then
+        local lccmd = cmd:lower()
         for name, obj in pairs(commands) do
-            if cmd and cmd:lower() == name then
-                return obj.cmd(arg, botdata)
+            if lccmd == name then
+                return obj.cmd(arg, botdata, cmd)
             end
         end
     else