mover now displays source1 and source2 marker with different colors - blue and green

master
rnd1 2015-10-01 21:56:24 +02:00
parent 1666c1784b
commit a3b72cf96e
3 changed files with 55 additions and 2 deletions

View File

@ -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",

View File

@ -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

BIN
textures/machines_pos11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B