From a3b72cf96e890acd40c503bc8b4c03ce7be3d148 Mon Sep 17 00:00:00 2001 From: rnd1 Date: Thu, 1 Oct 2015 21:56:24 +0200 Subject: [PATCH] mover now displays source1 and source2 marker with different colors - blue and green --- mark.lua | 52 +++++++++++++++++++++++++++++++++++- mover.lua | 5 +++- textures/machines_pos11.png | Bin 0 -> 204 bytes 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 textures/machines_pos11.png diff --git a/mark.lua b/mark.lua index 07d4cd8..9b55cf6 100644 --- a/mark.lua +++ b/mark.lua @@ -3,8 +3,9 @@ -- need for marking machines = {}; -machines.pos1 = {}; machines.pos2 = {}; +machines.pos1 = {};machines.pos11 = {}; machines.pos2 = {}; machines.marker1 = {} +machines.marker11 = {} machines.marker2 = {} machines.marker_region = {} @@ -34,6 +35,31 @@ machines.mark_pos1 = function(name) end end +--marks machines region position 1 +machines.mark_pos11 = function(name) + local pos11 = machines.pos11[name]; + + if pos11 ~= nil then + --make area stay loaded + local manip = minetest.get_voxel_manip() + manip:read_from_map(pos11, pos11) + end + + if not machines[name] then machines[name]={} end + machines[name].timer = 10; + if machines.marker11[name] ~= nil then --marker already exists + machines.marker11[name]:remove() --remove marker + machines.marker11[name] = nil + end + if pos11 ~= nil then + --add marker + machines.marker11[name] = minetest.add_entity(pos11, "machines:pos11") + if machines.marker11[name] ~= nil then + machines.marker11[name]:get_luaentity().name = name + end + end +end + --marks machines region position 2 machines.mark_pos2 = function(name) local pos1, pos2 = machines.pos1[name], machines.pos2[name] @@ -85,6 +111,30 @@ minetest.register_entity(":machines:pos1", { end, }) +minetest.register_entity(":machines:pos11", { + initial_properties = { + visual = "cube", + visual_size = {x=1.1, y=1.1}, + textures = {"machines_pos11.png", "machines_pos11.png", + "machines_pos11.png", "machines_pos11.png", + "machines_pos11.png", "machines_pos11.png"}, + collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55}, + physical = false, + }, + on_step = function(self, dtime) + if not machines[self.name] then machines[self.name]={}; machines[self.name].timer = 10 end + machines[self.name].timer = machines[self.name].timer - dtime + if machines[self.name].timer<=0 or machines.marker11[self.name] == nil then + self.object:remove() + end + end, + on_punch = function(self, hitter) + self.object:remove() + machines.marker11[self.name] = nil + machines[self.name].timer = 10 + end, +}) + minetest.register_entity(":machines:pos2", { initial_properties = { visual = "cube", diff --git a/mover.lua b/mover.lua index 22ebdbc..4dd96b9 100644 --- a/mover.lua +++ b/mover.lua @@ -62,8 +62,11 @@ minetest.register_node("basic_machines:mover", { x1=meta:get_int("x1");y1=meta:get_int("y1");z1=meta:get_int("z1"); x2=meta:get_int("x2");y2=meta:get_int("y2");z2=meta:get_int("z2"); - machines.pos1[player:get_player_name()] = {x=pos.x+x1,y=pos.y+y1,z=pos.z+z1}; + machines.pos1[player:get_player_name()] = {x=pos.x+x0,y=pos.y+y0,z=pos.z+z0}; machines.mark_pos1(player:get_player_name()) -- mark pos1 + machines.pos11[player:get_player_name()] = {x=pos.x+x1,y=pos.y+y1,z=pos.z+z1}; + machines.mark_pos11(player:get_player_name()) -- mark pos11 + machines.pos2[player:get_player_name()] = {x=pos.x+x2,y=pos.y+y2,z=pos.z+z2}; machines.mark_pos2(player:get_player_name()) -- mark pos2 diff --git a/textures/machines_pos11.png b/textures/machines_pos11.png new file mode 100644 index 0000000000000000000000000000000000000000..8a8ec5d540b6db36748e9a1ca647fb4f797217b3 GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=BdgAk26#O}+vs$X?><>&kwgi&5A}LG+vuA5bXL)5S5w;&gIK#Ft0*%&ZNqjg5^D z>(^K)Th5Xc-~Z?Q5eLNtr4;7JkEZ`WY1A;mZ4aBkYRTn{|C5hOcJfBtVtaJKprLg} sM8n68tU9?d4qo>b^l^K5R=!|hxZo}qI{D_&UZ5omp00i_>zopr0Qyx!Z~y=R literal 0 HcmV?d00001