summaryrefslogtreecommitdiff
path: root/src/cat
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
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')
-rw-r--r--src/cat/CommandInterface.h2
-rw-r--r--src/cat/LuaScriptHelper.h3
-rw-r--r--src/cat/LuaScriptInterface.cpp17
-rw-r--r--src/cat/LuaScriptInterface.h3
4 files changed, 19 insertions, 6 deletions
diff --git a/src/cat/CommandInterface.h b/src/cat/CommandInterface.h
index 8cabdab..ca480dd 100644
--- a/src/cat/CommandInterface.h
+++ b/src/cat/CommandInterface.h
@@ -31,7 +31,7 @@ public:
virtual bool OnMouseWheel(int x, int y, int d) {return true;}
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
- virtual void OnTick(float dt) {}
+ virtual void OnTick() {}
virtual int Command(std::string command);
virtual std::string FormatCommand(std::string command);
std::string GetLastError();
diff --git a/src/cat/LuaScriptHelper.h b/src/cat/LuaScriptHelper.h
index a9aa02d..b5b885d 100644
--- a/src/cat/LuaScriptHelper.h
+++ b/src/cat/LuaScriptHelper.h
@@ -13,6 +13,9 @@ Simulation * luacon_sim;
LuaScriptInterface * luacon_ci;
Graphics * luacon_g;
+bool *luacon_currentCommand;
+string *luacon_lastError;
+
int *lua_el_func, *lua_el_mode;
int getPartIndex_curIdx;
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;
}
diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h
index b3ecd7a..a346b1a 100644
--- a/src/cat/LuaScriptInterface.h
+++ b/src/cat/LuaScriptInterface.h
@@ -36,6 +36,7 @@ extern "C"
class LuaScriptInterface: public CommandInterface {
int luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_mousebutton;
bool luacon_mousedown;
+ bool currentCommand;
public:
lua_State *l;
LuaScriptInterface(GameModel * m);
@@ -45,7 +46,7 @@ public:
virtual bool OnMouseWheel(int x, int y, int d);
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
- virtual void OnTick(float dt);
+ virtual void OnTick();
virtual int Command(std::string command);
virtual std::string FormatCommand(std::string command);
virtual ~LuaScriptInterface();