forked from mtcontrib/arrow_signs
New method for place signs.
This commit is contained in:
parent
9b4970622a
commit
129efd98d8
114
init.lua
114
init.lua
@ -7,47 +7,95 @@
|
|||||||
arrow_signs={}
|
arrow_signs={}
|
||||||
|
|
||||||
arrow_signs_on_place = function(itemstack, placer, pointed_thing)
|
arrow_signs_on_place = function(itemstack, placer, pointed_thing)
|
||||||
local function transformvector(vector)
|
|
||||||
local vectorlist ={
|
|
||||||
{cmin = -1, cmax = -0.5},
|
|
||||||
{cmin = -0.5, cmax = 0},
|
|
||||||
{cmin = 0, cmax = 0.5},
|
|
||||||
{cmin = 0.5, cmax = 1}
|
|
||||||
}
|
|
||||||
local r = {}
|
|
||||||
for n,res in pairs(vector) do
|
|
||||||
for ia=1,table.getn(vectorlist) do
|
|
||||||
if vectorlist[ia].cmin<res and vectorlist[ia].cmax>res then
|
|
||||||
r[n]=ia
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return r["x"]*10+r["z"]
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = pointed_thing.above
|
local posabove = pointed_thing.above
|
||||||
local vector = transformvector(placer:get_look_dir())
|
local posunder = pointed_thing.under
|
||||||
local changer = {
|
local vector = placer:get_look_dir()
|
||||||
{31,5},
|
local place = true
|
||||||
{12,14},
|
|
||||||
{24,11},
|
|
||||||
{43,16},
|
|
||||||
}
|
|
||||||
local place = false
|
|
||||||
|
|
||||||
for i=1,table.getn(changer) do
|
if posabove.y>posunder.y then
|
||||||
if vector == changer[i][1] then
|
if(vector.z>0.5 and vector.z<=1) then
|
||||||
minetest.add_node(pos,{name = itemstack:get_name(), param2 = changer[i][2]})
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 10})
|
||||||
place = true
|
elseif (vector.x>0.5 and vector.x<=1) then
|
||||||
break
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 19})
|
||||||
|
elseif(-0.5>vector.z and -1<=vector.z) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 4})
|
||||||
|
elseif (-0.5>vector.x and -1<=vector.x) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 13})
|
||||||
|
else
|
||||||
|
place = false
|
||||||
end
|
end
|
||||||
|
elseif posabove.y<posunder.y then
|
||||||
|
if(vector.z>0.5 and vector.z<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 8})
|
||||||
|
elseif (vector.x>0.5 and vector.x<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 17})
|
||||||
|
elseif(-0.5>vector.z and -1<=vector.z) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 6})
|
||||||
|
elseif (-0.5>vector.x and -1<=vector.x) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 15})
|
||||||
|
else
|
||||||
|
place = false
|
||||||
|
end
|
||||||
|
elseif posabove.z>posunder.z then
|
||||||
|
if(vector.y>0.75 and vector.y<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 22})
|
||||||
|
elseif (vector.y>=-1 and vector.y<-0.75) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 2})
|
||||||
|
elseif (vector.x>=0 and vector.x<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 18})
|
||||||
|
elseif (vector.x<0 and vector.x>=-1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 14})
|
||||||
|
else
|
||||||
|
place = false
|
||||||
|
end
|
||||||
|
elseif posabove.z<posunder.z then
|
||||||
|
if(vector.y>0.75 and vector.y<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 20})
|
||||||
|
elseif (vector.y>=-1 and vector.y<-0.75) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 0})
|
||||||
|
elseif (vector.x>=0 and vector.x<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 16})
|
||||||
|
elseif (vector.x<0 and vector.x>=-1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 12})
|
||||||
|
else
|
||||||
|
place = false
|
||||||
|
end
|
||||||
|
elseif posabove.x>posunder.x then
|
||||||
|
if(vector.y>0.75 and vector.y<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 21})
|
||||||
|
elseif (vector.y>=-1 and vector.y<-0.75) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 3})
|
||||||
|
elseif (vector.z>=0 and vector.z<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 11})
|
||||||
|
elseif (vector.z<0 and vector.z>=-1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 7})
|
||||||
|
else
|
||||||
|
place = false
|
||||||
|
end
|
||||||
|
elseif posabove.x<posunder.x then
|
||||||
|
if(vector.y>0.75 and vector.y<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 23})
|
||||||
|
elseif (vector.y>=-1 and vector.y<-0.75) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 1})
|
||||||
|
elseif (vector.z>=0 and vector.z<=1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 9})
|
||||||
|
elseif (vector.z<0 and vector.z>=-1) then
|
||||||
|
minetest.add_node(posabove,{name = itemstack:get_name(), param2 = 5})
|
||||||
|
else
|
||||||
|
place = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
place = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if not(place) then
|
if not(place) then
|
||||||
minetest.rotate_node(itemstack, placer, pointed_thing)
|
minetest.rotate_node(itemstack, placer, pointed_thing)
|
||||||
else
|
else
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function arrow_signs:savetext(pos, formname, fields, sender)
|
function arrow_signs:savetext(pos, formname, fields, sender)
|
||||||
@ -186,6 +234,6 @@ minetest.register_abm({
|
|||||||
|
|
||||||
--Locked sign
|
--Locked sign
|
||||||
if locks then
|
if locks then
|
||||||
local MODPATH = minetest.get_modpath("arrow_signs");
|
local MODPATH = minetest.get_modpath("arrow_signs");
|
||||||
dofile(MODPATH.."/shared_locked.lua")
|
dofile(MODPATH.."/shared_locked.lua")
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user