Compare commits
5 Commits
327544ba47
...
bb7f5f806f
Author | SHA1 | Date |
---|---|---|
Juraj Vajda | bb7f5f806f | |
Juraj Vajda | 58c58695d4 | |
Juraj Vajda | 7af6a1a93c | |
Juraj Vajda | 62823d8623 | |
Juraj Vajda | 5425e54ab2 |
369
mover.lua
369
mover.lua
|
@ -198,8 +198,10 @@ local get_mover_form = function(pos,player)
|
|||
|
||||
local mode_string = meta:get_string("mode") or ""
|
||||
|
||||
local meta1 = minetest.get_meta({x = pos.x + x0, y = pos.y + y0, z = pos.z + z0}) -- source meta
|
||||
local meta2 = minetest.get_meta({x = pos.x + x2, y = pos.y + y2, z = pos.z + z2}) -- target meta
|
||||
-- source meta
|
||||
local meta1 = minetest.get_meta({x = pos.x + x0, y = pos.y + y0, z = pos.z + z0})
|
||||
-- target meta
|
||||
local meta2 = minetest.get_meta({x = pos.x + x2, y = pos.y + y2, z = pos.z + z2})
|
||||
|
||||
local inv1 = 1
|
||||
local inv2 = 1
|
||||
|
@ -208,8 +210,8 @@ local get_mover_form = function(pos,player)
|
|||
|
||||
local list1 = meta1:get_inventory():get_lists()
|
||||
local inv_list1 = ""
|
||||
local j = 1 -- stupid dropdown requires item index but returns string on receive so we have to find index.. grrr, one other solution: invert the table: key <-> value
|
||||
|
||||
-- stupid dropdown requires item index but returns string on receive so we have to find index.. grrr, one other solution: invert the table: key <-> value
|
||||
local j = 1
|
||||
|
||||
for i in pairs( list1) do
|
||||
inv_list1 = inv_list1 .. i .. ","
|
||||
|
@ -238,6 +240,11 @@ local get_mover_form = function(pos,player)
|
|||
upgrade = upgrade - 1
|
||||
end
|
||||
|
||||
if upgrade > 10 then
|
||||
upgrade = 10
|
||||
meta:set_float("upgrade", 10)
|
||||
end
|
||||
|
||||
local seltab = meta:get_int("seltab")
|
||||
local form
|
||||
|
||||
|
@ -359,14 +366,18 @@ minetest.register_node("basic_machines:mover", {
|
|||
meta:set_int("public", 0)
|
||||
meta:set_int("x0", 0)
|
||||
meta:set_int("y0", -1)
|
||||
meta:set_int("z0", 0) -- source1
|
||||
-- source1
|
||||
meta:set_int("z0", 0)
|
||||
meta:set_int("x1", 0)
|
||||
meta:set_int("y1", -1)
|
||||
meta:set_int("z1", 0) -- source2: defines cube
|
||||
-- source2: defines cube
|
||||
meta:set_int("z1", 0)
|
||||
meta:set_int("pc", 0)
|
||||
meta:set_int("dim", 1)-- current cube position and dimensions
|
||||
-- current cube position and dimensions
|
||||
meta:set_int("dim", 1)
|
||||
meta:set_int("pc", 0)
|
||||
meta:set_int("dim", 1)-- current cube position and dimensions
|
||||
-- current cube position and dimensions
|
||||
meta:set_int("dim", 1)
|
||||
meta:set_int("x2", 0)
|
||||
meta:set_int("y2", 1)
|
||||
meta:set_int("z2", 0)
|
||||
|
@ -378,9 +389,10 @@ minetest.register_node("basic_machines:mover", {
|
|||
|
||||
local privs = minetest.get_player_privs(placer:get_player_name())
|
||||
|
||||
-- means operation will be for free
|
||||
if privs.privs then
|
||||
meta:set_float("upgrade", -1)
|
||||
end -- means operation will be for free
|
||||
end
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("upgrade", 1 * 1)
|
||||
|
@ -398,7 +410,8 @@ minetest.register_node("basic_machines:mover", {
|
|||
-- minetest.show_formspec(name, "basic_machines:intro_mover", form)
|
||||
end,
|
||||
|
||||
can_dig = function(pos, player) -- dont dig if upgrades inside, cause they will be destroyed
|
||||
-- dont dig if upgrades inside, cause they will be destroyed
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("upgrade")
|
||||
|
@ -424,33 +437,45 @@ minetest.register_node("basic_machines:mover", {
|
|||
return 0
|
||||
end
|
||||
|
||||
local stack_name = stack:get_name()
|
||||
|
||||
if listname == "filter" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local itemname = stack:get_name() or ""
|
||||
meta:set_string("prefer", itemname)
|
||||
-- minetest.chat_send_player(player:get_player_name(),"#mover: filter set as " .. itemname)
|
||||
local form = get_mover_form(pos,player)
|
||||
local form = get_mover_form(pos, player)
|
||||
|
||||
meta:set_string("prefer", stack_name)
|
||||
minetest.show_formspec(player:get_player_name(), "basic_machines:mover_"..minetest.pos_to_string(pos), form)
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
if listname == "upgrade" then
|
||||
if not (stack_name == "default:diamondblock" or stack_name == "default:mese") then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
return stack:get_count()
|
||||
end,
|
||||
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
|
||||
if listname == "upgrade" then
|
||||
-- update upgrades
|
||||
local meta = minetest.get_meta(pos)
|
||||
local upgrade = 0
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local stack_name = stack:get_name()
|
||||
local upgrade_name = "default:mese"
|
||||
|
||||
-- check if upgrade should be for elevator
|
||||
if meta:get_int("elevator") == 1 then
|
||||
upgrade_name = "default:diamondblock"
|
||||
end
|
||||
|
||||
if stack:get_name() == upgrade_name then
|
||||
--inv:contains_item("upgrade", ItemStack({name="default:mese"})) then
|
||||
upgrade = (inv:get_stack("upgrade", 1):get_count()) or 0
|
||||
upgrade = upgrade + stack:get_count()
|
||||
-- add upgrades
|
||||
if stack_name == upgrade_name then
|
||||
upgrade = inv:get_stack(listname, index):get_count() or 0
|
||||
|
||||
-- not more than 10
|
||||
if upgrade > 10 then
|
||||
|
@ -461,10 +486,15 @@ minetest.register_node("basic_machines:mover", {
|
|||
|
||||
local form = get_mover_form(pos, player)
|
||||
minetest.show_formspec(player:get_player_name(), "basic_machines:mover_"..minetest.pos_to_string(pos), form)
|
||||
end
|
||||
end
|
||||
-- reset upgrade level when switching the item
|
||||
else
|
||||
meta:set_float("upgrade", 1)
|
||||
|
||||
return stack:get_count()
|
||||
local form = get_mover_form(pos, player)
|
||||
minetest.show_formspec(player:get_player_name(), "basic_machines:mover_"..minetest.pos_to_string(pos), form)
|
||||
end
|
||||
|
||||
end
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
|
@ -597,7 +627,7 @@ minetest.register_node("basic_machines:mover", {
|
|||
|
||||
-- check if elevator mode
|
||||
if x2 == 0 and z2 == 0 then
|
||||
local requirement = math.floor(math.abs(pos2.y-pos.y)/100)+1;
|
||||
local requirement = math.floor(math.abs(pos2.y - pos.y) / 100) + 1
|
||||
|
||||
if upgrade - 1 < requirement then
|
||||
meta:set_string("infotext","MOVER: Elevator error. Need at least "..requirement .. " diamond block(s) in upgrade (1 for every 100 height). ")
|
||||
|
@ -612,7 +642,7 @@ minetest.register_node("basic_machines:mover", {
|
|||
end
|
||||
|
||||
-- upgrade decreases fuel cost
|
||||
fuel_cost = fuel_cost/upgrade
|
||||
fuel_cost = fuel_cost / upgrade
|
||||
|
||||
-- free operation for admin
|
||||
if upgrade == -1 then
|
||||
|
@ -784,7 +814,7 @@ minetest.register_node("basic_machines:mover", {
|
|||
-- object on no teleport list
|
||||
if not basic_machines.no_teleport_table[detected_obj] then
|
||||
if times > 0 then
|
||||
local finalmove = true;
|
||||
local finalmove = true
|
||||
-- move objects with set velocity in target direction
|
||||
obj:setvelocity(velocityv);
|
||||
|
||||
|
@ -1102,9 +1132,44 @@ minetest.register_node("basic_machines:mover", {
|
|||
|
||||
local positions = minetest.find_nodes_in_area({x = pos1.x - r, y = pos1.y, z = pos1.z - r}, {x = pos1.x + r, y = pos1.y + 16, z = pos1.z + r}, node1.name)
|
||||
|
||||
local def = minetest.registered_nodes[node1.name]
|
||||
local distance_ok = vector.distance(pos1, pos2) <= 16
|
||||
local texture = "default_dirt.png"
|
||||
|
||||
-- try to find a node texture
|
||||
if def then
|
||||
if def.tiles then
|
||||
if #def.tiles > 0 then
|
||||
if type(def.tiles[1]) == "string" then
|
||||
texture = def.tiles[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, pos3 in ipairs(positions) do
|
||||
minetest.set_node(pos3, {name = "air"})
|
||||
count = count + 1
|
||||
|
||||
-- add particles only when not too far
|
||||
if distance_ok then
|
||||
minetest.add_particlespawner({
|
||||
amount = math.random(1, 3),
|
||||
time = 0.5,
|
||||
minpos = {x=pos3.x-0.7, y=pos3.y, z=pos3.z-0.7},
|
||||
maxpos = {x=pos3.x+0.7, y=pos3.y+0.75, z=pos3.z+0.7},
|
||||
minvel = {x = -0.5, y = -4, z = -0.5},
|
||||
maxvel = {x = 0.5, y = -2, z = 0.5},
|
||||
minacc = {x = -0.5, y = -4, z = -0.5},
|
||||
maxacc = {x = 0.5, y = -2, z = 0.5},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1,
|
||||
minsize = 0.5,
|
||||
maxsize = 2,
|
||||
collisiondetection = true,
|
||||
texture = texture
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- if tree or cactus was digged up
|
||||
|
@ -1224,12 +1289,17 @@ minetest.register_node("basic_machines:mover", {
|
|||
if vector.distance(pos1, pos2) <= 16 then
|
||||
local texture = "default_dirt.png"
|
||||
|
||||
if type(def.tiles[1]) == "string" then
|
||||
texture = def.tiles[1]
|
||||
-- try to find a node texture
|
||||
if def.tiles then
|
||||
if #def.tiles > 0 then
|
||||
if type(def.tiles[1]) == "string" then
|
||||
texture = def.tiles[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = math.random(5, 10),
|
||||
amount = math.random(3, 6),
|
||||
time = 0.5,
|
||||
minpos = {x=pos2.x-0.7, y=pos2.y, z=pos2.z-0.7},
|
||||
maxpos = {x=pos2.x+0.7, y=pos2.y+0.75, z=pos2.z+0.7},
|
||||
|
@ -1250,31 +1320,39 @@ minetest.register_node("basic_machines:mover", {
|
|||
else
|
||||
minetest.set_node(pos2, {name = node1.name})
|
||||
|
||||
-- add particles only when not too far
|
||||
if vector.distance(pos1, pos2) <= 16 then
|
||||
local texture = "default_dirt.png"
|
||||
if def then
|
||||
-- add particles only when not too far
|
||||
if vector.distance(pos1, pos2) <= 16 then
|
||||
local texture = "default_dirt.png"
|
||||
|
||||
if type(def.tiles[1]) == "string" then
|
||||
texture = def.tiles[1]
|
||||
-- try to find a node texture
|
||||
if def.tiles then
|
||||
if #def.tiles > 0 then
|
||||
if type(def.tiles[1]) == "string" then
|
||||
texture = def.tiles[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = math.random(3, 6),
|
||||
time = 0.5,
|
||||
minpos = {x=pos2.x-0.7, y=pos2.y, z=pos2.z-0.7},
|
||||
maxpos = {x=pos2.x+0.7, y=pos2.y+0.75, z=pos2.z+0.7},
|
||||
minvel = {x = -0.5, y = -4, z = -0.5},
|
||||
maxvel = {x = 0.5, y = -2, z = 0.5},
|
||||
minacc = {x = -0.5, y = -4, z = -0.5},
|
||||
maxacc = {x = 0.5, y = -2, z = 0.5},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1,
|
||||
minsize = 0.5,
|
||||
maxsize = 2,
|
||||
collisiondetection = true,
|
||||
texture = texture
|
||||
})
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = math.random(5, 10),
|
||||
time = 0.5,
|
||||
minpos = {x=pos2.x-0.7, y=pos2.y, z=pos2.z-0.7},
|
||||
maxpos = {x=pos2.x+0.7, y=pos2.y+0.75, z=pos2.z+0.7},
|
||||
minvel = {x = -0.5, y = -4, z = -0.5},
|
||||
maxvel = {x = 0.5, y = -2, z = 0.5},
|
||||
minacc = {x = -0.5, y = -4, z = -0.5},
|
||||
maxacc = {x = 0.5, y = -2, z = 0.5},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1,
|
||||
minsize = 0.5,
|
||||
maxsize = 2,
|
||||
collisiondetection = true,
|
||||
texture = texture
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1289,34 +1367,43 @@ minetest.register_node("basic_machines:mover", {
|
|||
if dig then
|
||||
minetest.check_for_falling(pos1)
|
||||
end
|
||||
local def = minetest.registered_nodes[node1.name]
|
||||
|
||||
minetest.set_node(pos1, {name = "air"})
|
||||
|
||||
-- add particles only when not too far
|
||||
if vector.distance(pos1, pos2) <= 16 then
|
||||
local def = minetest.registered_nodes[node1.name]
|
||||
local texture = "default_dirt.png"
|
||||
if def then
|
||||
-- add particles only when not too far
|
||||
if vector.distance(pos1, pos2) <= 16 then
|
||||
local texture = "default_dirt.png"
|
||||
|
||||
if type(def.tiles[1]) == "string" then
|
||||
texture = def.tiles[1]
|
||||
-- try to find a node texture
|
||||
if def.tiles then
|
||||
if #def.tiles > 0 then
|
||||
if type(def.tiles[1]) == "string" then
|
||||
texture = def.tiles[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = math.random(3, 6),
|
||||
time = 0.5,
|
||||
minpos = {x=pos1.x-0.5, y=pos1.y, z=pos1.z-0.5},
|
||||
maxpos = {x=pos1.x+0.5, y=pos1.y+0.75, z=pos1.z+0.5},
|
||||
minvel = {x = -0.5, y = -4, z = -0.5},
|
||||
maxvel = {x = 0.5, y = -2, z = 0.5},
|
||||
minacc = {x = -0.5, y = -4, z = -0.5},
|
||||
maxacc = {x = 0.5, y = -2, z = 0.5},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1,
|
||||
minsize = 0.5,
|
||||
maxsize = 2,
|
||||
collisiondetection = true,
|
||||
texture = texture
|
||||
})
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = math.random(5, 10),
|
||||
time = 0.5,
|
||||
minpos = {x=pos1.x-0.5, y=pos1.y, z=pos1.z-0.5},
|
||||
maxpos = {x=pos1.x+0.5, y=pos1.y+0.75, z=pos1.z+0.5},
|
||||
minvel = {x = -0.5, y = -4, z = -0.5},
|
||||
maxvel = {x = 0.5, y = -2, z = 0.5},
|
||||
minacc = {x = -0.5, y = -4, z = -0.5},
|
||||
maxacc = {x = 0.5, y = -2, z = 0.5},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1,
|
||||
minsize = 0.5,
|
||||
maxsize = 2,
|
||||
collisiondetection = true,
|
||||
texture = texture
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end, -- /action_on - mover
|
||||
|
||||
|
@ -2389,7 +2476,8 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
|||
end
|
||||
end
|
||||
|
||||
if punchset[name].node == "basic_machines:mover" then -- mover code, not first punch
|
||||
-- mover code, not first punch
|
||||
if punchset[name].node == "basic_machines:mover" then
|
||||
|
||||
if minetest.is_protected(pos,name) then
|
||||
minetest.chat_send_player(name, "MOVER: Punched position is protected. aborting.")
|
||||
|
@ -2397,8 +2485,14 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
|||
punchset[name].state = 0; return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(punchset[name].pos); if not meta then return end;
|
||||
local range = meta:get_float("upgrade") or 1; range = range*max_range;
|
||||
local meta = minetest.get_meta(punchset[name].pos)
|
||||
|
||||
if not meta then
|
||||
return
|
||||
end
|
||||
|
||||
local range = meta:get_float("upgrade") or 1
|
||||
range = range * max_range
|
||||
|
||||
if punchset[name].state == 1 then
|
||||
local privs = minetest.get_player_privs(puncher:get_player_name());
|
||||
|
@ -2435,38 +2529,57 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
|||
|
||||
punchset[name].pos11 = {x=pos.x,y=pos.y,z=pos.z};punchset[name].state = 3;
|
||||
machines.pos11[name] = {x=pos.x,y=pos.y,z=pos.z};
|
||||
machines.mark_pos11(name) -- mark pos11
|
||||
-- mark pos11
|
||||
machines.mark_pos11(name)
|
||||
minetest.chat_send_player(name, "MOVER: Source2 position for mover set. Punch again to set target position.")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if punchset[name].state == 3 then
|
||||
if punchset[name].node~="basic_machines:mover" then punchset[name].state = 0 return end
|
||||
if punchset[name].node ~= "basic_machines:mover" then
|
||||
punchset[name].state = 0
|
||||
return
|
||||
end
|
||||
|
||||
local privs = minetest.get_player_privs(puncher:get_player_name());
|
||||
local elevator_mode = false
|
||||
local meta = minetest.get_meta(punchset[name].pos)
|
||||
meta:set_int("elevator", 0)
|
||||
|
||||
local elevator_mode = false;
|
||||
if punchset[name].pos.x == pos.x and punchset[name].pos.z == pos.z then -- check if elevator mode
|
||||
if math.abs(punchset[name].pos.y-pos.y)>3 then -- trying to make elevator?
|
||||
-- check if elevator mode
|
||||
if punchset[name].pos.x == pos.x and
|
||||
punchset[name].pos.z == pos.z then
|
||||
-- trying to make elevator?
|
||||
if math.abs(punchset[name].pos.y - pos.y) > 3 then
|
||||
local meta = minetest.get_meta(punchset[name].pos)
|
||||
|
||||
-- only if object mode
|
||||
if meta:get_string("mode") == "object" then
|
||||
-- count number of diamond blocks to determine if elevator can be set up with this height distance
|
||||
local inv = meta:get_inventory()
|
||||
local upgrade = 0
|
||||
|
||||
local meta = minetest.get_meta(punchset[name].pos);
|
||||
if meta:get_string("mode")=="object" then -- only if object mode
|
||||
--count number of diamond blocks to determine if elevator can be set up with this height distance
|
||||
local inv = meta:get_inventory();
|
||||
local upgrade = 0;
|
||||
if inv:get_stack("upgrade", 1):get_name() == "default:diamondblock" then
|
||||
upgrade = (inv:get_stack("upgrade", 1):get_count()) or 0;
|
||||
|
||||
local inv_stack = inv:get_stack("upgrade", 1)
|
||||
upgrade = inv_stack:get_count()
|
||||
|
||||
if upgrade > 10 then
|
||||
upgrade = 10
|
||||
end
|
||||
end
|
||||
|
||||
local requirement = math.floor(math.abs(punchset[name].pos.y-pos.y)/100)+1;
|
||||
if upgrade<requirement then
|
||||
minetest.chat_send_player(name, "MOVER: Error while trying to make elevator. Need at least "..requirement .. " diamond block(s) in upgrade (1 for every 100 height). ");
|
||||
punchset[name].state = 0; return
|
||||
local requirement = math.floor(math.abs(punchset[name].pos.y - pos.y) / 100) + 1
|
||||
|
||||
if upgrade < requirement then
|
||||
minetest.chat_send_player(name, "MOVER: Error while trying to make elevator. Need at least "..requirement .. " diamond block(s) in upgrade (1 for every 100 height). ")
|
||||
punchset[name].state = 0
|
||||
return
|
||||
else
|
||||
elevator_mode=true;
|
||||
meta:set_int("upgrade",upgrade+1);
|
||||
meta:set_int("elevator",1);
|
||||
minetest.chat_send_player(name, "MOVER: elevator setup completed, upgrade level " .. upgrade);
|
||||
elevator_mode = true
|
||||
meta:set_int("upgrade", upgrade + 1)
|
||||
meta:set_int("elevator", 1)
|
||||
minetest.chat_send_player(name, "MOVER: elevator setup completed, upgrade level " .. upgrade)
|
||||
meta:set_string("infotext", "ELEVATOR, activate to use.")
|
||||
end
|
||||
|
||||
|
@ -2476,40 +2589,62 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
|||
|
||||
end
|
||||
|
||||
if not privs.privs and not elevator_mode and (math.abs(punchset[name].pos.x - pos.x)>range or math.abs(punchset[name].pos.y - pos.y)>range or math.abs(punchset[name].pos.z - pos.z)>range) then
|
||||
if not privs.privs and
|
||||
not elevator_mode and
|
||||
(math.abs(punchset[name].pos.x - pos.x) > range or math.abs(punchset[name].pos.y - pos.y) > range or math.abs(punchset[name].pos.z - pos.z) > range) then
|
||||
minetest.chat_send_player(name, "MOVER: Punch closer to mover. aborting.")
|
||||
punchset[name].state = 0; return
|
||||
punchset[name].state = 0
|
||||
return
|
||||
end
|
||||
|
||||
punchset[name].pos2 = {x=pos.x,y=pos.y,z=pos.z}; punchset[name].state = 0;
|
||||
machines.pos2[name] = punchset[name].pos2;machines.mark_pos2(name) -- mark pos2
|
||||
punchset[name].pos2 = {x = pos.x, y = pos.y, z = pos.z}
|
||||
punchset[name].state = 0
|
||||
-- mark pos2
|
||||
machines.pos2[name] = punchset[name].pos2
|
||||
machines.mark_pos2(name)
|
||||
|
||||
minetest.chat_send_player(name, "MOVER: End position for mover set.")
|
||||
|
||||
local x0 = punchset[name].pos1.x-punchset[name].pos.x;
|
||||
local y0 = punchset[name].pos1.y-punchset[name].pos.y;
|
||||
local z0 = punchset[name].pos1.z-punchset[name].pos.z;
|
||||
local meta = minetest.get_meta(punchset[name].pos);
|
||||
local x0 = punchset[name].pos1.x-punchset[name].pos.x
|
||||
local y0 = punchset[name].pos1.y-punchset[name].pos.y
|
||||
local z0 = punchset[name].pos1.z-punchset[name].pos.z
|
||||
local meta = minetest.get_meta(punchset[name].pos)
|
||||
|
||||
local x1 = punchset[name].pos11.x-punchset[name].pos.x
|
||||
local y1 = punchset[name].pos11.y-punchset[name].pos.y
|
||||
local z1 = punchset[name].pos11.z-punchset[name].pos.z
|
||||
|
||||
local x1 = punchset[name].pos11.x-punchset[name].pos.x;
|
||||
local y1 = punchset[name].pos11.y-punchset[name].pos.y;
|
||||
local z1 = punchset[name].pos11.z-punchset[name].pos.z;
|
||||
local x2 = punchset[name].pos2.x-punchset[name].pos.x
|
||||
local y2 = punchset[name].pos2.y-punchset[name].pos.y
|
||||
local z2 = punchset[name].pos2.z-punchset[name].pos.z
|
||||
|
||||
-- this ensures that x0 <= x1
|
||||
if x0 > x1 then
|
||||
x0, x1 = x1, x0
|
||||
end
|
||||
|
||||
local x2 = punchset[name].pos2.x-punchset[name].pos.x;
|
||||
local y2 = punchset[name].pos2.y-punchset[name].pos.y;
|
||||
local z2 = punchset[name].pos2.z-punchset[name].pos.z;
|
||||
if y0 > y1 then
|
||||
y0, y1 = y1, y0
|
||||
end
|
||||
|
||||
if x0>x1 then x0,x1 = x1,x0 end -- this ensures that x0<=x1
|
||||
if y0>y1 then y0,y1 = y1,y0 end
|
||||
if z0>z1 then z0,z1 = z1,z0 end
|
||||
if z0 > z1 then
|
||||
z0, z1 = z1, z0
|
||||
end
|
||||
|
||||
meta:set_int("x1",x1);meta:set_int("y1",y1);meta:set_int("z1",z1);
|
||||
meta:set_int("x0",x0);meta:set_int("y0",y0);meta:set_int("z0",z0);
|
||||
meta:set_int("x2",x2);meta:set_int("y2",y2);meta:set_int("z2",z2);
|
||||
meta:set_int("x1", x1)
|
||||
meta:set_int("y1", y1)
|
||||
meta:set_int("z1", z1)
|
||||
|
||||
meta:set_int("pc",0); meta:set_int("dim",(x1-x0+1)*(y1-y0+1)*(z1-z0+1))
|
||||
meta:set_int("x0", x0)
|
||||
meta:set_int("y0", y0)
|
||||
meta:set_int("z0", z0)
|
||||
|
||||
meta:set_int("x2", x2)
|
||||
meta:set_int("y2", y2)
|
||||
meta:set_int("z2", z2)
|
||||
|
||||
meta:set_int("pc", 0)
|
||||
meta:set_int("dim", (x1 - x0 + 1) * (y1 - y0 + 1) * (z1 - z0 + 1))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue