1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

[CSM] Add local formspecs. (#5094)

This commit is contained in:
red-001 2017-01-24 16:26:15 +00:00 committed by Loïc Blot
parent 2c19d51409
commit c42c53fccf
12 changed files with 126 additions and 67 deletions

View file

@ -112,3 +112,27 @@ void ScriptApiClient::environment_step(float dtime)
+ script_get_backtrace(L));
}
}
void ScriptApiClient::on_formspec_input(const std::string &formname,
const StringMap &fields)
{
SCRIPTAPI_PRECHECKHEADER
// Get core.registered_on_chat_messages
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_formspec_input");
// Call callbacks
// param 1
lua_pushstring(L, formname.c_str());
// param 2
lua_newtable(L);
StringMap::const_iterator it;
for (it = fields.begin(); it != fields.end(); ++it) {
const std::string &name = it->first;
const std::string &value = it->second;
lua_pushstring(L, name.c_str());
lua_pushlstring(L, value.c_str(), value.size());
lua_settable(L, -3);
}
runCallbacks(2, RUN_CALLBACKS_MODE_OR_SC);
}