summaryrefslogtreecommitdiff
path: root/src/cat/LuaScriptInterface.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-04-04 20:47:58 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-04-04 20:47:58 (GMT)
commitea51cde1f07d2a63f824e78c44adad0993115853 (patch)
treea6afee4bafb5de2f91caf1235351b7cc6fc2e606 /src/cat/LuaScriptInterface.cpp
parent89cdeef9ad9c164e9f484cded3096bcbc72b7207 (diff)
downloadpowder-ea51cde1f07d2a63f824e78c44adad0993115853.zip
powder-ea51cde1f07d2a63f824e78c44adad0993115853.tar.gz
Change brush size with [ and ] keys, change order of drawing for Lua, Fix print and tpt.log so they log to the console when it is open
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
-rw-r--r--src/cat/LuaScriptInterface.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 617577b..3da7284 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -13,7 +13,8 @@
#include "LuaScriptHelper.h"
LuaScriptInterface::LuaScriptInterface(GameModel * m):
- CommandInterface(m)
+ CommandInterface(m),
+ currentCommand(false)
{
int i = 0, j;
char tmpname[12];
@@ -77,6 +78,9 @@ LuaScriptInterface::LuaScriptInterface(GameModel * m):
{NULL,NULL}
};
+ luacon_currentCommand = &currentCommand;
+ luacon_lastError = &lastError;
+
luacon_model = m;
luacon_sim = m->GetSimulation();
luacon_g = ui::Engine::Ref().g;
@@ -246,7 +250,7 @@ bool LuaScriptInterface::OnKeyRelease(int key, Uint16 character, bool shift, boo
return luacon_keyevent(key, /*TODO: sdl_mod*/0, LUACON_KUP);
}
-void LuaScriptInterface::OnTick(float dt)
+void LuaScriptInterface::OnTick()
{
if(luacon_mousedown)
luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS);
@@ -257,11 +261,13 @@ int LuaScriptInterface::Command(std::string command)
{
int ret;
lastError = "";
+ currentCommand = true;
if((ret = luaL_dostring(l, command.c_str())))
{
lastError = luacon_geterror();
- Log(LogError, lastError);
+ //Log(LogError, lastError);
}
+ currentCommand = false;
return ret;
}
@@ -977,7 +983,10 @@ int luatpt_setconsole(lua_State* l)
int luatpt_log(lua_State* l)
{
- luacon_ci->Log(CommandInterface::LogNotice, luaL_optstring(l, 1, ""));
+ if((*luacon_currentCommand) && !(*luacon_lastError).length())
+ (*luacon_lastError) = luaL_optstring(l, 1, "");
+ else
+ luacon_ci->Log(CommandInterface::LogNotice, luaL_optstring(l, 1, ""));
return 0;
}