Skip to content

Commit

Permalink
add sim.reloadSave, tpt.selectedreplace
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Mar 13, 2014
1 parent c6d6011 commit 258aaed
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/gui/game/GameController.cpp
Expand Up @@ -149,6 +149,7 @@ GameController::GameController():
ActiveToolChanged(0, gameModel->GetActiveTool(0));
ActiveToolChanged(1, gameModel->GetActiveTool(1));
ActiveToolChanged(2, gameModel->GetActiveTool(2));
ActiveToolChanged(3, gameModel->GetActiveTool(3));

//sim = new Simulation();
Client::Ref().AddListener(this);
Expand Down
4 changes: 3 additions & 1 deletion src/lua/LegacyLuaAPI.cpp
Expand Up @@ -588,12 +588,13 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel)
return mpcontinue;
}

int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::string selectalt, int bsx, int bsy)
int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::string selectalt, std::string selectreplace, int bsx, int bsy)
{
int i, j, callret;
lua_State* l=luacon_ci->l;
lua_pushinteger(l, bsy);
lua_pushinteger(l, bsx);
lua_pushstring(l, selectreplace.c_str());
lua_pushstring(l, selectalt.c_str());
lua_pushstring(l, selectr.c_str());
lua_pushstring(l, selectl.c_str());
Expand All @@ -604,6 +605,7 @@ int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::s
lua_setfield(l, tptProperties, "selectedl");
lua_setfield(l, tptProperties, "selectedr");
lua_setfield(l, tptProperties, "selecteda");
lua_setfield(l, tptProperties, "selectedreplace");
lua_setfield(l, tptProperties, "brushx");
lua_setfield(l, tptProperties, "brushy");
lua_pushstring(l, "stepfunctions");
Expand Down
2 changes: 1 addition & 1 deletion src/lua/LuaScriptHelper.h
Expand Up @@ -21,7 +21,7 @@ extern int tptElements; //Table for TPT element names
extern int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex;

void luacon_hook(lua_State *L, lua_Debug *ar);
int luacon_step(int mx, int my, std::string , std::string selectr, std::string selectedalt, int bsx, int bsy);
int luacon_step(int mx, int my, std::string , std::string selectr, std::string selectedalt, std::string selectedreplace, int bsx, int bsy);
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
int luacon_keyevent(int key, int modifier, int event);
int luacon_eval(const char *command);
Expand Down
9 changes: 8 additions & 1 deletion src/lua/LuaScriptInterface.cpp
Expand Up @@ -483,6 +483,7 @@ void LuaScriptInterface::initSimulationAPI()
{"loadStamp", simulation_loadStamp},
{"deleteStamp", simulation_deleteStamp},
{"loadSave", simulation_loadSave},
{"reloadSave", simulation_reloadSave},
{"getSaveID", simulation_getSaveID},
{"adjustCoords", simulation_adjustCoords},
{"prettyPowders", simulation_prettyPowders},
Expand Down Expand Up @@ -1430,6 +1431,12 @@ int LuaScriptInterface::simulation_loadSave(lua_State * l)
return 0;
}

int LuaScriptInterface::simulation_reloadSave(lua_State * l)
{
luacon_controller->ReloadSim();
return 0;
}

int LuaScriptInterface::simulation_getSaveID(lua_State *l)
{
SaveInfo *tempSave = luacon_model->GetSave();
Expand Down Expand Up @@ -2851,7 +2858,7 @@ void LuaScriptInterface::OnTick()
ui::Engine::Ref().LastTick(gettime());
if(luacon_mousedown)
luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0);
luacon_step(luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_selectedalt, luacon_brushx, luacon_brushy);
luacon_step(luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_selectedalt, luacon_selectedreplace, luacon_brushx, luacon_brushy);
}

int LuaScriptInterface::Command(std::string command)
Expand Down
1 change: 1 addition & 0 deletions src/lua/LuaScriptInterface.h
Expand Up @@ -88,6 +88,7 @@ class LuaScriptInterface: public CommandInterface
static int simulation_loadStamp(lua_State * l);
static int simulation_deleteStamp(lua_State * l);
static int simulation_loadSave(lua_State * l);
static int simulation_reloadSave(lua_State * l);
static int simulation_getSaveID(lua_State * l);
static int simulation_adjustCoords(lua_State * l);
static int simulation_prettyPowders(lua_State * l);
Expand Down

0 comments on commit 258aaed

Please sign in to comment.