Fix ndef error and prepare enchanting table
This commit is contained in:
parent
5d8db6a8ef
commit
c497b36e60
@ -131,6 +131,15 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "xdecor:enchantment_table",
|
||||
recipe = {
|
||||
{"", "default:book", ""},
|
||||
{"default:diamond", "default:obsidian", "default:diamond"},
|
||||
{"default:obsidian", "default:obsidian", "default:obsidian"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "xdecor:fence_wrought_iron 2",
|
||||
recipe = {
|
||||
|
65
enchanting.lua
Normal file
65
enchanting.lua
Normal file
@ -0,0 +1,65 @@
|
||||
local function enchconstruct(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", "size[8,7;]"..xdecor.fancy_gui..
|
||||
"label[0.65,-0.15;Enchant]"..
|
||||
"image[0.4,0.2;2,2;default_book.png]"..
|
||||
"list[current_name;tool;0.3,2;1,1;]"..
|
||||
"list[current_name;mese;1.3,2;1,1;]"..
|
||||
"image_button[2.5,0;5.3,1.1;bg.png;durable;Durable]"..
|
||||
"image_button[2.5,1;5.3,1.1;bg.png;fast;Fast]"..
|
||||
"image_button[2.5,2;5.3,1.1;bg.png;luck;Luck]"..
|
||||
"list[current_player;main;0,3.3;8,4;]")
|
||||
meta:set_string("infotext", "Enchantment Table")
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("tool", 1)
|
||||
inv:set_size("mese", 1)
|
||||
end
|
||||
|
||||
local function enchdig(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if not inv:is_empty("tool") or not inv:is_empty("mese") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function enchput(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if listname == "mese" then
|
||||
if stack:get_name() == "default:mese_crystal" then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
if listname == "tool" then
|
||||
local tname = stack:get_name()
|
||||
local tdef = minetest.registered_tools[tname]
|
||||
|
||||
if tdef then return 1 else return 0 end
|
||||
end
|
||||
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
xdecor.register("enchantment_table", {
|
||||
description = "Enchantment Table",
|
||||
tiles = {
|
||||
"xdecor_enchantment_top.png",
|
||||
"xdecor_enchantment_bottom.png",
|
||||
"xdecor_enchantment_side.png",
|
||||
"xdecor_enchantment_side.png",
|
||||
"xdecor_enchantment_side.png",
|
||||
"xdecor_enchantment_side.png",
|
||||
},
|
||||
groups = {cracky=1},
|
||||
sounds = xdecor.stone,
|
||||
on_construct = enchconstruct,
|
||||
can_dig = enchdig,
|
||||
allow_metadata_inventory_put = enchput
|
||||
})
|
1
init.lua
1
init.lua
@ -4,6 +4,7 @@ modpath = minetest.get_modpath("xdecor")
|
||||
dofile(modpath.."/handlers/nodeboxes.lua")
|
||||
dofile(modpath.."/handlers/registration.lua")
|
||||
dofile(modpath.."/crafts.lua")
|
||||
--dofile(modpath.."/enchanting.lua") -- In development.
|
||||
dofile(modpath.."/hive.lua")
|
||||
dofile(modpath.."/itemframe.lua")
|
||||
dofile(modpath.."/mailbox.lua")
|
||||
|
BIN
textures/bg.png
Normal file
BIN
textures/bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 231 B |
@ -1,7 +1,7 @@
|
||||
local material = {
|
||||
"cloud", -- Only used for the formspec display.
|
||||
"wood", "junglewood", "pinewood",
|
||||
"tree", "jungletree", "pinetree",
|
||||
"wood", "junglewood", "pinewood", "acacia_wood",
|
||||
"tree", "jungletree", "pinetree", "acacia_tree",
|
||||
"cobble", "mossycobble", "desert_cobble",
|
||||
"stone", "sandstone", "desert_stone", "obsidian",
|
||||
"stonebrick", "sandstonebrick", "desert_stonebrick", "obsidianbrick",
|
||||
@ -135,20 +135,22 @@ for m=1, #material do
|
||||
local w = def[n]
|
||||
local nodename = "default:"..v
|
||||
local ndef = minetest.registered_nodes[nodename]
|
||||
|
||||
xdecor.register(w[1].."_"..v, {
|
||||
description = string.sub(string.upper(w[1]), 0, 1)..
|
||||
string.sub(w[1], 2),
|
||||
light_source = ndef.light_source,
|
||||
sounds = ndef.sounds,
|
||||
tiles = ndef.tiles,
|
||||
groups = {snappy=3, not_in_creative_inventory=1},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = w[3]
|
||||
},
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
if ndef then
|
||||
xdecor.register(w[1].."_"..v, {
|
||||
description = string.sub(string.upper(w[1]), 0, 1)..
|
||||
string.sub(w[1], 2),
|
||||
light_source = ndef.light_source,
|
||||
sounds = ndef.sounds,
|
||||
tiles = ndef.tiles,
|
||||
groups = {snappy=3, not_in_creative_inventory=1},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = w[3]
|
||||
},
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user