forked from mtcontrib/banners
Refactoring
This commit is contained in:
parent
9fd7e579db
commit
03745ff814
78
crafts.lua
Normal file
78
crafts.lua
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
|
||||||
|
-- craft recipes
|
||||||
|
minetest.register_craft( -- wooden flag pole
|
||||||
|
{
|
||||||
|
output = "banners:wooden_pole 1",
|
||||||
|
recipe = {
|
||||||
|
{"", "", "default:stick"},
|
||||||
|
{"", "default:stick", ""},
|
||||||
|
{"default:stick", "", ""}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craft( -- steel flag pole
|
||||||
|
{
|
||||||
|
output = "banners:steel_pole 1",
|
||||||
|
recipe = {
|
||||||
|
{"", "", "default:steel_ingot"},
|
||||||
|
{"", "default:steel_ingot", ""},
|
||||||
|
{"default:steel_ingot", "", ""}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craft( -- wooden flag support base
|
||||||
|
{
|
||||||
|
output = "banners:wooden_base 1",
|
||||||
|
recipe = {
|
||||||
|
{"", "default:stick", ""},
|
||||||
|
{"default:stick", "", "default:stick"},
|
||||||
|
{"group:wood", "group:wood", "group:wood"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craft( -- steel support
|
||||||
|
{
|
||||||
|
output = "banners:steel_base",
|
||||||
|
recipe = {
|
||||||
|
{"", "default:steel_ingot", ""},
|
||||||
|
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||||
|
{"", "default:steelblock", ""}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craft( -- banner sheet
|
||||||
|
{
|
||||||
|
output = "banners:banner_sheet 1",
|
||||||
|
recipe = {
|
||||||
|
{"", "", ""},
|
||||||
|
{"farming:cotton", "farming:cotton", "farming:cotton"},
|
||||||
|
{"farming:cotton", "farming:cotton", "farming:cotton"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craft( -- wooden support
|
||||||
|
{
|
||||||
|
output = "banners:wooden_banner 1",
|
||||||
|
recipe = {
|
||||||
|
{"", "banners:banner_sheet", ""},
|
||||||
|
{"", "banners:wooden_pole", ""},
|
||||||
|
{"", "banners:wooden_base", ""}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craft( -- steel support
|
||||||
|
{
|
||||||
|
output = "banners:steel_banner 1",
|
||||||
|
recipe = {
|
||||||
|
{"", "banners:banner_sheet", ""},
|
||||||
|
{"", "banners:steel_pole", ""},
|
||||||
|
{"", "banners:steel_base", ""}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
194
init.lua
194
init.lua
@ -35,10 +35,10 @@ banners.colors = {
|
|||||||
"brown", "darkbrown"
|
"brown", "darkbrown"
|
||||||
}
|
}
|
||||||
|
|
||||||
banners.base_transform = ({texture = "bg_white.png", mask="mask_background.png"})
|
banners.base_transform = ({texture = "bg_white.png",
|
||||||
|
mask="mask_background.png"})
|
||||||
|
|
||||||
banners.creation_form = smartfs.create("banners:banner_creation",
|
banners.creation_form_func = function(state)
|
||||||
function(state)
|
|
||||||
-- helper functions
|
-- helper functions
|
||||||
state.update_player_inv = function(self)
|
state.update_player_inv = function(self)
|
||||||
local player = minetest.get_player_by_name(self.player)
|
local player = minetest.get_player_by_name(self.player)
|
||||||
@ -111,8 +111,10 @@ banners.creation_form = smartfs.create("banners:banner_creation",
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
)
|
|
||||||
|
banners.creation_form = smartfs.create("banners:banner_creation",
|
||||||
|
banners.creation_form_func);
|
||||||
|
|
||||||
|
|
||||||
-- banner definition
|
-- banner definition
|
||||||
@ -181,61 +183,6 @@ banners.banner_after_place = function (pos, player, itemstack, pointed_thing)
|
|||||||
minetest.add_entity(pos, "banners:banner_ent")
|
minetest.add_entity(pos, "banners:banner_ent")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- da wooden banner
|
|
||||||
minetest.register_node("banners:wooden_banner",
|
|
||||||
{
|
|
||||||
drawtype = "mesh",
|
|
||||||
mesh = "banner_support.x",
|
|
||||||
tiles = {"banner_support.png"},
|
|
||||||
description = "Wooden banner",
|
|
||||||
groups = {choppy=2, dig_immediate=2},
|
|
||||||
diggable = true,
|
|
||||||
stack_max = 1,
|
|
||||||
paramtype="light",
|
|
||||||
paramtype2="facedir",
|
|
||||||
after_place_node = function (pos, player, itemstack, pointed_thing)
|
|
||||||
banners.banner_after_place(pos, player, itemstack, pointed_thing)
|
|
||||||
end,
|
|
||||||
on_destruct = function(pos)
|
|
||||||
banners.banner_on_destruct(pos)
|
|
||||||
end,
|
|
||||||
on_use = function(i, p, pt)
|
|
||||||
banners.banner_on_use(i, p, pt)
|
|
||||||
end,
|
|
||||||
on_dig = function(pos, n, p)
|
|
||||||
banners.banner_on_dig(pos, n, p)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- steel banner
|
|
||||||
minetest.register_node("banners:steel_banner",
|
|
||||||
{
|
|
||||||
drawtype = "mesh",
|
|
||||||
mesh = "banner_support.x",
|
|
||||||
tiles = {"steel_support.png"},
|
|
||||||
description = "Steel banner",
|
|
||||||
groups = {cracky=2},
|
|
||||||
diggable = true,
|
|
||||||
stack_max = 1,
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
after_place_node = function (pos, player, itemstack, pointed_thing)
|
|
||||||
banners.banner_after_place(pos, player, itemstack, pointed_thing)
|
|
||||||
end,
|
|
||||||
on_destruct = function(pos)
|
|
||||||
banners.banner_on_destruct(pos)
|
|
||||||
end,
|
|
||||||
on_use = function(i, p, pt)
|
|
||||||
banners.banner_on_use(i, p, pt)
|
|
||||||
end,
|
|
||||||
on_dig = function(pos, n, p)
|
|
||||||
banners.banner_on_dig(pos, n, p)
|
|
||||||
end
|
|
||||||
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- banner entity
|
-- banner entity
|
||||||
local set_banner_texture
|
local set_banner_texture
|
||||||
set_banner_texture = function (obj, texture)
|
set_banner_texture = function (obj, texture)
|
||||||
@ -273,130 +220,11 @@ minetest.register_entity("banners:banner_ent",
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
-- items
|
|
||||||
|
|
||||||
minetest.register_craftitem("banners:banner_sheet",
|
|
||||||
{
|
|
||||||
groups = {},
|
|
||||||
description = "Banner sheet",
|
|
||||||
inventory_image = "banner_sheet.png",
|
|
||||||
stack_max = 1,
|
|
||||||
metadata = "",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craftitem("banners:wooden_pole",
|
|
||||||
{
|
|
||||||
groups = {},
|
|
||||||
description = "Wooden pole",
|
|
||||||
inventory_image = "wooden_pole.png"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craftitem("banners:wooden_base",
|
|
||||||
{
|
|
||||||
groups = {},
|
|
||||||
description = "Wooden base",
|
|
||||||
inventory_image = "wooden_base.png"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craftitem("banners:steel_pole",
|
|
||||||
{
|
|
||||||
groups = {},
|
|
||||||
description = "Steel pole",
|
|
||||||
inventory_image = "steel_pole.png"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craftitem("banners:steel_base",
|
|
||||||
{
|
|
||||||
groups = {},
|
|
||||||
description = "Steel base",
|
|
||||||
inventory_image = "steel_base.png"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- craft recipes
|
|
||||||
minetest.register_craft( -- wooden flag pole
|
|
||||||
{
|
|
||||||
output = "banners:wooden_pole 1",
|
|
||||||
recipe = {
|
|
||||||
{"", "", "default:stick"},
|
|
||||||
{"", "default:stick", ""},
|
|
||||||
{"default:stick", "", ""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craft( -- steel flag pole
|
|
||||||
{
|
|
||||||
output = "banners:steel_pole 1",
|
|
||||||
recipe = {
|
|
||||||
{"", "", "default:steel_ingot"},
|
|
||||||
{"", "default:steel_ingot", ""},
|
|
||||||
{"default:steel_ingot", "", ""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craft( -- wooden flag support base
|
|
||||||
{
|
|
||||||
output = "banners:wooden_base 1",
|
|
||||||
recipe = {
|
|
||||||
{"", "default:stick", ""},
|
|
||||||
{"default:stick", "", "default:stick"},
|
|
||||||
{"group:wood", "group:wood", "group:wood"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craft( -- steel support
|
|
||||||
{
|
|
||||||
output = "banners:steel_base",
|
|
||||||
recipe = {
|
|
||||||
{"", "default:steel_ingot", ""},
|
|
||||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
|
||||||
{"", "default:steelblock", ""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craft( -- banner sheet
|
|
||||||
{
|
|
||||||
output = "banners:banner_sheet 1",
|
|
||||||
recipe = {
|
|
||||||
{"", "", ""},
|
|
||||||
{"farming:cotton", "farming:cotton", "farming:cotton"},
|
|
||||||
{"farming:cotton", "farming:cotton", "farming:cotton"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craft( -- wooden support
|
|
||||||
{
|
|
||||||
output = "banners:wooden_banner 1",
|
|
||||||
recipe = {
|
|
||||||
{"", "banners:banner_sheet", ""},
|
|
||||||
{"", "banners:wooden_pole", ""},
|
|
||||||
{"", "banners:wooden_base", ""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.register_craft( -- steel support
|
|
||||||
{
|
|
||||||
output = "banners:steel_banner 1",
|
|
||||||
recipe = {
|
|
||||||
{"", "banners:banner_sheet", ""},
|
|
||||||
{"", "banners:steel_pole", ""},
|
|
||||||
{"", "banners:steel_base", ""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if minetest.get_modpath("factions") then
|
if minetest.get_modpath("factions") then
|
||||||
dofile(minetest.get_modpath("banners").."/factions.lua")
|
dofile(minetest.get_modpath("banners").."/factions.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("banners").."/items.lua")
|
||||||
|
dofile(minetest.get_modpath("banners").."/nodes.lua")
|
||||||
|
dofile(minetest.get_modpath("banners").."/crafts.lua")
|
||||||
|
|
||||||
|
45
items.lua
Normal file
45
items.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
|
||||||
|
-- items
|
||||||
|
|
||||||
|
minetest.register_craftitem("banners:banner_sheet",
|
||||||
|
{
|
||||||
|
groups = {},
|
||||||
|
description = "Banner sheet",
|
||||||
|
inventory_image = "banner_sheet.png",
|
||||||
|
stack_max = 1,
|
||||||
|
metadata = "",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craftitem("banners:wooden_pole",
|
||||||
|
{
|
||||||
|
groups = {},
|
||||||
|
description = "Wooden pole",
|
||||||
|
inventory_image = "wooden_pole.png"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craftitem("banners:wooden_base",
|
||||||
|
{
|
||||||
|
groups = {},
|
||||||
|
description = "Wooden base",
|
||||||
|
inventory_image = "wooden_base.png"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craftitem("banners:steel_pole",
|
||||||
|
{
|
||||||
|
groups = {},
|
||||||
|
description = "Steel pole",
|
||||||
|
inventory_image = "steel_pole.png"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craftitem("banners:steel_base",
|
||||||
|
{
|
||||||
|
groups = {},
|
||||||
|
description = "Steel base",
|
||||||
|
inventory_image = "steel_base.png"
|
||||||
|
}
|
||||||
|
)
|
55
nodes.lua
Normal file
55
nodes.lua
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
-- da wooden banner
|
||||||
|
minetest.register_node("banners:wooden_banner",
|
||||||
|
{
|
||||||
|
drawtype = "mesh",
|
||||||
|
mesh = "banner_support.x",
|
||||||
|
tiles = {"banner_support.png"},
|
||||||
|
description = "Wooden banner",
|
||||||
|
groups = {choppy=2, dig_immediate=2},
|
||||||
|
diggable = true,
|
||||||
|
stack_max = 1,
|
||||||
|
paramtype="light",
|
||||||
|
paramtype2="facedir",
|
||||||
|
after_place_node = function (pos, player, itemstack, pointed_thing)
|
||||||
|
banners.banner_after_place(pos, player, itemstack, pointed_thing)
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
banners.banner_on_destruct(pos)
|
||||||
|
end,
|
||||||
|
on_use = function(i, p, pt)
|
||||||
|
banners.banner_on_use(i, p, pt)
|
||||||
|
end,
|
||||||
|
on_dig = function(pos, n, p)
|
||||||
|
banners.banner_on_dig(pos, n, p)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
-- steel banner
|
||||||
|
minetest.register_node("banners:steel_banner",
|
||||||
|
{
|
||||||
|
drawtype = "mesh",
|
||||||
|
mesh = "banner_support.x",
|
||||||
|
tiles = {"steel_support.png"},
|
||||||
|
description = "Steel banner",
|
||||||
|
groups = {cracky=2},
|
||||||
|
diggable = true,
|
||||||
|
stack_max = 1,
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
after_place_node = function (pos, player, itemstack, pointed_thing)
|
||||||
|
banners.banner_after_place(pos, player, itemstack, pointed_thing)
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
banners.banner_on_destruct(pos)
|
||||||
|
end,
|
||||||
|
on_use = function(i, p, pt)
|
||||||
|
banners.banner_on_use(i, p, pt)
|
||||||
|
end,
|
||||||
|
on_dig = function(pos, n, p)
|
||||||
|
banners.banner_on_dig(pos, n, p)
|
||||||
|
end
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user