aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/client/chatcommands.lua2
-rw-r--r--builtin/client/cheats/chat.lua35
-rw-r--r--builtin/client/cheats/combat.lua28
-rw-r--r--builtin/client/cheats/init.lua11
-rw-r--r--builtin/client/cheats/inventory.lua48
-rw-r--r--builtin/client/cheats/world.lua17
-rw-r--r--builtin/client/util.lua15
-rw-r--r--builtin/settingtypes.txt52
-rw-r--r--doc/client_lua_api.txt14
-rw-r--r--src/client/game.cpp28
-rw-r--r--src/client/game.h1
-rw-r--r--src/defaultsettings.cpp9
-rw-r--r--src/gui/cheatMenu.cpp66
-rw-r--r--src/gui/cheatMenu.h4
-rw-r--r--src/script/lua_api/l_clientobject.cpp9
-rw-r--r--src/script/lua_api/l_clientobject.h3
-rw-r--r--src/script/lua_api/l_inventoryaction.cpp2
-rw-r--r--src/script/lua_api/l_localplayer.cpp4
18 files changed, 282 insertions, 66 deletions
diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua
index 7c3dd521e..8090b2bef 100644
--- a/builtin/client/chatcommands.lua
+++ b/builtin/client/chatcommands.lua
@@ -155,7 +155,7 @@ core.register_chatcommand("place", {
func = function(param)
local success, pos = core.parse_relative_pos(param)
if success then
- cores.place_node(pos)
+ core.place_node(pos)
return true, "Node placed at " .. core.pos_to_string(pos)
end
return false, pos
diff --git a/builtin/client/cheats/chat.lua b/builtin/client/cheats/chat.lua
index 1b8094768..0763909df 100644
--- a/builtin/client/cheats/chat.lua
+++ b/builtin/client/cheats/chat.lua
@@ -6,3 +6,38 @@ core.register_on_receiving_chat_message(function(message)
return true
end
end)
+
+function core.send_colorized(message)
+ local starts_with = message:sub(1, 1)
+
+ if starts_with == "/" or starts_with == "." then return end
+
+ local reverse = core.settings:get_bool("chat_reverse")
+
+ if reverse then
+ local msg = ""
+ for i = 1, #message do
+ msg = message:sub(i, i) .. msg
+ end
+ message = msg
+ end
+
+ local use_chat_color = core.settings:get_bool("use_chat_color")
+ local color = core.settings:get("chat_color")
+
+ if use_chat_color and color then
+ local msg
+ if color == "rainbow" then
+ msg = core.rainbow(message)
+ else
+ msg = core.colorize(color, message)
+ end
+ message = msg
+ end
+
+ core.send_chat_message(message)
+ return true
+end
+
+core.register_on_sending_chat_message(core.send_colorized)
+
diff --git a/builtin/client/cheats/combat.lua b/builtin/client/cheats/combat.lua
index b497c6c1b..4904d8c52 100644
--- a/builtin/client/cheats/combat.lua
+++ b/builtin/client/cheats/combat.lua
@@ -2,7 +2,9 @@ local placed_crystal
local switched_to_totem = 0
local used_sneak = true
local totem_move_action = InventoryAction("move")
-totem_move_action:to("current_player", "main", 8)
+totem_move_action:to("current_player", "main", 9)
+
+core.register_list_command("friend", "Configure Friend List (friends dont get attacked by Killaura or Forcefield)", "friendlist")
core.register_globalstep(function(dtime)
local player = core.localplayer
@@ -10,7 +12,25 @@ core.register_globalstep(function(dtime)
local control = player:get_control()
local pointed = core.get_pointed_thing()
local item = player:get_wielded_item():get_name()
- if core.settings:get_bool("crystal_pvp") then
+ if core.settings:get_bool("killaura") or core.settings:get_bool("forcefield") and control.LMB then
+ local friendlist = core.settings:get("friendlist"):split(",")
+ for _, obj in ipairs(core.get_objects_inside_radius(player:get_pos(), 5)) do
+ local do_attack = true
+ if obj:is_local_player() then
+ do_attack = false
+ else
+ for _, friend in ipairs(friendlist) do
+ if obj:get_name() == friend or obj:get_nametag() == friend then
+ do_attack = false
+ break
+ end
+ end
+ end
+ if do_attack then
+ obj:punch()
+ end
+ end
+ elseif core.settings:get_bool("crystal_pvp") then
if placed_crystal then
if core.switch_to_item("mobs_mc:totem") then
switched_to_totem = 5
@@ -48,9 +68,9 @@ core.register_globalstep(function(dtime)
if totem_stack and totem_stack:get_name() ~= "mobs_mc:totem" then
local totem_index = core.find_item("mobs_mc:totem")
if totem_index then
- totem_move_action:from("current_player", "main", totem_index - 1)
+ totem_move_action:from("current_player", "main", totem_index)
totem_move_action:apply()
- player:set_wield_index(8)
+ player:set_wield_index(9)
end
end
end
diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua
index a7be83cee..03fc20c60 100644
--- a/builtin/client/cheats/init.lua
+++ b/builtin/client/cheats/init.lua
@@ -1,6 +1,7 @@
core.cheats = {
["Combat"] = {
["Killaura"] = "killaura",
+ ["Forcefield"] = "forcefield",
["AntiKnockback"] = "antiknockback",
["FastHit"] = "spamclick",
["AttachmentFloat"] = "float_above_parent",
@@ -26,6 +27,7 @@ core.cheats = {
["Coords"] = "coords",
["Tracers"] = "enable_tracers",
["ESP"] = "enable_esp",
+ ["CheatHUD"] = "cheat_hud",
},
["World"] = {
["FastDig"] = "fastdig",
@@ -37,7 +39,8 @@ core.cheats = {
["ScaffoldPlus"] = "scaffold_plus",
["BlockWater"] = "block_water",
["PlaceOnTop"] = "autotnt",
- ["Replace"] = "replace"
+ ["Replace"] = "replace",
+ ["Nuke"] = "nuke",
},
["Exploit"] = {
["EntitySpeed"] = "entity_speed",
@@ -54,7 +57,9 @@ core.cheats = {
},
["Chat"] = {
["IgnoreStatus"] = "ignore_status_messages",
- ["Deathmessages"] = "mark_deathmessages"
+ ["Deathmessages"] = "mark_deathmessages",
+ ["ColoredChat"] = "use_chat_color",
+ ["ReversedChat"] = "chat_reverse",
},
["Inventory"] = {
["AutoEject"] = "autoeject",
@@ -62,6 +67,8 @@ core.cheats = {
["Enderchest"] = function() core.open_enderchest() end,
["HandSlot"] = function() core.open_handslot() end,
["NextItem"] = "next_item",
+ ["Strip"] = "strip",
+ ["AutoRefill"] = "autorefill",
}
}
diff --git a/builtin/client/cheats/inventory.lua b/builtin/client/cheats/inventory.lua
index faa7d1c0e..b9943f507 100644
--- a/builtin/client/cheats/inventory.lua
+++ b/builtin/client/cheats/inventory.lua
@@ -2,15 +2,48 @@ local elapsed_time = 0
local tick_time = 0.05
local drop_action = InventoryAction("drop")
+local strip_move_act = InventoryAction("move")
+strip_move_act:to("current_player", "craft", 1)
+local strip_craft_act = InventoryAction("craft")
+strip_craft_act:craft("current_player")
+local strip_move_back_act = InventoryAction("move")
+strip_move_back_act:from("current_player", "craftresult", 1)
+
core.register_globalstep(function(dtime)
+ local player = core.localplayer
+ if not player then return end
+ local item = player:get_wielded_item()
+ local itemdef = core.get_item_def(item:get_name())
+ local wieldindex = player:get_wield_index()
+ -- AutoRefill
+ if core.settings:get_bool("autorefill") and itemdef then
+ local space = item:get_free_space()
+ local i = core.find_item(item:get_name(), wieldindex + 1)
+ if i and space > 0 then
+ local move_act = InventoryAction("move")
+ move_act:to("current_player", "main", wieldindex)
+ move_act:from("current_player", "main", i)
+ move_act:set_count(space)
+ move_act:apply()
+ end
+ end
+ -- Strip
+ if core.settings:get_bool("strip") then
+ if itemdef and itemdef.groups.tree and player:get_control().RMB then
+ strip_move_act:from("current_player", "main", wieldindex)
+ strip_move_back_act:to("current_player", "main", wieldindex)
+ strip_move_act:apply()
+ strip_craft_act:apply()
+ strip_move_back_act:apply()
+ end
+ end
-- AutoEject
if core.settings:get_bool("autoeject") then
- local player = core.localplayer
local list = (core.settings:get("eject_items") or ""):split(",")
local inventory = core.get_inventory("current_player")
for index, stack in pairs(inventory.main) do
if table.indexof(list, stack:get_name()) ~= -1 then
- drop_action:from("current_player", "main", index - 1)
+ drop_action:from("current_player", "main", index)
drop_action:apply()
end
end
@@ -19,12 +52,8 @@ core.register_globalstep(function(dtime)
if core.settings:get_bool("next_item") then
elapsed_time = elapsed_time + dtime
if elapsed_time < tick_time then return end
- local player = minetest.localplayer
- if not player then return end
- local item = player:get_wielded_item()
if item:get_count() == 0 then
- local index = player:get_wield_index()
- player:set_wield_index(index + 1)
+ player:set_wield_index(wieldindex + 1)
end
elapsed_time = 0
end
@@ -62,7 +91,7 @@ core.register_on_punchnode(function(pos, node)
for index, stack in pairs(inventory.main) do
is_better, best_time = check_tool(stack, node_groups, best_time)
if is_better then
- new_index = index - 1
+ new_index = index
end
end
player:set_wield_index(new_index)
@@ -113,3 +142,6 @@ local hand_formspec = "size[9,8.75]"..
function core.open_handslot()
minetest.show_formspec("__builtin__:hand", hand_formspec)
end
+
+
+
diff --git a/builtin/client/cheats/world.lua b/builtin/client/cheats/world.lua
index 5b97b206b..6cbdd67fc 100644
--- a/builtin/client/cheats/world.lua
+++ b/builtin/client/cheats/world.lua
@@ -48,6 +48,23 @@ core.register_globalstep(function(dtime)
end
end
end
+ if core.settings:get_bool("nuke") then
+ local i = 0
+ for x = pos.x - 5, pos.x + 5 do
+ for y = pos.y - 5, pos.y + 5 do
+ for z = pos.z - 5, pos.z + 5 do
+ local p = vector.new(x, y, z)
+ local node = core.get_node_or_nil(p)
+ local def = node and core.get_node_def(node.name)
+ if def and def.diggable then
+ if i > nodes_per_tick then return end
+ core.dig_node(p)
+ i = i + 1
+ end
+ end
+ end
+ end
+ end
end)
diff --git a/builtin/client/util.lua b/builtin/client/util.lua
index d61b547c6..783d0ceb1 100644
--- a/builtin/client/util.lua
+++ b/builtin/client/util.lua
@@ -21,9 +21,9 @@ function core.parse_relative_pos(param)
return success, pos
end
-function core.find_item(item)
+function core.find_item(item, mini, maxi)
for index, stack in ipairs(core.get_inventory("current_player").main) do
- if stack:get_name() == item then
+ if (not mini or index >= mini) and (not maxi or index <= maxi) and stack:get_name() == item then
return index
end
end
@@ -32,7 +32,7 @@ end
function core.switch_to_item(item)
local i = core.find_item(item)
if i then
- core.localplayer:set_wield_index(i - 1)
+ core.localplayer:set_wield_index(i)
return true
else
return false
@@ -42,6 +42,11 @@ end
function core.get_pointed_thing()
local pos = core.camera:get_pos()
local pos2 = vector.add(pos, vector.multiply(core.camera:get_look_dir(), 5))
- local ray = core.raycast(pos, pos2, true, core.settings:get_bool("point_liquids") or core.get_item_def(core.localplayer:get_wielded_item():get_name()).liquids_pointable)
- return ray:next()
+ local player = core.localplayer
+ if not player then return end
+ local item = player:get_wielded_item()
+ if not item then return end
+ local def = core.get_item_def(item:get_name())
+ local ray = core.raycast(pos, pos2, true, core.settings:get_bool("point_liquids") or def and def.liquids_pointable)
+ return ray and ray:next()
end
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index ebd0ad621..620e4b355 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -2213,6 +2213,31 @@ contentdb_url (ContentDB URL) string https://content.minetest.net
# so see a full list at https://content.minetest.net/help/content_flags/
contentdb_flag_blacklist (ContentDB Flag Blacklist) string nonfree, desktop_default
+[Cheat Menu]
+
+# Font to use for cheat menu
+cheat_menu_font (MenuFont) enum FM_Standard, FM_Mono, FM_Fallback, FM_Simple, FM_SimpleMono, FM_MaxMode, FM_Unspecified
+
+# (RGB value)
+m_bg_color (Cell background color) v3f 45 45 68
+
+m_bg_color_alpha (Cell background color alpha) int 173
+
+# (RGB value)
+m_active_bg_color (Active cell background color) v3f 0 0 0
+
+m_active_bg_color_alpha (Active cell background color alpha) int 210
+
+# (RGB value)
+m_font_color (Font color) v3f 255 255 255
+
+m_font_color_alpha (Font color alpha) int 195
+
+# (RGB value)
+m_selected_font_color (Selected font color) v3f 255 255 255
+
+m_selected_font_color_alpha (Selected font color alpha) int 235
+
[Cheats]
fullbright (Fullbright) bool false
@@ -2299,27 +2324,24 @@ replace (Replace) bool false
crystal_pvp (CrystalPvP) bool false
-[Cheat Menu]
+autototem (AutoTotem) bool false
-# Font to use for cheat menu
-cheat_menu_font (MenuFont) enum FM_Standard, FM_Mono, FM_Fallback, FM_Simple, FM_SimpleMono, FM_MaxMode, FM_Unspecified
+dont_point_nodes (ThroughWalls) bool false
-# (RGB value)
-m_bg_color (Cell background color) v3f 45 45 68
+strip (Strip) bool false
-m_bg_color_alpha (Cell background color alpha) int 173
+autorefill (AutoRefill) bool false
-# (RGB value)
-m_active_bg_color (Active cell background color) v3f 0 0 0
+nuke (Nuke) bool false
-m_active_bg_color_alpha (Active cell background color alpha) int 210
+chat_color (Chat Color) string rainbow
-# (RGB value)
-m_font_color (Font color) v3f 255 255 255
+use_chat_color (ColoredChat) bool false
-m_font_color_alpha (Font color alpha) int 195
+chat_reverse (ReversedChat) bool false
-# (RGB value)
-m_selected_font_color (Selected font color) v3f 255 255 255
+forcefield (Forcefield) bool false
+
+friendlist (Killaura / Forcefield Friendlist) string
-m_selected_font_color_alpha (Selected font color alpha) int 235 \ No newline at end of file
+cheat_hud (CheatHUD) bool true \ No newline at end of file
diff --git a/doc/client_lua_api.txt b/doc/client_lua_api.txt
index 50c33940e..c332ca4c3 100644
--- a/doc/client_lua_api.txt
+++ b/doc/client_lua_api.txt
@@ -1184,9 +1184,9 @@ Methods:
* `get_name()`
* returns player name
* `get_wield_index()`
- * returns the index of the wielded item
+ * returns the index of the wielded item (starts at 1)
* `set_wield_index()`
- * sets the index
+ * sets the index (starts at 1)
* `get_wielded_item()`
* returns the itemstack the player is holding
* `is_attached()`
@@ -1296,6 +1296,8 @@ Methods:
* change a value of a previously added HUD element
* element `stat` values: `position`, `name`, `scale`, `text`, `number`, `item`, `dir`
* Returns `true` on success, otherwise returns `nil`
+* `get_object()`
+ * Returns the ClientObjectRef for the player
### Settings
An interface to read config files in the format of `minetest.conf`.
@@ -1336,6 +1338,7 @@ This is basically a reference to a C++ `GenericCAO`.
* `get_acceleration()`: returns the acceleration, a vector
* `get_rotation()`: returns the rotation, a vector (radians)
* `is_player()`: returns true if the object is a player
+* `is_local_player()`: returns true if the object is the local player
* `get_attach()`: returns parent or nil if it isn't attached.
* `get_nametag()`: returns the nametag (string)
* `get_item_textures()`: returns the textures
@@ -1717,6 +1720,7 @@ A reference to a C++ InventoryAction. You can move, drop and craft items in all
* `InventoryAction(type)`:
* creates a new InventoryAction
* type is on of "move", "drop", or "craft", else returns nil
+ * indexing starts at 1
* `apply()`:
* applies the InventoryAction (InventoryActions can be applied multible times)
* `from(inventorylocation, listname, stack)`
@@ -1736,13 +1740,13 @@ A reference to a C++ InventoryAction. You can move, drop and craft items in all
#### example
`local move_act = InventoryAction("move")
- move_act:from("current_player", "main", 0)
- move_act:to("current_player", "craft", 0)
+ move_act:from("current_player", "main", 1)
+ move_act:to("current_player", "craft", 1)
move_act:set_count(1)
local craft_act = InventoryAction("craft")
craft_act:craft("current_player")
local drop_act = InventoryAction("drop")
- drop_act:from("current_player", "craft", 0)
+ drop_act:from("current_player", "craft_result",10)
move_act:apply()
craft_act:apply()
drop_act:apply()
diff --git a/src/client/game.cpp b/src/client/game.cpp
index d8800d9ea..479484ae9 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -2453,9 +2453,6 @@ PointedThing Game::updatePointedThing(
ClientMap &map = env.getClientMap();
const NodeDefManager *nodedef = map.getNodeDefManager();
- if (g_settings->getBool("killaura"))
- handleKillaura(shootline.start, shootline.getLength());
-
runData.selected_object = NULL;
hud->pointing_at_object = false;
RaycastState s(shootline, look_for_object, liquids_pointable, ! g_settings->getBool("dont_point_nodes"));
@@ -2532,22 +2529,6 @@ PointedThing Game::updatePointedThing(
return result;
}
-void Game::handleKillaura(v3f origin, f32 max_d)
-{
- ClientEnvironment &env = client->getEnv();
- std::vector<DistanceSortedActiveObject> allObjects;
- env.getActiveObjects(origin, max_d, allObjects);
- for (const auto &allObject : allObjects) {
- ClientActiveObject *obj = allObject.obj;
- s16 id = obj->getId();
- aabb3f selection_box;
- if (! obj->getSelectionBox(&selection_box))
- continue;
- PointedThing pointed(id, v3f(0,0,0), v3s16(0,0,0), 0);
- client->interact(INTERACT_START_DIGGING, pointed);
- }
-}
-
void Game::handlePointingAtNothing(const ItemStack &playerItem)
{
infostream << "Right Clicked in Air" << std::endl;
@@ -3225,9 +3206,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
Cheat menu
*/
- if (m_game_ui->m_flags.show_cheat_menu && ! gui_chat_console->isOpen())
- m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug);
-
+ if (! gui_chat_console->isOpen()) {
+ if (m_game_ui->m_flags.show_cheat_menu)
+ m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug);
+ if (g_settings->getBool("cheat_hud"))
+ m_cheat_menu->drawHUD(driver, dtime);
+ }
/*
Damage flash
*/
diff --git a/src/client/game.h b/src/client/game.h
index b8efa3a73..51accc679 100644
--- a/src/client/game.h
+++ b/src/client/game.h
@@ -773,7 +773,6 @@ public:
PointedThing updatePointedThing(
const core::line3d<f32> &shootline, bool liquids_pointable,
bool look_for_object, const v3s16 &camera_offset);
- void handleKillaura(v3f origin, f32 max_d);
void handlePointingAtNothing(const ItemStack &playerItem);
void handlePointingAtNode(const PointedThing &pointed,
const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 525f94678..619c26eec 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -118,6 +118,15 @@ void set_default_settings(Settings *settings)
settings->setDefault("crystal_pvp", "false");
settings->setDefault("autototem", "false");
settings->setDefault("dont_point_nodes", "false");
+ settings->setDefault("strip", "false");
+ settings->setDefault("autorefill", "false");
+ settings->setDefault("nuke", "false");
+ settings->setDefault("chat_color", "rainbow");
+ settings->setDefault("use_chat_color", "false");
+ settings->setDefault("chat_reverse", "false");
+ settings->setDefault("forcefield", "false");
+ settings->setDefault("friendlist", "");
+ settings->setDefault("cheat_hud", "true");
// Keymap
settings->setDefault("remote_port", "30000");
diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp
index f4f85c7fe..5a7f52477 100644
--- a/src/gui/cheatMenu.cpp
+++ b/src/gui/cheatMenu.cpp
@@ -151,6 +151,72 @@ void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug)
}
}
+void CheatMenu::drawHUD(video::IVideoDriver *driver, double dtime)
+{
+ CHEAT_MENU_GET_SCRIPTPTR
+
+ m_rainbow_offset += dtime;
+
+ m_rainbow_offset = fmod(m_rainbow_offset, 6.0f);
+
+ std::vector<std::string> enabled_cheats;
+
+ int cheat_count = 0;
+
+ for (auto category = script->m_cheat_categories.begin(); category != script->m_cheat_categories.end(); category++) {
+ for (auto cheat = (*category)->m_cheats.begin(); cheat != (*category)->m_cheats.end(); cheat++) {
+ if ((*cheat)->is_enabled()) {
+ enabled_cheats.push_back((*cheat)->m_name);
+ cheat_count++;
+ }
+ }
+ }
+
+ if (enabled_cheats.empty())
+ return;
+
+ std::vector<video::SColor> colors;
+
+ for (int i = 0; i < cheat_count; i++) {
+ video::SColor color;
+ f32 h = (f32)i * 2.0f / (f32)cheat_count - m_rainbow_offset;
+ if (h < 0)
+ h = 6.0f + h;
+ f32 x = (1 - fabs(fmod(h, 2.0f) - 1.0f)) * 255.0f;
+ switch((int)h) {
+ case 0:
+ color = video::SColor(255, 255, x, 0); break;
+ case 1:
+ color = video::SColor(255, x, 255, 0); break;
+ case 2:
+ color = video::SColor(255, 0, 255, x); break;
+ case 3:
+ color = video::SColor(255, 0, x, 255); break;
+ case 4:
+ color = video::SColor(255, x, 0, 255); break;
+ case 5:
+ color = video::SColor(255, 255, 0, x); break;
+ }
+ colors.push_back(color);
+ }
+
+ core::dimension2d<u32> screensize = driver->getScreenSize();
+
+ u32 y = 5;
+
+ int i = 0;
+ for (std::string cheat : enabled_cheats) {
+ core::dimension2d<u32> dim = m_font->getDimension(utf8_to_wide(cheat).c_str());
+ u32 x = screensize.Width - 5 - dim.Width;
+
+ core::rect<s32> fontbounds(x, y, x + dim.Width, y + dim.Height);
+ m_font->draw(cheat.c_str(), fontbounds, colors[i], false, false);
+
+ y += dim.Height;
+ i++;
+ }
+}
+
void CheatMenu::selectLeft()
{
CHEAT_MENU_GET_SCRIPTPTR
diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h
index f12f10ac0..bedd7e048 100644
--- a/src/gui/cheatMenu.h
+++ b/src/gui/cheatMenu.h
@@ -48,6 +48,8 @@ public:
}
void draw(video::IVideoDriver *driver, bool show_debug);
+
+ void drawHUD(video::IVideoDriver *driver, double dtime);
void drawEntry(video::IVideoDriver *driver, std::string name,
std::size_t column_align_index, std::size_t cheat_entry_index,
@@ -81,4 +83,6 @@ private:
gui::IGUIFont *m_font = nullptr;
v2u32 m_fontsize;
+
+ float m_rainbow_offset = 0.0;
};
diff --git a/src/script/lua_api/l_clientobject.cpp b/src/script/lua_api/l_clientobject.cpp
index 90f0bcd15..d88b538a1 100644
--- a/src/script/lua_api/l_clientobject.cpp
+++ b/src/script/lua_api/l_clientobject.cpp
@@ -87,6 +87,14 @@ int ClientObjectRef::l_is_player(lua_State *L)
return 1;
}
+int ClientObjectRef::l_is_local_player(lua_State *L)
+{
+ ClientObjectRef *ref = checkobject(L, 1);
+ GenericCAO *gcao = get_generic_cao(ref, L);
+ lua_pushboolean(L, gcao->isLocalPlayer());
+ return 1;
+}
+
int ClientObjectRef::l_get_name(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
@@ -210,6 +218,7 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos),
luamethod(ClientObjectRef, get_acceleration),
luamethod(ClientObjectRef, get_rotation),
luamethod(ClientObjectRef, is_player),
+ luamethod(ClientObjectRef, is_local_player),
luamethod(ClientObjectRef, get_name),
luamethod(ClientObjectRef, get_attach),
luamethod(ClientObjectRef, get_nametag),
diff --git a/src/script/lua_api/l_clientobject.h b/src/script/lua_api/l_clientobject.h
index 88a6956bc..521591444 100644
--- a/src/script/lua_api/l_clientobject.h
+++ b/src/script/lua_api/l_clientobject.h
@@ -60,6 +60,9 @@ private:
// is_player(self)
static int l_is_player(lua_State *L);
+
+ // is_local_player(self)
+ static int l_is_local_player(lua_State *L);
// get_name(self)
static int l_get_name(lua_State *L);
diff --git a/src/script/lua_api/l_inventoryaction.cpp b/src/script/lua_api/l_inventoryaction.cpp
index 516d6d3b2..f3037ba83 100644
--- a/src/script/lua_api/l_inventoryaction.cpp
+++ b/src/script/lua_api/l_inventoryaction.cpp
@@ -133,7 +133,7 @@ void LuaInventoryAction::readFullInventoryLocationInto(lua_State *L, InventoryLo
loc->deSerialize(readParam<std::string>(L, 2));
std::string l = readParam<std::string>(L, 3);
*list = l;
- *index = luaL_checkinteger(L, 4);
+ *index = luaL_checkinteger(L, 4) - 1;
} catch (SerializationError &) {}
}
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp
index 8057802a4..e40dd7b37 100644
--- a/src/script/lua_api/l_localplayer.cpp
+++ b/src/script/lua_api/l_localplayer.cpp
@@ -116,7 +116,7 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- lua_pushinteger(L, player->getWieldIndex());
+ lua_pushinteger(L, player->getWieldIndex() + 1);
return 1;
}
@@ -124,7 +124,7 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
int LuaLocalPlayer::l_set_wield_index(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- u32 index = luaL_checkinteger(L, 2);
+ u32 index = luaL_checkinteger(L, 2) - 1;
player->setWieldIndex(index);
g_game->processItemSelection(&g_game->runData.new_playeritem);