Add files via upload

master
AiTechEye 2018-08-26 10:27:14 +02:00 committed by GitHub
parent 9323771218
commit e9084404fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 116 additions and 2 deletions

View File

@ -293,3 +293,91 @@ vexcazer.registry_mode({
return true
end
})
vexcazer.placedigxyz=function(itemstack, user, pointed_thing,input,typ)
local pos2=vexcazer.load(input,"PlaceDigxyz")
if not pos2 then
minetest.chat_send_player(input.user:get_player_name(),"<vexcazer> you have to place first (set a start position)")
return itemstack
end
local pos1
if pointed_thing.type=="node" then
pos1=pointed_thing.above
else
pos1=user:get_pos()
end
local d=math.floor(vector.distance(pos1,pos2)+0.5)
minetest.chat_send_player(user:get_player_name(),d)
if d>input.max_amount*3 then
minetest.chat_send_player(user:get_player_name(),"<vexcazer> too far, max " .. (input.max_amount*3))
return itemstack
end
local inv=user:get_inventory()
local stack=inv:get_stack("main", input.index-1):get_name()
local count=inv:get_stack("main", input.index-1):get_count()
local dis=inv:get_stack("main", input.index+1):get_count()
if count==0 or (typ==1 and (not minetest.registered_nodes[stack] or (not input.admin and not inv:contains_item("main", stack)))) then
return
elseif dis==0 then
dis=1
end
if typ==1 then
minetest.sound_play("vexcazer_place", {pos = user:get_pos(), gain = 1.0, max_hear_distance =5,})
else
minetest.sound_play("diplazer_dig", {pos = user:get_pos(), gain = 1.0, max_hear_distance = 5,})
end
local v = {x = pos1.x - pos2.x, y = pos1.y - pos2.y-1, z = pos1.z - pos2.z}
local amount = (v.x ^ 2 + v.y ^ 2 + v.z ^ 2) ^ 0.5
local d=math.sqrt((pos1.x-pos2.x)*(pos1.x-pos2.x) + (pos1.y-pos2.y)*(pos1.y-pos2.y)+(pos1.z-pos2.z)*(pos1.z-pos2.z))
v.x = (v.x / amount)*-1
v.y = (v.y / amount)*-1
v.z = (v.z / amount)*-1
for i=0,d,dis do
local posn={x=pos1.x+(v.x*i),y=pos1.y+(v.y*i),z=pos1.z+(v.z*i)}
if typ==1 then
vexcazer.place({pos=posn,node={name=stack}},input)
elseif typ==2 then
vexcazer.dig(posn,input)
end
end
end
vexcazer.registry_mode({
wear_on_use=1,
name="Place xyz",
wear_on_use=10,
wear_on_place=0,
info="USE using all stacks and counts on\nthe hotbar until it hits a tool: from left to right",
on_place = function(itemstack, user, pointed_thing,input)
if pointed_thing.type=="node" then
vexcazer.save(input,"PlaceDigxyz",pointed_thing.above,false)
return itemstack
end
end,
on_use = function(itemstack, user, pointed_thing,input)
vexcazer.placedigxyz(itemstack, user, pointed_thing,input,1)
end,
})
vexcazer.registry_mode({
wear_on_use=1,
name="Dig xyz",
wear_on_use=10,
wear_on_place=0,
info="USE using all stacks and counts on\nthe hotbar until it hits a tool: from left to right",
on_place = function(itemstack, user, pointed_thing,input)
if pointed_thing.type=="node" then
vexcazer.save(input,"PlaceDigxyz",pointed_thing.above,false)
return itemstack
end
end,
on_use = function(itemstack, user, pointed_thing,input)
vexcazer.placedigxyz(itemstack, user, pointed_thing,input,2)
end,
})

View File

@ -84,7 +84,8 @@ vexcazer.use=function(itemstack, user, pointed_thing,input)
if pointed_thing.type=="node" and (minetest.get_node(pointed_thing.under)==nil or minetest.get_node(pointed_thing.above)==nil) then return itemstack end
if pointed_thing.type=="node" and (not minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]) then
minetest.set_node(pointed_thing.under, {name="air"})
vexcazer.unknown_remove(pointed_thing.under)
--minetest.set_node(pointed_thing.under, {name="air"})
return itemstack
end
@ -384,7 +385,7 @@ vexcazer.place=function(use,input)--{pos,node={name=name}},input
if fn~=nil and input.default and fn.drop=="" and fn.name:find("maptools:",1)~=nil then return false end
if fn==nil then return false end
if fn.walkable==false then
if (input.default and fn.buildable_to) or ((input.admin or input.mod) and (fn.walkable==false or fn.buildable_to)) then
minetest.set_node(use.pos, use.node)
if not (input.admin or input.creative) then
input.user:get_inventory():remove_item("main", use.node.name)
@ -501,6 +502,31 @@ vexcazer.wear=function(itemstack,input,wear)
return itemstack
end
vexcazer.def=function(pos,n)
if not (pos and pos.x and pos.y and pos.z and n) then
return nil
elseif not minetest.registered_nodes[minetest.get_node(pos).name] then
minetest.remove_node(pos)
end
return minetest.registered_nodes[minetest.get_node(pos).name][n]
end
vexcazer.unknown_remove=function(pos)
local a=50
for y=-a,a,1 do
for x=-a,a,1 do
for z=-a,a,1 do
local p={x=pos.x+x,y=pos.y+y,z=pos.z+z}
local cc=vector.length(vector.new({x=x,y=y,z=z}))/a
if not minetest.registered_nodes[minetest.get_node(p).name] then
minetest.remove_node(p)
end
end
end
end
end
dofile(minetest.get_modpath("vexcazer") .. "/stuff.lua")
dofile(minetest.get_modpath("vexcazer") .. "/default_modes.lua")
dofile(minetest.get_modpath("vexcazer") .. "/craft.lua")