Separate API from registration files.

This commit is contained in:
addi 2016-07-22 17:06:36 +02:00
parent 5f11ec9809
commit ed25a62185
3 changed files with 90 additions and 89 deletions

View File

@ -141,86 +141,29 @@ arrow_signs.create_lines = function(text)
return text, n+m
end
minetest.override_item("default:sign_wall", {
groups = {choppy=2,dig_immediate=2,attached_node=1,sign=1},
})
arrow_signs.nodebox = {
type = "fixed",
fixed = {
{ 0.25, -0.25, 0.5, -0.25, 0.5, 0.47},
{ 0.1875, -0.3125, 0.5, -0.1875, -0.25, 0.47},
{ 0.125, -0.3125, 0.5, -0.125, -0.375, 0.47},
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
}
}
--Sign arrow
minetest.register_node("arrow_signs:wall", {
description = "Arrow signs",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ 0.25, -0.25, 0.5, -0.25, 0.5, 0.47},
{ 0.1875, -0.3125, 0.5, -0.1875, -0.25, 0.47},
{ 0.125, -0.3125, 0.5, -0.125, -0.375, 0.47},
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
}
},
selection_box = {
arrow_signs.selection_box = {
type = "fixed",
fixed = {
{ 0.30, -0.5, 0.5, -0.30, 0.5, 0.47}
}
},
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",
wield_image = "arrow_sign.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
walkable = false,
groups = {choppy=2,dig_immediate=2,sign=1},
sounds = default.node_sound_defaults(),
on_place = arrow_signs.on_place,
on_construct = function(pos)
--local n = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", arrow_signs.formspec)
meta:set_string("infotext", [[""]])
end,
on_receive_fields = arrow_signs.savetext,
})
--Recipes
minetest.register_craft({
type = 'shapeless',
output = 'arrow_signs:wall',
recipe = {'group:sign', 'default:stick'},
})
minetest.register_craft({
output = 'default:sign_wall',
recipe = {
{'group:sign'},
}
})
--Redefinition
minetest.register_lbm({
name = "arrow_signs:replace_old",
nodenames = {"arrow_signs:wall_right", "arrow_signs:wall_left", "arrow_signs:wall_up", "arrow_signs:wall_down",
"more_signs:wall_right","more_signs:wall_left","more_signs:wall_up" ,"more_signs:wall_down"
},
action = function(pos, node)
local convert_facedir={
["arrow_signs:wall_right"] = {6,4,5,11,16,14},
["arrow_signs:wall_left"] = {8,10,9,7,12,18},
["arrow_signs:wall_up"] = {15,19,23,21,20,22},
["arrow_signs:wall_down"] = {17,13,1,3,0,2},
-- For old mod
["more_signs:wall_right"] = {6,4,5,11,16,14},
["more_signs:wall_left"] = {8,10,9,7,12,18},
["more_signs:wall_up"] = {15,19,23,21,20,22},
["more_signs:wall_down"] = {17,13,1,3,0,2},
}
minetest.swap_node(pos, {name="arrow_signs:wall",param2=convert_facedir[node.name][node.param2+1]})
end,
})
local MODPATH = minetest.get_modpath("arrow_signs")
-- Wooden Sign
dofile(MODPATH.."/wood.lua")
--Locked sign
if locks then
local MODPATH = minetest.get_modpath("arrow_signs");
--Shared Locked sign
if minetest.get_modpath("locks") then
dofile(MODPATH.."/shared_locked.lua")
end
end

View File

@ -1,22 +1,14 @@
-- a sign
--[[
Shared Locked Arrow sign
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
]]
minetest.register_node("arrow_signs:shared_locked", {
description = "Shared locked sign",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ 0.25, -0.25, 0.5, -0.25, 0.5, 0.47},
{ 0.1875, -0.3125, 0.5, -0.1875, -0.25, 0.47},
{ 0.125, -0.3125, 0.5, -0.125, -0.375, 0.47},
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
}
},
selection_box = {
type = "fixed",
fixed = {
{ 0.30, -0.5, 0.5, -0.30, 0.5, 0.47}
}
},
node_box = arrow_signs.nodebox,
selection_box = arrow_signs.selection_box,
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",
wield_image = "arrow_sign.png",

66
wood.lua Normal file
View File

@ -0,0 +1,66 @@
--[[
Wooden Arrow sign
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
]]
minetest.register_node("arrow_signs:wall", {
description = "Arrow signs",
drawtype = "nodebox",
node_box = arrow_signs.nodebox,
selection_box = arrow_signs.selection_box,
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",
wield_image = "arrow_sign.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
walkable = false,
groups = {choppy=2,dig_immediate=2,sign=1},
sounds = default.node_sound_defaults(),
on_place = arrow_signs.on_place,
on_construct = function(pos)
--local n = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", arrow_signs.formspec)
meta:set_string("infotext", [[""]])
end,
on_receive_fields = arrow_signs.savetext,
})
--Recipes
minetest.register_craft({
type = "shapeless",
output = "arrow_signs:wall",
recipe = {"default:sign_wall_wood", "group:stick"},
})
minetest.register_craft({
output = "default:sign_wall",
recipe = {
{"arrow_signs:wall"},
}
})
--Redefinition
minetest.register_lbm({
name = "arrow_signs:replace_old",
nodenames = {"arrow_signs:wall_right", "arrow_signs:wall_left", "arrow_signs:wall_up", "arrow_signs:wall_down",
"more_signs:wall_right","more_signs:wall_left","more_signs:wall_up" ,"more_signs:wall_down"
},
action = function(pos, node)
local convert_facedir={
["arrow_signs:wall_right"] = {6,4,5,11,16,14},
["arrow_signs:wall_left"] = {8,10,9,7,12,18},
["arrow_signs:wall_up"] = {15,19,23,21,20,22},
["arrow_signs:wall_down"] = {17,13,1,3,0,2},
-- For old mod
["more_signs:wall_right"] = {6,4,5,11,16,14},
["more_signs:wall_left"] = {8,10,9,7,12,18},
["more_signs:wall_up"] = {15,19,23,21,20,22},
["more_signs:wall_down"] = {17,13,1,3,0,2},
}
minetest.swap_node(pos, {name="arrow_signs:wall",param2=convert_facedir[node.name][node.param2+1]})
end,
})