Add Mk2 and Mk3 mining lasers
@ -151,11 +151,11 @@ Flashlight = Linterna
|
||||
3 nodes tall. = 3 nodos de alto.
|
||||
3 nodes wide. = 3 nodos de ancho.
|
||||
3x3 nodes. = 3x3 nodos.
|
||||
Hold shift and use to change Mining Drill Mk%d modes. = Manten pulsado Mayus y Usar para cambiar el modo del Taladro de Mineria MK%d.
|
||||
Hold shift and use to change Mining Drill Mk%d modes. = Manten pulsado Mayus y Usar para cambiar el modo del Taladro de Mineria Mk%d.
|
||||
Mining Drill Mk%d Mode %d = Taladro de Mineria Mk%d Modo %d
|
||||
Mining Drill Mk1 = Taladro de Mineria Mk1
|
||||
Mining Drill Mk2 = Taladro de Mineria Mk2
|
||||
Mining Drill Mk3 = Taladro de Mineria Mk3
|
||||
Mining Drill Mk%d = Taladro de Mineria Mk%d
|
||||
Mining Laser Mk%d = Laser de Mineria Mk%d
|
||||
Single node. = Nodo simple.
|
||||
Sonic Screwdriver = Destonillador Sonico
|
||||
Tree Tap = Grifo de Arbol
|
||||
|
||||
|
@ -153,9 +153,8 @@ Flashlight =
|
||||
3x3 nodes. =
|
||||
Hold shift and use to change Mining Drill Mk%d modes. =
|
||||
Mining Drill Mk%d Mode %d =
|
||||
Mining Drill Mk1 =
|
||||
Mining Drill Mk2 =
|
||||
Mining Drill Mk3 =
|
||||
Mining Drill Mk%d =
|
||||
Mining Laser Mk%d =
|
||||
Single node. =
|
||||
Sonic Screwdriver =
|
||||
Tree Tap =
|
||||
|
BIN
technic/sounds/technic_laser_mk1.1.ogg
Normal file
BIN
technic/sounds/technic_laser_mk2.0.ogg
Normal file
BIN
technic/sounds/technic_laser_mk2.1.ogg
Normal file
BIN
technic/sounds/technic_laser_mk2.2.ogg
Normal file
BIN
technic/sounds/technic_laser_mk3.1.ogg
Normal file
BIN
technic/sounds/technic_laser_mk3.2.ogg
Normal file
Before Width: | Height: | Size: 119 B |
BIN
technic/textures/technic_laser_beam_mk1.png
Normal file
After Width: | Height: | Size: 279 B |
BIN
technic/textures/technic_laser_beam_mk2.png
Normal file
After Width: | Height: | Size: 638 B |
BIN
technic/textures/technic_laser_beam_mk3.png
Normal file
After Width: | Height: | Size: 547 B |
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 216 B |
BIN
technic/textures/technic_mining_laser_mk2.png
Normal file
After Width: | Height: | Size: 244 B |
BIN
technic/textures/technic_mining_laser_mk3.png
Normal file
After Width: | Height: | Size: 312 B |
@ -4,7 +4,7 @@ if technic.config:get_bool("enable_mining_drill") then
|
||||
dofile(path.."/mining_drill.lua")
|
||||
end
|
||||
if technic.config:get_bool("enable_mining_laser") then
|
||||
dofile(path.."/mining_laser_mk1.lua")
|
||||
dofile(path.."/mining_lasers.lua")
|
||||
end
|
||||
if technic.config:get_bool("enable_flashlight") then
|
||||
dofile(path.."/flashlight.lua")
|
||||
|
@ -222,7 +222,7 @@ end
|
||||
|
||||
technic.register_power_tool("technic:mining_drill", mining_drill_max_charge)
|
||||
minetest.register_tool("technic:mining_drill", {
|
||||
description = S("Mining Drill Mk1"),
|
||||
description = S("Mining Drill Mk%d"):format(1),
|
||||
inventory_image = "technic_mining_drill.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
@ -245,7 +245,7 @@ minetest.register_tool("technic:mining_drill", {
|
||||
})
|
||||
|
||||
minetest.register_tool("technic:mining_drill_mk2", {
|
||||
description = S("Mining Drill Mk2"),
|
||||
description = S("Mining Drill Mk%d"):format(2),
|
||||
inventory_image = "technic_mining_drill_mk2.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
mining_drill_mk2_handler(itemstack, user, pointed_thing)
|
||||
@ -270,7 +270,7 @@ for i = 1, 4 do
|
||||
end
|
||||
|
||||
minetest.register_tool("technic:mining_drill_mk3", {
|
||||
description = S("Mining Drill Mk3"),
|
||||
description = S("Mining Drill Mk%d"):format(3),
|
||||
inventory_image = "technic_mining_drill_mk3.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
mining_drill_mk3_handler(itemstack,user,pointed_thing)
|
||||
|
@ -1,176 +0,0 @@
|
||||
local laser_mk1_max_charge = 40000
|
||||
technic.register_power_tool("technic:laser_mk1", laser_mk1_max_charge)
|
||||
|
||||
local laser_shoot = function(player, pointed_thing)
|
||||
local laser_straight_mode=0
|
||||
local playerpos=player:getpos()
|
||||
local dir=player:get_look_dir()
|
||||
if pointed_thing.type=="node" then
|
||||
pos=minetest.get_pointed_thing_position(pointed_thing, above)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if node.name~="ignore" then
|
||||
minetest.node_dig(pos,node,player)
|
||||
end
|
||||
laser_straight_mode=1
|
||||
end
|
||||
|
||||
direction_y=math.abs(math.floor(dir.y*100))
|
||||
if direction_y>50 then entity_name="technic:laser_beam_entityV"
|
||||
else entity_name="technic:laser_beam_entity" end
|
||||
|
||||
if laser_straight_mode==1 then
|
||||
pos1=minetest.get_pointed_thing_position(pointed_thing, under)
|
||||
pos1.x=math.floor(pos1.x)
|
||||
pos1.y=math.floor(pos1.y)
|
||||
pos1.z=math.floor(pos1.z)
|
||||
obj=minetest.env:add_entity(pos1,entity_name)
|
||||
else
|
||||
obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.6,z=playerpos.z},entity_name)
|
||||
end
|
||||
if obj:get_luaentity().player == nil then
|
||||
obj:get_luaentity().player = player
|
||||
end
|
||||
if laser_straight_mode==1 and direction_y<50 then
|
||||
obj:setvelocity({x=dir.x*8, y=0, z=dir.z*8})
|
||||
else if laser_straight_mode==1 and direction_y>50 then
|
||||
obj:setvelocity({x=0, y=dir.y*8, z=dir.z*8})
|
||||
end
|
||||
end
|
||||
if laser_straight_mode==0 then
|
||||
obj:setvelocity({x=dir.x*8, y=dir.y*8, z=dir.z*8})
|
||||
end
|
||||
obj:setacceleration({x=0, y=0, z=0})
|
||||
obj:setyaw(player:get_look_yaw()+math.pi)
|
||||
if obj:get_luaentity().player == nil then
|
||||
obj:get_luaentity().player = player
|
||||
end
|
||||
--obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name()
|
||||
minetest.sound_play("technic_laser", {pos = playerpos, gain = 1.0, max_hear_distance = 10,})
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
minetest.register_tool("technic:laser_mk1", {
|
||||
description = "Mining Laser MK1",
|
||||
inventory_image = "technic_mining_laser_mk1.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local meta = get_item_meta(itemstack:get_metadata())
|
||||
if not meta or not meta.charge then
|
||||
return
|
||||
end
|
||||
if meta.charge - 400 > 0 then
|
||||
laser_shoot(user, pointed_thing)
|
||||
meta.charge = meta.charge - 400
|
||||
technic.set_RE_wear(itemstack, meta.charge, laser_mk1_max_charge)
|
||||
itemstack:set_metadata(set_item_meta(meta))
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:laser_mk1',
|
||||
recipe = {
|
||||
{'default:diamond', 'default:steel_ingot', 'technic:battery'},
|
||||
{'', 'default:steel_ingot', 'technic:battery'},
|
||||
{'', '', 'default:copper_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_node("technic:laser_beam_box", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.5 , -0.1, -0.1 , 0.1 , 0.1 , 0.1 },
|
||||
{ -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1 },
|
||||
}
|
||||
},
|
||||
tiles = {"technic_laser_beam.png"},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
minetest.register_node("technic:laser_beam_boxV", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1 },
|
||||
{ -0.1 , -0.5, -0.1 , 0.1 , 0.1 , 0.1 },
|
||||
|
||||
}
|
||||
},
|
||||
tiles = {"technic_laser_beam.png"},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
LASER_BEAM_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.2, y=0.2},
|
||||
textures = {"technic:laser_beam_box"},
|
||||
lastpos={},
|
||||
max_range=10,
|
||||
count=0,
|
||||
-- digger=nil,
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
}
|
||||
|
||||
LASER_BEAM_ENTITY.on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
if self.player~=nil then if self.lastpos.x~=nil then lazer_it (pos, self.player) end end
|
||||
if self.lastpos.x ~=nil and self.lastpos.y ~=nil and self.lastpos.y ~=nil then
|
||||
temp1={x=math.floor(self.lastpos.x),y=math.floor(self.lastpos.y),z=math.floor(self.lastpos.z)}
|
||||
temp2={x=math.floor(pos.x),y=math.floor(pos.y),z=math.floor(pos.z)}
|
||||
if temp1.x==temp2.x and temp1.y==temp2.y and temp1.z==temp2.z then return end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.count=self.count+1
|
||||
if self.count==self.max_range then self.object:remove() end
|
||||
end
|
||||
|
||||
LASER_BEAM_ENTITYV={
|
||||
physical = false,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.2, y=0.2},
|
||||
textures = {"technic:laser_beam_boxV"},
|
||||
lastpos={},
|
||||
max_range=15,
|
||||
count=0,
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
}
|
||||
|
||||
LASER_BEAM_ENTITYV.on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
if self.player~=nil then if self.lastpos.x~=nil then lazer_it (pos, self.player) end end
|
||||
if self.lastpos.x ~=nil and self.lastpos.y ~=nil and self.lastpos.y ~=nil then
|
||||
temp1={x=math.floor(self.lastpos.x),y=math.floor(self.lastpos.y),z=math.floor(self.lastpos.z)}
|
||||
temp2={x=math.floor(pos.x),y=math.floor(pos.y),z=math.floor(pos.z)}
|
||||
if temp1.x==temp2.x and temp1.y==temp2.y and temp1.z==temp2.z then return end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.count=self.count+1
|
||||
if self.count==self.max_range then self.object:remove() end
|
||||
end
|
||||
|
||||
|
||||
minetest.register_entity("technic:laser_beam_entity", LASER_BEAM_ENTITY)
|
||||
minetest.register_entity("technic:laser_beam_entityV", LASER_BEAM_ENTITYV)
|
||||
|
||||
function lazer_it (pos, player)
|
||||
local pos1={}
|
||||
-- pos1.x=math.floor(pos.x)
|
||||
-- pos1.y=math.floor(pos.y)
|
||||
-- pos1.z=math.floor(pos.z)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if node.name == "air" or node.name == "ignore" or node.name == "default:lava_source" or node.name == "default:lava_flowing" then return end
|
||||
if node.name == "default:water_source" or node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end
|
||||
if player then minetest.node_dig(pos,node,player) end
|
||||
end
|
157
technic/tools/mining_lasers.lua
Normal file
@ -0,0 +1,157 @@
|
||||
|
||||
local r_corr = 0.25 -- Remove a bit more nodes (if shooting diagonal) to let it look like a hole (sth like antialiasing)
|
||||
local mk1_charge = 40000
|
||||
|
||||
local mining_lasers_list = {
|
||||
-- {<num>, <range of the laser shots>, <max_charge>},
|
||||
{"1", 7, mk1_charge},
|
||||
{"2", 11, mk1_charge * 4},
|
||||
{"3", 30, mk1_charge * 16},
|
||||
}
|
||||
|
||||
local f_1 = 0.5 - r_corr
|
||||
local f_2 = 0.5 + r_corr
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local function get_used_dir(dir)
|
||||
local abs_dir = {x = math.abs(dir.x),
|
||||
y = math.abs(dir.y),
|
||||
z = math.abs(dir.z)}
|
||||
local dir_max = math.max(abs_dir.x, abs_dir.y, abs_dir.z)
|
||||
if dir_max == abs_dir.x then
|
||||
local tab = {"x", {x = 1, y = dir.y / dir.x, z = dir.z / dir.x}}
|
||||
if dir.x >= 0 then
|
||||
tab[3] = "+"
|
||||
end
|
||||
return tab
|
||||
end
|
||||
if dir_max == abs_dir.y then
|
||||
local tab = {"y", {x = dir.x / dir.y, y = 1, z = dir.z / dir.y}}
|
||||
if dir.y >= 0 then
|
||||
tab[3] = "+"
|
||||
end
|
||||
return tab
|
||||
end
|
||||
local tab = {"z", {x = dir.x / dir.z, y = dir.y / dir.z, z = 1}}
|
||||
if dir.z >= 0 then
|
||||
tab[3] = "+"
|
||||
end
|
||||
return tab
|
||||
end
|
||||
|
||||
local function node_tab(z, d)
|
||||
local n1 = math.floor(z * d + f_1)
|
||||
local n2 = math.floor(z * d + f_2)
|
||||
if n1 == n2 then
|
||||
return {n1}
|
||||
end
|
||||
return {n1, n2}
|
||||
end
|
||||
|
||||
local function laser_node(pos, player)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == "air"
|
||||
or node.name == "ignore"
|
||||
or node.name == "default:lava_source"
|
||||
or node.name == "default:lava_flowing" then
|
||||
return
|
||||
end
|
||||
if node.name == "default:water_source"
|
||||
or node.name == "default:water_flowing" then
|
||||
minetest.remove_node(pos)
|
||||
minetest.add_particle(pos,
|
||||
{x=0, y=2, z=0},
|
||||
{x=0, y=-1, z=0},
|
||||
1.5,
|
||||
8,
|
||||
false,
|
||||
"smoke_puff.png")
|
||||
return
|
||||
end
|
||||
if player then
|
||||
minetest.node_dig(pos, node, player)
|
||||
end
|
||||
end
|
||||
|
||||
local function laser_nodes(pos, dir, player, range)
|
||||
local t_dir = get_used_dir(dir)
|
||||
local dir_typ = t_dir[1]
|
||||
if t_dir[3] == "+" then
|
||||
f_tab = {0, range}
|
||||
else
|
||||
f_tab = {-range,0}
|
||||
end
|
||||
local d_ch = t_dir[2]
|
||||
if dir_typ == "x" then
|
||||
for d = f_tab[1],f_tab[2],1 do
|
||||
local x = d
|
||||
local ytab = node_tab(d_ch.y, d)
|
||||
local ztab = node_tab(d_ch.z, d)
|
||||
for _, y in pairs(ytab) do
|
||||
for _, z in pairs(ztab) do
|
||||
laser_node({x = pos.x + x, y = pos.y + y, z = pos.z + z}, player)
|
||||
end
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
if dir_typ == "y" then
|
||||
for d = f_tab[1], f_tab[2] do
|
||||
local xtab = node_tab(d_ch.x, d)
|
||||
local y = d
|
||||
local ztab = node_tab(d_ch.z, d)
|
||||
for _, x in pairs(xtab) do
|
||||
for _, z in pairs(ztab) do
|
||||
laser_node({x = pos.x + x, y = pos.y + y, z = pos.z + z}, player)
|
||||
end
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
for d = f_tab[1], f_tab[2] do
|
||||
local xtab = node_tab(d_ch.x, d)
|
||||
local ytab = node_tab(d_ch.y, d)
|
||||
local z = d
|
||||
for _, x in pairs(xtab) do
|
||||
for _, y in pairs(ytab) do
|
||||
laser_node({x = pos.x + x, y = pos.y + y, z = pos.z + z}, player)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function laser_shoot(player, range, particle_texture, sound)
|
||||
local playerpos = player:getpos()
|
||||
local dir = player:get_look_dir()
|
||||
|
||||
local startpos = {x = playerpos.x, y = playerpos.y + 1.6, z = playerpos.z}
|
||||
local mult_dir = vector.multiply(dir, 50)
|
||||
minetest.add_particle(startpos, dir, mult_dir, range / 11, 1, false, particle_texture)
|
||||
laser_nodes(vector.round(startpos), dir, player, range)
|
||||
minetest.sound_play(sound, {pos = playerpos, gain = 1.0, max_hear_distance = range})
|
||||
end
|
||||
|
||||
|
||||
for _, m in pairs(mining_lasers_list) do
|
||||
technic.register_power_tool("technic:laser_mk"..m[1], m[3])
|
||||
minetest.register_tool("technic:laser_mk"..m[1], {
|
||||
description = S("Mining Laser Mk%d"):format(m[1]),
|
||||
inventory_image = "technic_mining_laser_mk"..m[1]..".png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user)
|
||||
local meta = get_item_meta(itemstack:get_metadata())
|
||||
if not meta or not meta.charge then
|
||||
return
|
||||
end
|
||||
if meta.charge - 400 > 0 then
|
||||
laser_shoot(user, m[2], "technic_laser_beam_mk"..m[1]..".png", "technic_laser_mk"..m[1])
|
||||
meta.charge = meta.charge - 400
|
||||
technic.set_RE_wear(itemstack, meta.charge, m[3])
|
||||
itemstack:set_metadata(set_item_meta(meta))
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
end
|
||||
|