Simplify crafting guide code; add infotext

This commit is contained in:
Wuzzy 2016-02-13 21:56:07 +01:00
parent ad0feefe43
commit ea07bb56d6
3 changed files with 57 additions and 93 deletions

View File

@ -1090,104 +1090,61 @@ minetest.register_node("tutorial:ruler", {
}) })
-- Crafting guides (example crafting images at crafting section) -- Crafting guides (example crafting images at crafting section)
minetest.register_node("tutorial:craftguide_paper", { function tutorial.craftguideinfo(pos)
description = S("crafting example: white paper"), local meta = minetest.get_meta(pos)
drawtype = "signlike", meta:set_string("infotext", S("This is a crafting example."))
selection_box = { end
type = "wallmounted",
wall_side = { -0.5, -0.5, -0.5, -0.4, 0.5, 0.5 },
},
walkable = false,
tiles = { "tutorial_craftguide_paper_white.png" },
inventory_image = "tutorial_craftguide_paper_white.png",
wield_image = "tutorial_craftguide_paper_white.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
groups = {immortal=1, attached_node=1},
})
minetest.register_node("tutorial:craftguide_paper_color", { function tutorial.register_craftguide(subId, desc, imageStatic, imageAnim, animFrames)
description = S("crafting example: colored paper"), local id = "tutorial:craftguide_"..subId
drawtype = "signlike",
selection_box = { local tiles
type = "wallmounted", if imageAnim ~= nil then
wall_side = { -0.5, -0.5, -0.5, -0.4, 0.5, 0.5 },
},
walkable = false,
tiles = { tiles = {
{ {
name = "tutorial_craftguide_paper_color_anim.png", name = imageAnim,
animation = { animation = {
type = "vertical_frames", type = "vertical_frames",
aspect_w = 32, aspect_w = 32,
aspect_h = 32, aspect_h = 32,
length = 16.0, length = animFrames * 4.0,
}, },
} }
}, }
inventory_image = "tutorial_craftguide_paper_color.png", else
wield_image = "tutorial_craftguide_paper_color.png", tiles = { imageStatic }
paramtype = "light", end
paramtype2 = "wallmounted",
sunlight_propagates = true,
groups = {immortal=1, attached_node=1},
})
minetest.register_node("tutorial:craftguide_wheat", { minetest.register_node(id, {
description = S("crafting example: wheat"), description = desc,
drawtype = "signlike", drawtype = "signlike",
selection_box = { selection_box = {
type = "wallmounted", type = "wallmounted",
wall_side = { -0.5, -0.5, -0.5, -0.4, 0.5, 0.5 }, wall_side = { -0.5, -0.5, -0.5, -0.4, 0.5, 0.5 },
}, },
walkable = false, walkable = false,
tiles = { tiles = tiles,
{ inventory_image = imageStatic,
name = "tutorial_craftguide_wheat_anim.png", wield_image = imageStatic,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 12.0,
},
}
},
inventory_image = "tutorial_craftguide_wheat.png",
wield_image = "tutorial_craftguide_wheat.png",
paramtype = "light", paramtype = "light",
paramtype2 = "wallmounted", paramtype2 = "wallmounted",
sunlight_propagates = true, sunlight_propagates = true,
groups = {immortal=1, attached_node=1}, groups = {immortal=1, attached_node=1},
}) on_construct = tutorial.craftguideinfo,
})
minetest.register_node("tutorial:craftguide_repair", { minetest.register_abm({
description = S("crafting example: tool repair"), nodenames = id,
drawtype = "signlike", interval = 5,
selection_box = { chance = 1,
type = "wallmounted", action = tutorial.craftguideinfo,
wall_side = { -0.5, -0.5, -0.5, -0.4, 0.5, 0.5 }, })
}, end
walkable = false,
tiles = {
{
name = "tutorial_craftguide_repair_anim.png",
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 12.0,
},
}
},
inventory_image = "tutorial_craftguide_repair.png",
wield_image = "tutorial_craftguide_repair.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
groups = {immortal=1, attached_node=1},
})
tutorial.register_craftguide("paper", S("crafting example: white paper"), "tutorial_craftguide_paper_white.png")
tutorial.register_craftguide("wheat", S("crafting example: wheat"), "tutorial_craftguide_wheat.png", "tutorial_craftguide_wheat_anim.png", 3)
tutorial.register_craftguide("paper_color", S("crafting example: colored paper"), "tutorial_craftguide_paper_color.png", "tutorial_craftguide_paper_color_anim.png", 4)
tutorial.register_craftguide("repair", S("crafting example: tool repair"), "tutorial_craftguide_repair.png", "tutorial_craftguide_repair_anim.png", 3)
--[[ Tutorial cups, awarded for achievements ]] --[[ Tutorial cups, awarded for achievements ]]
tutorial.cupnodebox = { tutorial.cupnodebox = {
@ -1223,6 +1180,7 @@ function tutorial.diamondinfo(pos)
meta:set_string("infotext", S("This diamond cup has been awarded for collecting all hidden diamonds.")) meta:set_string("infotext", S("This diamond cup has been awarded for collecting all hidden diamonds."))
end end
--[[ awarded for collecting all gold ingots ]] --[[ awarded for collecting all gold ingots ]]
minetest.register_node("tutorial:cup_gold", { minetest.register_node("tutorial:cup_gold", {
description = S("golden cup"), description = S("golden cup"),

View File

@ -66,6 +66,9 @@ You have collected all hidden diamonds! = Sie haben alle versteckten Diamanten g
# Sign infotext (%s is replaced with sign caption # Sign infotext (%s is replaced with sign caption
%s (Right-click to read) = %s (Rechtsklick zum Lesen) %s (Right-click to read) = %s (Rechtsklick zum Lesen)
# Craft guide infotext
This is a crafting example. = Dies ist ein Fertigungsbeispiel.
# Awards # Awards
golden cup = Goldpokal golden cup = Goldpokal
diamond cup = Diamantpokal diamond cup = Diamantpokal

View File

@ -67,6 +67,9 @@ You have collected all hidden diamonds!
# Sign infotext (%s is replaced with sign caption # Sign infotext (%s is replaced with sign caption
%s (Right-click to read) %s (Right-click to read)
# Craft guide infotext
This is a crafting example.
# Awards # Awards
golden cup golden cup
diamond cup diamond cup