remove unneeded stuff
This commit is contained in:
parent
1bc80e0fdd
commit
0d1ebe83f1
@ -1,6 +1,5 @@
|
||||
--license LGPLv2+
|
||||
|
||||
--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 = {
|
||||
@ -10,9 +9,6 @@ local mining_lasers_list = {
|
||||
{"3", 30, mk1_charge*16, 1.08},
|
||||
}
|
||||
|
||||
--local f_1 = 0.5-r_corr
|
||||
--local f_2 = 0.5+r_corr
|
||||
|
||||
-- Taken from the Flowers mod by erlehmann.
|
||||
local function table_contains(t, v)
|
||||
for _,i in ipairs(t) do
|
||||
@ -23,39 +19,6 @@ local function table_contains(t, v)
|
||||
return false
|
||||
end
|
||||
|
||||
--[[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 table_contains({"air", "ignore", "default:lava_source", "default:lava_flowing"}, node.name) then
|
||||
@ -73,56 +36,6 @@ local function laser_node(pos, player)
|
||||
end
|
||||
end
|
||||
|
||||
local function laser_nodes(pos, dir, player, range)
|
||||
for _,p in ipairs(vector.line(pos, dir, range)) do
|
||||
laser_node(p, player)
|
||||
end
|
||||
--[[ 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 ipairs(ytab) do
|
||||
for _,z in ipairs(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],1 do
|
||||
local xtab = node_tab(d_ch.x, d)
|
||||
local y = d
|
||||
local ztab = node_tab(d_ch.z, d)
|
||||
for _,x in ipairs(xtab) do
|
||||
for _,z in ipairs(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],1 do
|
||||
local xtab = node_tab(d_ch.x, d)
|
||||
local ytab = node_tab(d_ch.y, d)
|
||||
local z = d
|
||||
for _,x in ipairs(xtab) do
|
||||
for _,y in ipairs(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, particle_time, sound)
|
||||
local t1 = os.clock()
|
||||
|
||||
@ -131,12 +44,15 @@ local function laser_shoot(player, range, particle_texture, particle_time, sound
|
||||
|
||||
local startpos = {x=playerpos.x, y=playerpos.y+1.6, z=playerpos.z}
|
||||
local a = vector.multiply(dir, 50)
|
||||
local nodes = vector.line(vector.round(startpos), dir, range)
|
||||
|
||||
minetest.add_particle(startpos, dir, a, particle_time, 1, false, particle_texture)
|
||||
laser_nodes(vector.round(startpos), dir, player, range)
|
||||
for _,p in ipairs(nodes) do --minetest.after isn't necessary for a laser
|
||||
laser_node(p, player)
|
||||
end
|
||||
minetest.sound_play(sound, {pos = playerpos, gain = 1.0, max_hear_distance = range})
|
||||
|
||||
print("[technic] <mining_laser> my shot was calculated after "..tostring(os.clock()-t1).."s")
|
||||
return true --Why?
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user