mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Remplement and improve /setting in Lua, now called /set
This commit is contained in:
parent
b54178bbbd
commit
8ecfd88d92
4 changed files with 81 additions and 66 deletions
|
@ -3800,6 +3800,15 @@ static int l_register_craft(lua_State *L)
|
|||
return 0; /* number of results */
|
||||
}
|
||||
|
||||
// setting_set(name, value)
|
||||
static int l_setting_set(lua_State *L)
|
||||
{
|
||||
const char *name = luaL_checkstring(L, 1);
|
||||
const char *value = luaL_checkstring(L, 2);
|
||||
g_settings->set(name, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// setting_get(name)
|
||||
static int l_setting_get(lua_State *L)
|
||||
{
|
||||
|
@ -4006,6 +4015,7 @@ static const struct luaL_Reg minetest_f [] = {
|
|||
{"register_item_raw", l_register_item_raw},
|
||||
{"register_alias_raw", l_register_alias_raw},
|
||||
{"register_craft", l_register_craft},
|
||||
{"setting_set", l_setting_set},
|
||||
{"setting_get", l_setting_get},
|
||||
{"setting_getbool", l_setting_getbool},
|
||||
{"chat_send_all", l_chat_send_all},
|
||||
|
|
|
@ -79,30 +79,6 @@ void cmd_shutdown(std::wostringstream &os,
|
|||
ctx->flags |= SEND_TO_OTHERS;
|
||||
}
|
||||
|
||||
void cmd_setting(std::wostringstream &os,
|
||||
ServerCommandContext *ctx)
|
||||
{
|
||||
if(!ctx->server->checkPriv(ctx->player->getName(), "server"))
|
||||
{
|
||||
os<<L"-!- You don't have permission to do that";
|
||||
return;
|
||||
}
|
||||
|
||||
/*std::string confline = wide_to_narrow(
|
||||
ctx->parms[1] + L" = " + ctx->params[2]);*/
|
||||
|
||||
std::string confline = wide_to_narrow(ctx->paramstring);
|
||||
|
||||
actionstream<<ctx->player->getName()
|
||||
<<" sets: "<<confline<<std::endl;
|
||||
|
||||
g_settings->parseConfigLine(confline);
|
||||
|
||||
ctx->server->saveConfig();
|
||||
|
||||
os<< L"-!- Setting changed and configuration saved.";
|
||||
}
|
||||
|
||||
void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx)
|
||||
{
|
||||
if(!ctx->server->checkPriv(ctx->player->getName(), "ban"))
|
||||
|
@ -194,8 +170,6 @@ std::wstring processServerCommand(ServerCommandContext *ctx)
|
|||
cmd_time(os, ctx);
|
||||
else if(ctx->parms[0] == L"shutdown")
|
||||
cmd_shutdown(os, ctx);
|
||||
else if(ctx->parms[0] == L"setting")
|
||||
cmd_setting(os, ctx);
|
||||
else if(ctx->parms[0] == L"ban" || ctx->parms[0] == L"unban")
|
||||
cmd_banunban(os, ctx);
|
||||
else if(ctx->parms[0] == L"me")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue