forked from mtcontrib/arrow_signs
New method for place signs.
This commit is contained in:
parent
135668b35c
commit
efd9866ff7
46
init.lua
46
init.lua
@ -6,6 +6,50 @@
|
||||
|
||||
arrow_signs={}
|
||||
|
||||
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 vector = transformvector(placer:get_look_dir())
|
||||
local changer = {
|
||||
{31,5},
|
||||
{12,14},
|
||||
{24,11},
|
||||
{43,16},
|
||||
}
|
||||
local place = false
|
||||
|
||||
for i=1,table.getn(changer) do
|
||||
if vector == changer[i][1] then
|
||||
minetest.add_node(pos,{name = itemstack:get_name(), param2 = changer[i][2]})
|
||||
place = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not(place) then
|
||||
minetest.rotate_node(itemstack, placer, pointed_thing)
|
||||
else
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
function arrow_signs:savetext(pos, formname, fields, sender)
|
||||
|
||||
if not minetest.get_player_privs(sender:get_player_name())["interact"] then
|
||||
@ -91,7 +135,7 @@ minetest.register_node("arrow_signs:wall", {
|
||||
walkable = false,
|
||||
groups = {choppy=2,dig_immediate=2,sign=1},
|
||||
sounds = default.node_sound_defaults(),
|
||||
on_place = minetest.rotate_node,
|
||||
on_place = arrow_signs_on_place,
|
||||
on_construct = function(pos)
|
||||
--local n = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -23,13 +23,13 @@ minetest.register_node("arrow_signs:shared_locked", {
|
||||
tiles = {"arrow_sign_border_left.png","arrow_sign_border_right.png","arrow_sign_border_up.png","arrow_sign_border_down.png","arrow_sign.png","arrow_sign.png"},
|
||||
inventory_image = "arrow_sign.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
groups = {choppy=2,dig_immediate=2,sign_locked=1},
|
||||
legacy_wallmounted = true,
|
||||
|
||||
on_place = minetest.rotate_node,
|
||||
on_place = arrow_signs_on_place,
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
Loading…
Reference in New Issue
Block a user