diff options
author | red-001 <red-001@outlook.ie> | 2017-01-24 16:26:15 +0000 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-03-13 23:56:05 +0100 |
commit | c42c53fccf87a3819ca78de52f8f20c47c4fbb9f (patch) | |
tree | 223bb0b18e989cfe7eb8f7d712bd606976be2c77 /src/script/cpp_api/s_client.cpp | |
parent | 2c19d51409ca903021e0b508e5bc15299c4e51dc (diff) | |
download | minetest-c42c53fccf87a3819ca78de52f8f20c47c4fbb9f.tar.gz minetest-c42c53fccf87a3819ca78de52f8f20c47c4fbb9f.tar.bz2 minetest-c42c53fccf87a3819ca78de52f8f20c47c4fbb9f.zip |
[CSM] Add local formspecs. (#5094)
Diffstat (limited to 'src/script/cpp_api/s_client.cpp')
-rw-r--r-- | src/script/cpp_api/s_client.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp index ce88d67e3..1827d483b 100644 --- a/src/script/cpp_api/s_client.cpp +++ b/src/script/cpp_api/s_client.cpp @@ -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); +} |