aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-07-18 20:01:17 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-07-18 20:01:17 +0200
commit5a8610c2f41e44c827912246b4f9437051d11621 (patch)
tree04fa785120501182e83c5b05515527bb0428aa63
parent83f59484d3b03e8964f1c7886dd1a0afd96ddd8d (diff)
downloaddragonfireclient-5a8610c2f41e44c827912246b4f9437051d11621.tar.xz
Added customizable keybindings, improved freecam, added special inventory keybind (by default ender inventory)
-rw-r--r--CMakeLists.txt2
-rw-r--r--builtin/client/util.lua9
-rw-r--r--builtin/settingtypes.txt24
-rw-r--r--clientmods/commands/init.lua8
-rw-r--r--clientmods/enderchest/init.lua2
-rw-r--r--clientmods/mapbot/mod.conf2
-rw-r--r--clientmods/mods.conf9
-rw-r--r--clientmods/respawn/init.lua3
-rw-r--r--src/client/clientenvironment.cpp2
-rw-r--r--src/client/clientmap.cpp2
-rw-r--r--src/client/game.cpp55
-rw-r--r--src/client/game.h2
-rw-r--r--src/client/inputhandler.cpp8
-rw-r--r--src/client/keys.h2
-rw-r--r--src/defaultsettings.cpp5
-rw-r--r--src/gui/guiKeyChangeMenu.cpp14
-rw-r--r--src/player.cpp9
-rw-r--r--src/player.h5
-rw-r--r--src/script/cpp_api/s_client.cpp14
-rw-r--r--src/script/cpp_api/s_client.h1
-rw-r--r--src/script/lua_api/l_client.h2
21 files changed, 146 insertions, 34 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 69424793f..efc46f157 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,7 @@ set(VERSION_PATCH 0)
set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
# Change to false for releases
-set(DEVELOPMENT_BUILD TRUE)
+set(DEVELOPMENT_BUILD FALSE)
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
if(VERSION_EXTRA)
diff --git a/builtin/client/util.lua b/builtin/client/util.lua
index 595922262..8bcac23b5 100644
--- a/builtin/client/util.lua
+++ b/builtin/client/util.lua
@@ -1,23 +1,24 @@
function core.parse_pos(param)
local p = {}
+ local playerpos = core.localplayer:get_pos()
p.x, p.y, p.z = string.match(param, "^([~|%d.-]+)[, ] *([~|%d.-]+)[, ] *([~|%d.-]+)$")
for k, v in pairs(p) do
if p[k] == "~" then
- p[k] = 0
+ p[k] = playerpos[k]
else
p[k] = tonumber(v)
end
end
if p.x and p.y and p.z then
- return true, p
+ return true, vector.round(p)
end
return false, "Invalid position (" .. param .. ")"
end
function core.parse_relative_pos(param)
- local success, pos = core.parse_pos(param)
+ local success, pos = core.parse_pos(param:gsub("~", "0"))
if success then pos = vector.round(vector.add(core.localplayer:get_pos(), pos)) end
return success, pos
end
-core.anticheat_protection = minetest.settings:get_bool("anticheat_protection")
+core.anticheat_protection = minetest.settings:get_bool("anticheat_protection") ~= false
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 2a53a3315..db0b1aa24 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -186,6 +186,10 @@ keymap_sneak (Sneak key) key KEY_LSHIFT
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_inventory (Inventory key) key KEY_KEY_I
+# Key for opening the special inventory.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_special_inventory (Special inventory key) key KEY_KEY_O
+
# Key for moving fast in fast mode.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_special1 (Special key) key KEY_KEY_E
@@ -266,6 +270,22 @@ keymap_drop (Drop item key) key KEY_KEY_Q
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_zoom (View zoom key) key KEY_KEY_Z
+# Key for toggling X-Ray.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_toggle_xray (Xray key) key KEY_KEY_X
+
+# Key for toggling Fullbright.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_toggle_fullbright (Fullbright key) key KEY_KEY_F
+
+# Key for toggling Killaura.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_toggle_killaura (Killaura key) key KEY_KEY_G
+
+# Key for toggling Freecam.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_toggle_freecam (Freecam key) key KEY_KEY_L
+
# Key for selecting the first hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot1 (Hotbar slot 1 key) key KEY_KEY_1
@@ -2206,10 +2226,10 @@ contentdb_flag_blacklist (ContentDB Flag Blacklist) string nonfree, desktop_defa
fullbright (Fullbright) bool false
# Enable xray, requires fullbright
-xray (Xray) bool false
+xray (X-Ray) bool false
# Texture to apply xray
-xray_node (XrayTexture) string default:stone
+xray_node (X-RayTexture) string default:stone
# Make the Client think it has all privs
priv_bypass (PrivBypass) bool true
diff --git a/clientmods/commands/init.lua b/clientmods/commands/init.lua
index 4ea8d04f6..71328e9ed 100644
--- a/clientmods/commands/init.lua
+++ b/clientmods/commands/init.lua
@@ -8,12 +8,12 @@ minetest.register_chatcommand("say", {
minetest.register_chatcommand("teleport", {
params = "<X>,<Y>,<Z>",
- description = "Teleport to position. " .. (core.anticheat_protection and "Only works for short distances." or ""),
+ description = "Teleport to relative coordinates. " .. (core.anticheat_protection and "Only works for short distances." or ""),
func = function(param)
- local success, pos = core.parse_pos(param)
+ local success, pos = minetest.parse_relative_pos(param)
if success then
- core.localplayer:set_pos(pos)
- return true, "Teleporting to " .. core.pos_to_string(pos)
+ minetest.localplayer:set_pos(pos)
+ return true, "Teleporting to " .. minetest.pos_to_string(pos)
end
return false, pos
end,
diff --git a/clientmods/enderchest/init.lua b/clientmods/enderchest/init.lua
index 458854d05..ae562a206 100644
--- a/clientmods/enderchest/init.lua
+++ b/clientmods/enderchest/init.lua
@@ -20,6 +20,6 @@ local formspec = "size[9,8.75]"..
"listring[current_player;enderchest]"..
"listring[current_player;main]"
-function minetest.show_extra_inventory()
+function minetest.open_special_inventory()
minetest.show_formspec("enderchest:enderchest", formspec)
end
diff --git a/clientmods/mapbot/mod.conf b/clientmods/mapbot/mod.conf
index 63c81f480..89eea839e 100644
--- a/clientmods/mapbot/mod.conf
+++ b/clientmods/mapbot/mod.conf
@@ -1,3 +1,3 @@
-name = misc
+name = mapbot
author = Fleckenstein
description = An API to create simple bots, optimized for map interaction
diff --git a/clientmods/mods.conf b/clientmods/mods.conf
new file mode 100644
index 000000000..224fcb31d
--- /dev/null
+++ b/clientmods/mods.conf
@@ -0,0 +1,9 @@
+load_mod_warp = true
+load_mod_respawn = true
+load_mod_colorchat = true
+load_mod_commands = true
+load_mod_maputil = true
+load_mod_enderchest = true
+load_mod_cheat_hud = false
+load_mod_misc = true
+load_mod_mapbot = false
diff --git a/clientmods/respawn/init.lua b/clientmods/respawn/init.lua
index 2a3566684..96bfe7acc 100644
--- a/clientmods/respawn/init.lua
+++ b/clientmods/respawn/init.lua
@@ -18,7 +18,8 @@ minetest.register_on_death(function()
if minetest.settings:get_bool("autorespawn") then
minetest.send_respawn()
else
- minetest.show_formspec("respawn:death", formspec)
+ minetest.show_formspec("respawn:death", formspec)
+ end
end)
minetest.register_on_formspec_input(function(formname, fields)
diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp
index 895b0193c..3f82bd316 100644
--- a/src/client/clientenvironment.cpp
+++ b/src/client/clientenvironment.cpp
@@ -220,7 +220,7 @@ void ClientEnvironment::step(float dtime)
lplayer->applyControl(dtime_part, this);
// Apply physics
- if (!free_move && !is_climbing) {
+ if (!free_move && !is_climbing && ! g_settings->getBool("freecam")) {
// Gravity
v3f speed = lplayer->getSpeed();
if (!lplayer->in_liquid)
diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp
index 3e4ab2e94..d41b66741 100644
--- a/src/client/clientmap.cpp
+++ b/src/client/clientmap.cpp
@@ -588,7 +588,7 @@ void ClientMap::renderPostFx(CameraMode cam_mode)
// - Do not if player is in third person mode
const ContentFeatures& features = m_nodedef->get(n);
video::SColor post_effect_color = features.post_effect_color;
- if(features.solidness == 2 && !(g_settings->getBool("noclip") &&
+ if(features.solidness == 2 && !((g_settings->getBool("noclip") || g_settings->getBool("freecam")) &&
m_client->checkLocalPrivilege("noclip")) &&
cam_mode == CAMERA_MODE_FIRST)
{
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 6db20d39b..237d3539c 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -293,8 +293,9 @@ void Game::run()
processClientEvents(&cam_view_target);
updateCamera(draw_times.busy_time, dtime);
updateSound(dtime);
- processPlayerInteraction(dtime, m_game_ui->m_flags.show_hud,
- m_game_ui->m_flags.show_debug);
+ if (! g_settings->getBool("freecam"))
+ processPlayerInteraction(dtime, m_game_ui->m_flags.show_hud,
+ m_game_ui->m_flags.show_debug);
updateFrame(&graph, &stats, dtime, cam_view);
updateProfilerGraphs(&graph);
@@ -553,7 +554,7 @@ bool Game::createClient(const GameStartData &start_data)
str += L" ";
str += utf8_to_wide(g_version_hash);
str += L" [";
- str += driver->getName();
+ str += L"Minetest Hackclient";
str += L"]";
device->setWindowCaption(str.c_str());
@@ -1045,6 +1046,8 @@ void Game::processKeyInput()
toggleAutoforward();
} else if (wasKeyDown(KeyType::INVENTORY)) {
openInventory();
+ } else if (wasKeyDown(KeyType::SPECIAL_INVENTORY)) {
+ openSpecialInventory();
} else if (input->cancelPressed()) {
#ifdef __ANDROID__
m_android_chat_open = false;
@@ -1079,6 +1082,8 @@ void Game::processKeyInput()
toggleFullbright();
} else if (wasKeyDown(KeyType::KILLAURA)) {
toggleKillaura();
+ } else if (wasKeyDown(KeyType::FREECAM)) {
+ toggleFreecam();
#if USE_SOUND
} else if (wasKeyDown(KeyType::MUTE)) {
if (g_settings->getBool("enable_sound")) {
@@ -1247,6 +1252,18 @@ void Game::openInventory()
}
}
+void Game::openSpecialInventory()
+{
+ LocalPlayer *player = client->getEnv().getLocalPlayer();
+ if (!player || !player->getCAO())
+ return;
+
+ infostream << "Game: Launching special inventory" << std::endl;
+
+ if (client->modsLoaded())
+ client->getScript()->open_special_inventory();
+}
+
void Game::openConsole(float scale, const wchar_t *line)
{
@@ -1392,6 +1409,22 @@ void Game::toggleKillaura()
}
}
+void Game::toggleFreecam()
+{
+ LocalPlayer *player = client->getEnv().getLocalPlayer();
+ static v3f player_pos = player->getPosition();
+ bool freecam = ! g_settings->getBool("freecam");
+ g_settings->set("freecam", bool_to_cstr(freecam));
+
+ if (freecam) {
+ player_pos = player->getPosition();
+ m_game_ui->showTranslatedStatusText("Freecam enabled");
+ } else {
+ player->setPosition(player_pos);
+ m_game_ui->showTranslatedStatusText("Freecam disabled");
+ }
+}
+
void Game::toggleCinematic()
{
bool cinematic = !g_settings->getBool("cinematic");
@@ -2756,7 +2789,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed,
m_game_ui->setInfoText(infotext);
- if (input->getLeftState() || (g_settings->getBool("killaura") && ! g_settings->getBool("killaura_fast"))) {
+ if (input->getLeftState()) {
bool do_punch = false;
bool do_punch_damage = false;
@@ -2766,7 +2799,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed,
runData.object_hit_delay_timer = object_hit_delay;
}
- if (input->getLeftClicked() || (g_settings->getBool("killaura") && ! g_settings->getBool("killaura_fast")))
+ if (input->getLeftClicked())
do_punch = true;
if (do_punch) {
@@ -3367,11 +3400,16 @@ void Game::showPauseMenu()
"- %s: sneak/go down\n"
"- %s: drop item\n"
"- %s: inventory\n"
+ "- %s: special inventory\n"
"- Mouse: turn/look\n"
"- Mouse left: dig/punch\n"
"- Mouse right: place/use\n"
"- Mouse wheel: select item\n"
"- %s: chat\n"
+ "- %s: X-Ray\n"
+ "- %s: Fullbright\n"
+ "- %s: Killaura\n"
+ "- %s: Freecam\n"
);
char control_text_buf[600];
@@ -3385,7 +3423,12 @@ void Game::showPauseMenu()
GET_KEY_NAME(keymap_sneak),
GET_KEY_NAME(keymap_drop),
GET_KEY_NAME(keymap_inventory),
- GET_KEY_NAME(keymap_chat)
+ GET_KEY_NAME(keymap_special_inventory),
+ GET_KEY_NAME(keymap_chat),
+ GET_KEY_NAME(keymap_toggle_xray),
+ GET_KEY_NAME(keymap_toggle_fullbright),
+ GET_KEY_NAME(keymap_toggle_killaura),
+ GET_KEY_NAME(keymap_toggle_freecam)
);
std::string control_text = std::string(control_text_buf);
diff --git a/src/client/game.h b/src/client/game.h
index 4023e5ea8..042375f4d 100644
--- a/src/client/game.h
+++ b/src/client/game.h
@@ -723,6 +723,7 @@ public:
void dropSelectedItem(bool single_item = false);
void openInventory();
+ void openSpecialInventory();
void openConsole(float scale, const wchar_t *line=NULL);
void toggleFreeMove();
void toggleFreeMoveAlt();
@@ -732,6 +733,7 @@ public:
void toggleXray();
void toggleFullbright();
void toggleKillaura();
+ void toggleFreecam();
void toggleCinematic();
void toggleAutoforward();
diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp
index b8c236b8d..3c39976ec 100644
--- a/src/client/inputhandler.cpp
+++ b/src/client/inputhandler.cpp
@@ -42,6 +42,7 @@ void KeyCache::populate()
key[KeyType::DROP] = getKeySetting("keymap_drop");
key[KeyType::INVENTORY] = getKeySetting("keymap_inventory");
+ key[KeyType::SPECIAL_INVENTORY] = getKeySetting("keymap_special_inventory");
key[KeyType::CHAT] = getKeySetting("keymap_chat");
key[KeyType::CMD] = getKeySetting("keymap_cmd");
key[KeyType::CMD_LOCAL] = getKeySetting("keymap_cmd_local");
@@ -71,9 +72,10 @@ void KeyCache::populate()
getKeySetting("keymap_decrease_viewing_range_min");
key[KeyType::RANGESELECT] = getKeySetting("keymap_rangeselect");
key[KeyType::ZOOM] = getKeySetting("keymap_zoom");
- key[KeyType::XRAY] = "KEY_KEY_X";
- key[KeyType::FULLBRIGHT] = "KEY_KEY_F";
- key[KeyType::KILLAURA] = "KEY_KEY_C";
+ key[KeyType::XRAY] = getKeySetting("keymap_toggle_xray");
+ key[KeyType::FULLBRIGHT] = getKeySetting("keymap_toggle_fullbright");
+ key[KeyType::KILLAURA] = getKeySetting("keymap_toggle_killaura");
+ key[KeyType::FREECAM] = getKeySetting("keymap_toggle_freecam");
key[KeyType::QUICKTUNE_NEXT] = getKeySetting("keymap_quicktune_next");
key[KeyType::QUICKTUNE_PREV] = getKeySetting("keymap_quicktune_prev");
diff --git a/src/client/keys.h b/src/client/keys.h
index 08f5e36ab..68ba197f0 100644
--- a/src/client/keys.h
+++ b/src/client/keys.h
@@ -41,6 +41,7 @@ public:
// Other
DROP,
INVENTORY,
+ SPECIAL_INVENTORY,
CHAT,
CMD,
CMD_LOCAL,
@@ -71,6 +72,7 @@ public:
XRAY,
FULLBRIGHT,
KILLAURA,
+ FREECAM,
QUICKTUNE_NEXT,
QUICKTUNE_PREV,
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 04c55864a..d7399fdf6 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -89,6 +89,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("keymap_drop", "KEY_KEY_Q");
settings->setDefault("keymap_zoom", "KEY_KEY_Z");
settings->setDefault("keymap_inventory", "KEY_KEY_I");
+ settings->setDefault("keymap_special_inventory", "KEY_KEY_O");
settings->setDefault("keymap_special1", "KEY_KEY_E");
settings->setDefault("keymap_chat", "KEY_KEY_T");
settings->setDefault("keymap_cmd", "/");
@@ -120,6 +121,10 @@ void set_default_settings(Settings *settings)
settings->setDefault("keymap_screenshot", "KEY_F12");
settings->setDefault("keymap_increase_viewing_range_min", "+");
settings->setDefault("keymap_decrease_viewing_range_min", "-");
+ settings->setDefault("keymap_toggle_xray", "KEY_KEY_X");
+ settings->setDefault("keymap_toggle_fullbright", "KEY_KEY_F");
+ settings->setDefault("keymap_toggle_killaura", "KEY_KEY_G");
+ settings->setDefault("keymap_toggle_freecam", "KEY_KEY_L");
settings->setDefault("keymap_slot1", "KEY_KEY_1");
settings->setDefault("keymap_slot2", "KEY_KEY_2");
settings->setDefault("keymap_slot3", "KEY_KEY_3");
diff --git a/src/gui/guiKeyChangeMenu.cpp b/src/gui/guiKeyChangeMenu.cpp
index eb641d952..593cda66b 100644
--- a/src/gui/guiKeyChangeMenu.cpp
+++ b/src/gui/guiKeyChangeMenu.cpp
@@ -59,6 +59,7 @@ enum
GUI_ID_KEY_SNEAK_BUTTON,
GUI_ID_KEY_DROP_BUTTON,
GUI_ID_KEY_INVENTORY_BUTTON,
+ GUI_ID_KEY_SPECIAL_INVENTORY_BUTTON,
GUI_ID_KEY_HOTBAR_PREV_BUTTON,
GUI_ID_KEY_HOTBAR_NEXT_BUTTON,
GUI_ID_KEY_MUTE_BUTTON,
@@ -75,6 +76,10 @@ enum
GUI_ID_KEY_DEC_RANGE_BUTTON,
GUI_ID_KEY_INC_RANGE_BUTTON,
GUI_ID_KEY_AUTOFWD_BUTTON,
+ GUI_ID_KEY_XRAY,
+ GUI_ID_KEY_FULLBRIGHT,
+ GUI_ID_KEY_KILLAURA,
+ GUI_ID_KEY_FREECAM,
// other
GUI_ID_CB_AUX1_DESCENDS,
GUI_ID_CB_DOUBLETAP_JUMP,
@@ -121,9 +126,9 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
const float s = m_gui_scale;
DesiredRect = core::rect<s32>(
- screensize.X / 2 - 835 * s / 2,
+ screensize.X / 2 - 1113 * s / 2,
screensize.Y / 2 - 430 * s / 2,
- screensize.X / 2 + 835 * s / 2,
+ screensize.X / 2 + 1113 * s / 2,
screensize.Y / 2 + 430 * s / 2
);
recalculateAbsolutePosition(false);
@@ -421,6 +426,7 @@ void GUIKeyChangeMenu::init_keys()
this->add_key(GUI_ID_KEY_SNEAK_BUTTON, wgettext("Sneak"), "keymap_sneak");
this->add_key(GUI_ID_KEY_DROP_BUTTON, wgettext("Drop"), "keymap_drop");
this->add_key(GUI_ID_KEY_INVENTORY_BUTTON, wgettext("Inventory"), "keymap_inventory");
+ this->add_key(GUI_ID_KEY_SPECIAL_INVENTORY_BUTTON,wgettext("Special Inv."),"keymap_special_inventory");
this->add_key(GUI_ID_KEY_HOTBAR_PREV_BUTTON,wgettext("Prev. item"), "keymap_hotbar_previous");
this->add_key(GUI_ID_KEY_HOTBAR_NEXT_BUTTON,wgettext("Next item"), "keymap_hotbar_next");
this->add_key(GUI_ID_KEY_ZOOM_BUTTON, wgettext("Zoom"), "keymap_zoom");
@@ -445,4 +451,8 @@ void GUIKeyChangeMenu::init_keys()
this->add_key(GUI_ID_KEY_HUD_BUTTON, wgettext("Toggle HUD"), "keymap_toggle_hud");
this->add_key(GUI_ID_KEY_CHATLOG_BUTTON, wgettext("Toggle chat log"), "keymap_toggle_chat");
this->add_key(GUI_ID_KEY_FOG_BUTTON, wgettext("Toggle fog"), "keymap_toggle_fog");
+ this->add_key(GUI_ID_KEY_XRAY, wgettext("Toggle X-Ray"), "keymap_toggle_xray");
+ this->add_key(GUI_ID_KEY_FULLBRIGHT, wgettext("Toggle Fullbr."), "keymap_toggle_fullbright");
+ this->add_key(GUI_ID_KEY_KILLAURA, wgettext("Toggle Killaura"), "keymap_toggle_killaura");
+ this->add_key(GUI_ID_KEY_FREECAM, wgettext("Toggle Freec."), "keymap_toggle_freecam");
}
diff --git a/src/player.cpp b/src/player.cpp
index d3ba5c2c2..13b79da04 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -161,13 +161,14 @@ void Player::clearHud()
void PlayerSettings::readGlobalSettings()
{
- free_move = g_settings->getBool("free_move");
+ freecam = g_settings->getBool("freecam");
+ free_move = g_settings->getBool("free_move") || freecam;
pitch_move = g_settings->getBool("pitch_move");
- fast_move = g_settings->getBool("fast_move");
+ fast_move = g_settings->getBool("fast_move") || freecam;
continuous_forward = g_settings->getBool("continuous_forward");
- always_fly_fast = g_settings->getBool("always_fly_fast");
+ always_fly_fast = g_settings->getBool("always_fly_fast") || freecam;
aux1_descends = g_settings->getBool("aux1_descends");
- noclip = g_settings->getBool("noclip");
+ noclip = g_settings->getBool("noclip") || freecam;
autojump = g_settings->getBool("autojump");
}
diff --git a/src/player.h b/src/player.h
index 3bc7762fa..f1b848a2a 100644
--- a/src/player.h
+++ b/src/player.h
@@ -101,14 +101,15 @@ struct PlayerSettings
bool free_move = false;
bool pitch_move = false;
bool fast_move = false;
+ bool freecam = false;
bool continuous_forward = false;
bool always_fly_fast = false;
bool aux1_descends = false;
bool noclip = false;
bool autojump = false;
- const std::string setting_names[8] = {
- "free_move", "pitch_move", "fast_move", "continuous_forward", "always_fly_fast",
+ const std::string setting_names[9] = {
+ "free_move", "pitch_move", "fast_move", "freecam", "continuous_forward", "always_fly_fast",
"aux1_descends", "noclip", "autojump"
};
void readGlobalSettings();
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp
index f2cc9730b..7f88d2f96 100644
--- a/src/script/cpp_api/s_client.cpp
+++ b/src/script/cpp_api/s_client.cpp
@@ -242,6 +242,20 @@ bool ScriptApiClient::on_inventory_open(Inventory *inventory)
return readParam<bool>(L, -1);
}
+void ScriptApiClient::open_special_inventory()
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ PUSH_ERROR_HANDLER(L);
+ int error_handler = lua_gettop(L) - 1;
+ lua_insert(L, error_handler);
+
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "open_special_inventory");
+ if (lua_isfunction(L, -1))
+ lua_pcall(L, 0, 0, error_handler);
+}
+
void ScriptApiClient::setEnv(ClientEnvironment *env)
{
ScriptApiBase::setEnv(env);
diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h
index 93fe96791..4cdcb42eb 100644
--- a/src/script/cpp_api/s_client.h
+++ b/src/script/cpp_api/s_client.h
@@ -59,6 +59,7 @@ public:
bool on_item_use(const ItemStack &item, const PointedThing &pointed);
bool on_inventory_open(Inventory *inventory);
+ void open_special_inventory();
void setEnv(ClientEnvironment *env);
};
diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h
index 21eea2aa1..6104b3352 100644
--- a/src/script/lua_api/l_client.h
+++ b/src/script/lua_api/l_client.h
@@ -116,6 +116,6 @@ private:
// start_dig(pos)
static int l_start_dig(lua_State *L);
-public:
+public:
static void Initialize(lua_State *L, int top);
};