]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/cpp_api/s_modchannels.cpp
Move `setlocale` from Lua to C++.
[dragonfireclient.git] / src / script / cpp_api / s_modchannels.cpp
1 /*
2 Minetest
3 Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "s_modchannels.h"
21 #include "s_internal.h"
22
23 void ScriptApiModChannels::on_modchannel_message(const std::string &channel,
24                 const std::string &sender, const std::string &message)
25 {
26         SCRIPTAPI_PRECHECKHEADER
27
28         // Get core.registered_on_generateds
29         lua_getglobal(L, "core");
30         lua_getfield(L, -1, "registered_on_modchannel_message");
31         // Call callbacks
32         lua_pushstring(L, channel.c_str());
33         lua_pushstring(L, sender.c_str());
34         lua_pushstring(L, message.c_str());
35         runCallbacks(3, RUN_CALLBACKS_MODE_AND);
36 }
37
38 void ScriptApiModChannels::on_modchannel_signal(
39                 const std::string &channel, ModChannelSignal signal)
40 {
41         SCRIPTAPI_PRECHECKHEADER
42
43         // Get core.registered_on_generateds
44         lua_getglobal(L, "core");
45         lua_getfield(L, -1, "registered_on_modchannel_signal");
46         // Call callbacks
47         lua_pushstring(L, channel.c_str());
48         lua_pushinteger(L, (int)signal);
49         runCallbacks(2, RUN_CALLBACKS_MODE_AND);
50 }