]> git.lizzy.rs Git - Crafter.git/commitdiff
Add in much more advanced coupling system
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 5 Jul 2020 13:33:31 +0000 (09:33 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 5 Jul 2020 13:33:31 +0000 (09:33 -0400)
mods/minecart/init.lua
mods/minecart/sounds/attributes.txt [new file with mode: 0644]
mods/minecart/sounds/wrench.1.ogg [new file with mode: 0644]
mods/minecart/sounds/wrench.2.ogg [new file with mode: 0644]
mods/minecart/sounds/wrench.3.ogg [new file with mode: 0644]
mods/minecart/sounds/wrench.4.ogg [new file with mode: 0644]
mods/minecart/sounds/wrench.5.ogg [new file with mode: 0644]
mods/minecart/sounds/wrench.6.ogg [new file with mode: 0644]
mods/minecart/sounds/wrench.7.ogg [new file with mode: 0644]
mods/minecart/textures/couple_particle.png [new file with mode: 0644]
mods/minecart/textures/wrench.png [new file with mode: 0644]

index 4cf4acdb34e8dce36a467ab084d49db914465334..a87d530959ddc1e48dbe8849354a85a6959cbe96 100644 (file)
@@ -23,9 +23,33 @@ local dirs = {
        {x= 0,y=-1,z=-1},
 }
 
-local axis_order = {
+local function coupling_particles(pos,truth)
+       local color = "red"
+       if truth then
+               color = "green"
+       end
+
+       minetest.add_particlespawner({
+               amount = 15,
+               time = 0.001,
+               minpos = pos,
+               maxpos = pos,
+               minvel = vector.new(-10,-10,-10),
+               maxvel = vector.new(10,10,10),
+               minacc = {x=0, y=0, z=0},
+               maxacc = {x=0, y=0, z=0},
+               minexptime = 1.1,
+               maxexptime = 1.5,
+               minsize = 1,
+               maxsize = 2,
+               collisiondetection = false,
+               collision_removal = false,
+               vertical = false,
+               texture = "couple_particle.png^[colorize:"..color..":200",
+               glow = 14,
+       })
+end
 
-}
 local function data_injection(pos,data)
        if data then
                pool[minetest.hash_node_position(pos)] = true
@@ -285,12 +309,48 @@ minecart.on_step = function(self,dtime)
 end
 
 minecart.on_rightclick = function(self,clicker)
+       if not clicker:get_wielded_item():get_name() == "minecart:wrench" then
+               return
+       end
+       local pos = self.object:get_pos()
        local name = clicker:get_player_name()
        if not pool[name] then
-               pool[name] = self.object
+               if not self.coupler2 then
+                       pool[name] = self.object
+                       minetest.sound_play("wrench",{
+                               object = self.object,
+                               gain = 1.0,
+                               max_hear_distance = 64,
+                       })
+                       coupling_particles(pos,true)
+               else
+                       minetest.sound_play("wrench",{
+                               object = self.object,
+                               gain = 1.0,
+                               max_hear_distance = 64,
+                               pitch = 0.7,
+                       })
+                       coupling_particles(pos,false)
+               end
        else
-               self.coupler1 = pool[name]
-               --pool[name]:get_luaentity().coupler1 = self.object
+               if not (pool[name]:get_luaentity().coupler1 and pool[name]:get_luaentity().coupler1 == self.object or self.coupler2) then
+                       self.coupler1 = pool[name]
+                       pool[name]:get_luaentity().coupler2 = self.object
+                       minetest.sound_play("wrench",{
+                               object = self.object,
+                               gain = 1.0,
+                               max_hear_distance = 64,
+                       })
+                       coupling_particles(pos,true)
+               else
+                       minetest.sound_play("wrench",{
+                               object = self.object,
+                               gain = 1.0,
+                               max_hear_distance = 64,
+                               pitch = 0.7,
+                       })
+                       coupling_particles(pos,false)
+               end
                pool[name] = nil
        end
 end
@@ -431,3 +491,18 @@ minetest.register_craft({
                {"main:iron","","main:iron"}
        }
 })
+
+
+minetest.register_food("minecart:wrench",{
+       description = "Train Wrench",
+       texture = "wrench.png",
+})
+
+minetest.register_craft({
+       output = "minecart:wrench",
+       recipe = {
+               {"main:iron", "", "main:iron"},
+               {"main:iron", "main:lapis", "main:iron"},
+               {"", "main:lapis", ""}
+       }
+})
\ No newline at end of file
diff --git a/mods/minecart/sounds/attributes.txt b/mods/minecart/sounds/attributes.txt
new file mode 100644 (file)
index 0000000..f13814d
--- /dev/null
@@ -0,0 +1 @@
+wrench: https://freesound.org/people/CGEffex/sounds/96215/  Attribution 3.0 Unported (CC BY 3.0)
\ No newline at end of file
diff --git a/mods/minecart/sounds/wrench.1.ogg b/mods/minecart/sounds/wrench.1.ogg
new file mode 100644 (file)
index 0000000..48e9cd0
Binary files /dev/null and b/mods/minecart/sounds/wrench.1.ogg differ
diff --git a/mods/minecart/sounds/wrench.2.ogg b/mods/minecart/sounds/wrench.2.ogg
new file mode 100644 (file)
index 0000000..287a8ed
Binary files /dev/null and b/mods/minecart/sounds/wrench.2.ogg differ
diff --git a/mods/minecart/sounds/wrench.3.ogg b/mods/minecart/sounds/wrench.3.ogg
new file mode 100644 (file)
index 0000000..c39a31e
Binary files /dev/null and b/mods/minecart/sounds/wrench.3.ogg differ
diff --git a/mods/minecart/sounds/wrench.4.ogg b/mods/minecart/sounds/wrench.4.ogg
new file mode 100644 (file)
index 0000000..c0b767e
Binary files /dev/null and b/mods/minecart/sounds/wrench.4.ogg differ
diff --git a/mods/minecart/sounds/wrench.5.ogg b/mods/minecart/sounds/wrench.5.ogg
new file mode 100644 (file)
index 0000000..2e08220
Binary files /dev/null and b/mods/minecart/sounds/wrench.5.ogg differ
diff --git a/mods/minecart/sounds/wrench.6.ogg b/mods/minecart/sounds/wrench.6.ogg
new file mode 100644 (file)
index 0000000..35803c1
Binary files /dev/null and b/mods/minecart/sounds/wrench.6.ogg differ
diff --git a/mods/minecart/sounds/wrench.7.ogg b/mods/minecart/sounds/wrench.7.ogg
new file mode 100644 (file)
index 0000000..30a86a1
Binary files /dev/null and b/mods/minecart/sounds/wrench.7.ogg differ
diff --git a/mods/minecart/textures/couple_particle.png b/mods/minecart/textures/couple_particle.png
new file mode 100644 (file)
index 0000000..07303a5
Binary files /dev/null and b/mods/minecart/textures/couple_particle.png differ
diff --git a/mods/minecart/textures/wrench.png b/mods/minecart/textures/wrench.png
new file mode 100644 (file)
index 0000000..5bb5083
Binary files /dev/null and b/mods/minecart/textures/wrench.png differ