diff --git a/init.lua b/init.lua index 548c460..bdf1607 100644 --- a/init.lua +++ b/init.lua @@ -378,31 +378,57 @@ mt.register_on_player_receive_fields(function(player, formname, fields) end end) +function craftguide:on_use(itemstack, user) + if not datas.init_items then + craftguide:get_init_items() + end + + local player_name = user:get_player_name() + local data = datas[player_name] + + if progressive_mode or not data then + datas[player_name] = {filter="", pagenum=1, iX=9} + if progressive_mode then + craftguide:get_filter_items( + datas[player_name], user) + end + craftguide:get_formspec(player_name) + else + show_formspec(player_name, "craftguide", data.formspec) + end +end + mt.register_craftitem("craftguide:book", { description = "Crafting Guide", inventory_image = "craftguide_book.png", wield_image = "craftguide_book.png", stack_max = 1, groups = {book=1}, - on_use = function(itemstack, user) - if not datas.init_items then - craftguide:get_init_items() - end + on_use = function(itemstack, user) craftguide:on_use(itemstack, user) end +}) - local player_name = user:get_player_name() - local data = datas[player_name] - - if progressive_mode or not data then - datas[player_name] = {filter="", pagenum=1, iX=9} - if progressive_mode then - craftguide:get_filter_items( - datas[player_name], user) - end - craftguide:get_formspec(player_name) - else - show_formspec(player_name, "craftguide", data.formspec) - end - end +mt.register_node("craftguide:sign", { + description = "Crafting Guide Sign", + drawtype = "nodebox", + tiles = {"craftguide_sign.png"}, + inventory_image = "craftguide_sign_inventory.png", + wield_image = "craftguide_sign_inventory.png", + stack_max = 1, + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + groups = {wood = 1, oddly_breakable_by_hand = 1, flammable = 3}, + legacy_wallmounted = true, + node_box = { + type = "wallmounted", + wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125}, + wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125}, + wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}, + }, + on_rightclick = function(pos, node, user, itemstack, pointed_thing) + craftguide:on_use(itemstack, user) + end }) mt.register_craft({ @@ -417,5 +443,12 @@ mt.register_craft({ burntime = 3 }) +mt.register_craft({ + output = "craftguide:sign", + type = "shapeless", + recipe = {"default:sign_wall_wood"} +}) + + mt.register_alias("xdecor:crafting_guide", "craftguide:book") diff --git a/textures/craftguide_sign.png b/textures/craftguide_sign.png new file mode 100644 index 0000000..dbd4cec Binary files /dev/null and b/textures/craftguide_sign.png differ diff --git a/textures/craftguide_sign_inventory.png b/textures/craftguide_sign_inventory.png new file mode 100644 index 0000000..649f405 Binary files /dev/null and b/textures/craftguide_sign_inventory.png differ