]> git.lizzy.rs Git - crystalpvp.git/commitdiff
Initial Commit
authorElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 11 Dec 2020 16:25:22 +0000 (17:25 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 11 Dec 2020 16:25:22 +0000 (17:25 +0100)
README [new file with mode: 0644]
init.lua [new file with mode: 0644]
mod.conf [new file with mode: 0644]
settingtypes.txt [new file with mode: 0644]

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..2b9653e
--- /dev/null
+++ b/README
@@ -0,0 +1,2 @@
+# crystalpvp
+A dragonfire CSM to automatically use end crystals and totems (Includes AutoTotem)
diff --git a/init.lua b/init.lua
new file mode 100644 (file)
index 0000000..80de047
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,60 @@
+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", 9)
+
+minetest.register_globalstep(function(dtime)
+       local player = minetest.localplayer
+       if not player then return end
+       local control = player:get_control()
+       local pointed = minetest.get_pointed_thing()
+       local item = player:get_wielded_item():get_name()
+       if minetest.settings:get_bool("crystal_pvp") then
+               if placed_crystal then
+                       if minetest.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.place 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 = minetest.get_pointed_thing_position(pointed)
+                               local node = minetest.get_node_or_nil(pos)
+                               if node and (node.name == "mcl_core:obsidian" or node.name == "mcl_core:bedrock") then
+                                       minetest.switch_to_item("mcl_end:crystal")
+                                       minetest.place_node(pos)
+                                       placed_crystal = true
+                               end     
+                       end
+                       used_sneak = true
+               else
+                       used_sneak = false
+               end
+       end
+       
+       if minetest.settings:get_bool("autototem") then
+               local totem_stack = minetest.get_inventory("current_player").main[9]
+               if totem_stack and totem_stack:get_name() ~= "mobs_mc:totem" then
+                       local totem_index = minetest.find_item("mobs_mc:totem")
+                       if totem_index then
+                               totem_move_action:from("current_player", "main", totem_index)
+                               totem_move_action:apply()
+                               player:set_wield_index(9)
+                       end
+               end
+       end
+end)
+minetest.register_cheat("CrystalPvP", "Combat", "crystal_pvp")
+minetest.register_cheat("AutoTotem", "Combat", "autototem")
diff --git a/mod.conf b/mod.conf
new file mode 100644 (file)
index 0000000..4339ca9
--- /dev/null
+++ b/mod.conf
@@ -0,0 +1,3 @@
+name = crystalpvp
+author = Fleckenstein
+description = A dragonfire CSM to automatically use end crystals and totems (Includes AutoTotem)
diff --git a/settingtypes.txt b/settingtypes.txt
new file mode 100644 (file)
index 0000000..2f6ad03
--- /dev/null
@@ -0,0 +1,2 @@
+crystalpvp (CrystalPvP) bool false
+autototem (AutoTotem) bool false