diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-10-19 13:09:38 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-10-19 13:09:38 +0200 |
commit | f1ff05bf5932a7825509dbe896e60183a96a6d36 (patch) | |
tree | 73f2e361a7fd8010345880071aa29f0495171879 /builtin/client | |
parent | 35da7306dcd07fd43252468cdf71c9d8c09faeeb (diff) | |
download | dragonfireclient-f1ff05bf5932a7825509dbe896e60183a96a6d36.tar.xz |
Added ThroughWalls, InventoryActions API and AutoTotem
Diffstat (limited to 'builtin/client')
-rw-r--r-- | builtin/client/cheats/combat.lua | 72 | ||||
-rw-r--r-- | builtin/client/cheats/init.lua | 2 | ||||
-rw-r--r-- | builtin/client/cheats/inventory.lua | 8 | ||||
-rw-r--r-- | builtin/client/util.lua | 19 |
4 files changed, 59 insertions, 42 deletions
diff --git a/builtin/client/cheats/combat.lua b/builtin/client/cheats/combat.lua index 25aaaec34..b497c6c1b 100644 --- a/builtin/client/cheats/combat.lua +++ b/builtin/client/cheats/combat.lua @@ -1,47 +1,57 @@ 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) core.register_globalstep(function(dtime) - if not minetest.settings:get_bool("crystal_pvp") then return end local player = core.localplayer if not player then return end local control = player:get_control() local pointed = core.get_pointed_thing() local item = player:get_wielded_item():get_name() - if placed_crystal then - if core.switch_to_item("mobs_mc:totem") then - switched_to_totem = 5 - end - placed_crystal = false - elseif switched_to_totem > 0 then - if item ~= "mobs_mc:totem" then - switched_to_totem = 0 - elseif pointed and pointed.type == "object" then - pointed.ref:punch() - switched_to_totem = 0 + if core.settings:get_bool("crystal_pvp") then + if placed_crystal then + if core.switch_to_item("mobs_mc:totem") then + switched_to_totem = 5 + end + placed_crystal = false + elseif switched_to_totem > 0 then + if item ~= "mobs_mc:totem" then + switched_to_totem = 0 + elseif pointed and pointed.type == "object" then + pointed.ref:punch() + switched_to_totem = 0 + else + switched_to_totem = switched_to_totem + end + elseif control.RMB and item == "mcl_end:crystal" then + placed_crystal = true + elseif control.sneak then + if pointed and pointed.type == "node" and not used_sneak then + local pos = core.get_pointed_thing_position(pointed) + local node = core.get_node_or_nil(pos) + if node and (node.name == "mcl_core:obsidian" or node.name == "mcl_core:bedrock") then + core.switch_to_item("mcl_end:crystal") + core.place_node(pos) + placed_crystal = true + end + end + used_sneak = true else - switched_to_totem = switched_to_totem + used_sneak = false end - elseif control.RMB and item == "mcl_end:crystal" then - placed_crystal = true - elseif control.sneak then - if used_sneak then - core.switch_to_item("mobs_mc:totem") - return - end - core.switch_to_item("mcl_end:crystal") - if pointed and pointed.type == "node" then - local pos = core.get_pointed_thing_position(pointed) - local node = core.get_node_or_nil(pos) - if node and (node.name == "mcl_core:obsidian" or node.name == "mcl_core:bedrock") then - core.place_node(pos) - placed_crystal = true + end + + if core.settings:get_bool("autototem") then + local totem_stack = core.get_inventory("current_player").main[9] + 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:apply() + player:set_wield_index(8) end end - used_sneak = true - else - used_sneak = false end end) - diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index cdeae78c8..a7be83cee 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -5,6 +5,8 @@ core.cheats = { ["FastHit"] = "spamclick", ["AttachmentFloat"] = "float_above_parent", ["CrystalPvP"] = "crystal_pvp", + ["AutoTotem"] = "autototem", + ["ThroughWalls"] = "dont_point_nodes", }, ["Movement"] = { ["Freecam"] = "freecam", diff --git a/builtin/client/cheats/inventory.lua b/builtin/client/cheats/inventory.lua index d12052d7c..faa7d1c0e 100644 --- a/builtin/client/cheats/inventory.lua +++ b/builtin/client/cheats/inventory.lua @@ -1,5 +1,6 @@ local elapsed_time = 0 local tick_time = 0.05 +local drop_action = InventoryAction("drop") core.register_globalstep(function(dtime) -- AutoEject @@ -9,11 +10,8 @@ core.register_globalstep(function(dtime) local inventory = core.get_inventory("current_player") for index, stack in pairs(inventory.main) do if table.indexof(list, stack:get_name()) ~= -1 then - local old_index = player:get_wield_index() - player:set_wield_index(index - 1) - core.drop_selected_item() - player:set_wield_index(old_index) - return + drop_action:from("current_player", "main", index - 1) + drop_action:apply() end end end diff --git a/builtin/client/util.lua b/builtin/client/util.lua index 4a6a72d72..d61b547c6 100644 --- a/builtin/client/util.lua +++ b/builtin/client/util.lua @@ -21,20 +21,27 @@ function core.parse_relative_pos(param) return success, pos end -function core.switch_to_item(item) +function core.find_item(item) for index, stack in ipairs(core.get_inventory("current_player").main) do if stack:get_name() == item then - core.localplayer:set_wield_index(index - 1) - return true + return index end end - return false +end + +function core.switch_to_item(item) + local i = core.find_item(item) + if i then + core.localplayer:set_wield_index(i - 1) + return true + else + return false + end 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, true) - + 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() end |