From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Sun, 5 Jul 2020 13:33:31 +0000 (-0400) Subject: Add in much more advanced coupling system X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=b6e6be006fe4c5940e0a448cf10b54851697a8bb;p=Crafter.git Add in much more advanced coupling system --- diff --git a/mods/minecart/init.lua b/mods/minecart/init.lua index 4cf4acd..a87d530 100644 --- a/mods/minecart/init.lua +++ b/mods/minecart/init.lua @@ -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 index 0000000..f13814d --- /dev/null +++ b/mods/minecart/sounds/attributes.txt @@ -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 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 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 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 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 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 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 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 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 index 0000000..5bb5083 Binary files /dev/null and b/mods/minecart/textures/wrench.png differ