function xdecor.sit_dig(pos, digger)
for _, player in pairs(minetest.get_objects_inside_radius(pos, 0.1)) do
- if player:is_player() and default.player_attached[player:get_player_name()] then
+ if player:is_player() and
+ default.player_attached[player:get_player_name()] then
return false
end
end
xdecor.box = {
slab_y = function(height, shift)
- return { -0.5, -0.5+(shift or 0), -0.5, 0.5, -0.5+height+(shift or 0), 0.5 }
+ return {-0.5, -0.5 + (shift or 0), -0.5, 0.5, -0.5 + height +
+ (shift or 0), 0.5}
end,
slab_z = function(depth)
- return { -0.5, -0.5, -0.5+depth, 0.5, 0.5, 0.5 }
+ return {-0.5, -0.5, -0.5 + depth, 0.5, 0.5, 0.5}
end,
bar_y = function(radius)
- return { -radius, -0.5, -radius, radius, 0.5, radius }
+ return {-radius, -0.5, -radius, radius, 0.5, radius}
end,
cuboid = function(radius_x, radius_y, radius_z)
- return { -radius_x, -radius_y, -radius_z, radius_x, radius_y, radius_z }
+ return {-radius_x, -radius_y, -radius_z, radius_x, radius_y, radius_z}
end
}
xdecor.nodebox = {
- regular = { type = "regular" },
- null = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } }
+ regular = {type="regular"},
+ null = {type="fixed", fixed={0,0,0,0,0,0}}
}
xdecor.pixelbox = function(size, boxes)
((z + l) / size) - 0.5
}
end
- return { type = "fixed", fixed = fixed }
+ return {type="fixed", fixed=fixed}
end
local mt = {}
if ref_type == "function" then
return function(...)
- return { type = "fixed", fixed = ref(...) }
+ return {type="fixed", fixed=ref(...)}
end
elseif ref_type == "table" then
- return { type = "fixed", fixed = ref }
+ return {type="fixed", fixed=ref}
elseif ref_type == "nil" then
error(key.."could not be found among nodebox presets and functions")
end
end
function xdecor.register(name, def)
- def.drawtype = def.drawtype
- or (def.mesh and "mesh")
- or (def.node_box and "nodebox")
-
+ def.drawtype = def.drawtype or (def.mesh and "mesh") or (def.node_box and "nodebox")
def.sounds = def.sounds or default.node_sound_defaults()
if not (def.drawtype == "normal" or def.drawtype == "signlike" or
local size = inventory.size or default_inventory_size
local inv = meta:get_inventory()
inv:set_size("main", size)
- meta:set_string("formspec", (inventory.formspec or get_formspec_by_size(size))..xbg)
+ meta:set_string("formspec", (inventory.formspec or
+ get_formspec_by_size(size))..xbg)
end
def.can_dig = def.can_dig or default_can_dig
elseif infotext and not def.on_construct then
return true
end
--- Ugly hack to determine if an item has `minetest.item_eat` in its definition.
+-- Ugly hack to determine if an item has the function `minetest.item_eat` in its definition.
local function eatable(itemstring)
local item = itemstring:match("[%w_:]+")
local on_use_def = minetest.registered_items[item].on_use
sum_caps_times = sum_caps_times + orig_caps.times[i]
end
local average_caps_time = sum_caps_times / #orig_caps.times
- bonus.efficiency = to_percent(average_caps_time, average_caps_time - enchanting.times)
+ bonus.efficiency = to_percent(average_caps_time, average_caps_time -
+ enchanting.times)
end
if fleshy then
bonus.damages = to_percent(fleshy, fleshy + enchanting.damages)
return minetest.colorize(specs[enchant][1], "\n"..cap(enchant)..specs[enchant][2])
end
+local enchant_buttons = {
+ [[ image_button[3.9,0.85;4,0.92;bg_btn.png;fast;Efficiency]
+ image_button[3.9,1.77;4,1.12;bg_btn.png;durable;Durability] ]],
+ "image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]",
+ "image_button[3.9,2.9;4,0.92;bg_btn.png;sharp;Sharpness]",
+ [[ image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]
+ image_button[3.9,1.77;4,1.12;bg_btn.png;speed;Speed] ]]
+}
function enchanting.formspec(pos, num)
local meta = minetest.get_meta(pos)
tooltip[speed;Your speed is increased] ]]
..default.gui_slots..default.get_hotbar_bg(0.5,4.5)
- local enchant_buttons = {
- [[ image_button[3.9,0.85;4,0.92;bg_btn.png;fast;Efficiency]
- image_button[3.9,1.77;4,1.12;bg_btn.png;durable;Durability] ]],
- "image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]",
- "image_button[3.9,2.9;4,0.92;bg_btn.png;sharp;Sharpness]",
- [[ image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]
- image_button[3.9,1.77;4,1.12;bg_btn.png;speed;Speed] ]]
- }
-
formspec = formspec..(enchant_buttons[num] or "")
meta:set_string("formspec", formspec)
end
end
function enchanting.fields(pos, _, fields, sender)
- if not next(fields) or fields.quit then
- return
- end
+ if not next(fields) or fields.quit then return end
local inv = minetest.get_meta(pos):get_inventory()
local tool = inv:get_stack("tool", 1)
local mese = inv:get_stack("mese", 1)
local enchanted_tool = (mod or "")..":enchanted_"..(name or "").."_"..next(fields)
if mese:get_count() >= mese_cost and minetest.registered_tools[enchanted_tool] then
- minetest.sound_play("xdecor_enchanting", {to_player=sender:get_player_name(), gain=0.8})
+ minetest.sound_play("xdecor_enchanting", {
+ to_player=sender:get_player_name(), gain=0.8})
tool:replace(enchanted_tool)
tool:add_wear(orig_wear)
mese:take_item(mese_cost)
end
function enchanting.put(_, listname, _, stack)
- local item = stack:get_name():match("[^:]+$")
- if listname == "mese" and item == "mese_crystal" then
+ local stackname = stack:get_name()
+ if listname == "mese" and stackname == "default:mese_crystal" then
return stack:get_count()
- elseif listname == "tool" and allowed(item) then
+ elseif listname == "tool" and allowed(stackname:match("[^:]+$")) then
return 1
end
return 0
for enchant in def.tools[tool].enchants:gmatch("[%w_]+") do
local original_tool = minetest.registered_tools[mod..":"..tool.."_"..material]
if not original_tool then break end
+ local original_toolcaps = original_tool.tool_capabilities
- if original_tool.tool_capabilities then
- local original_damage_groups = original_tool.tool_capabilities.damage_groups
- local original_groupcaps = original_tool.tool_capabilities.groupcaps
+ if original_toolcaps then
+ local original_damage_groups = original_toolcaps.damage_groups
+ local original_groupcaps = original_toolcaps.groupcaps
local groupcaps = table.copy(original_groupcaps)
local fleshy = original_damage_groups.fleshy
- local full_punch_interval = original_tool.tool_capabilities.full_punch_interval
- local max_drop_level = original_tool.tool_capabilities.max_drop_level
+ local full_punch_interval = original_toolcaps.full_punch_interval
+ local max_drop_level = original_toolcaps.max_drop_level
local group = next(original_groupcaps)
if enchant == "durable" then
- groupcaps[group].uses = ceil(original_groupcaps[group].uses * enchanting.uses)
+ groupcaps[group].uses = ceil(original_groupcaps[group].uses *
+ enchanting.uses)
elseif enchant == "fast" then
for i, time in pairs(original_groupcaps[group].times) do
groupcaps[group].times[i] = time - enchanting.times
groups = {not_in_creative_inventory=1},
tool_capabilities = {
groupcaps = groupcaps, damage_groups = {fleshy = fleshy},
- full_punch_interval = full_punch_interval, max_drop_level = max_drop_level
+ full_punch_interval = full_punch_interval,
+ max_drop_level = max_drop_level
}
})
end
return ""
end
-function mailbox:formspec(pos, owner, num)
+function mailbox:formspec(pos, owner, is_owner)
local spos = pos.x..","..pos.y..","..pos.z
local meta = minetest.get_meta(pos)
local giver, img = "", ""
- if num == 1 then
+ if is_owner then
for i = 1, 7 do
local giving = meta:get_string("giver"..i)
if giving ~= "" then
local stack_name = stack:match("[%w_:]+")
local stack_count = stack:match("%s(%d+)") or 1
- giver = giver.."#FFFF00,"..giver_name..","..i..",#FFFFFF,x "..stack_count..","
+ giver = giver.."#FFFF00,"..giver_name..","..i..
+ ",#FFFFFF,x "..stack_count..","
img = img..i.."="..img_col(stack_name).."^\\[resize:16x16,"
end
end
"list[nodemeta:"..spos..";mailbox;0,0.75;6,4;]"..
"listring[nodemeta:"..spos..";mailbox]"..
xbg..default.get_hotbar_bg(0.75,5.25)
- else
- return [[ size[8,5]
- list[current_player;main;0,1.25;8,4;] ]]..
- "label[0,0;Send your goods to\n"..minetest.colorize("#FFFF00", owner).."]"..
- "list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
- xbg..default.get_hotbar_bg(0,1.25)
end
+ return [[ size[8,5]
+ list[current_player;main;0,1.25;8,4;] ]]..
+ "label[0,0;Send your goods to\n"..minetest.colorize("#FFFF00", owner).."]"..
+ "list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
+ xbg..default.get_hotbar_bg(0,1.25)
end
function mailbox.dig(pos, player)
local player = clicker:get_player_name()
local owner = meta:get_string("owner")
- if player == owner then
- minetest.show_formspec(player, "xdecor:mailbox", mailbox:formspec(pos, owner, 1))
- else
- minetest.show_formspec(player, "xdecor:mailbox", mailbox:formspec(pos, owner, 0))
- end
+ minetest.show_formspec(player, "xdecor:mailbox", mailbox:formspec(pos,
+ owner, (player == owner)))
return itemstack
end
if inv:room_for_item("mailbox", stack) then
return -1
else
- minetest.chat_send_player(player:get_player_name(), "The mailbox is full")
+ minetest.chat_send_player(player:get_player_name(),
+ "The mailbox is full")
end
end
return 0
end
end
--- Optionally, you can register custom cuttable nodes in the workbench
+-- Optionally, you can register custom cuttable nodes in the workbench.
workbench.custom_nodes_register = {
-- "default:leaves",
}
function workbench.put(_, listname, _, stack)
local stackname = stack:get_name()
- if (listname == "tool" and stack:get_wear() > 0 and workbench:repairable(stackname)) or
+ if (listname == "tool" and stack:get_wear() > 0 and
+ workbench:repairable(stackname)) or
(listname == "input" and minetest.registered_nodes[stackname.."_cube"]) or
(listname == "hammer" and stackname == "xdecor:hammer") or
listname == "storage" then
})
for _, d in pairs(workbench.defs) do
-for i = 1, #nodes do
+for i=1, #nodes do
local node = nodes[i]
local def = minetest.registered_nodes[node]
end
if not minetest.registered_nodes["stairs:slab_"..node:match(":(.*)")] then
- stairs.register_stair_and_slab(node:match(":(.*)"), node, groups, tiles,
- def.description.." Stair", def.description.." Slab", def.sounds)
+ stairs.register_stair_and_slab(node:match(":(.*)"), node,
+ groups, tiles, def.description.." Stair",
+ def.description.." Slab", def.sounds)
end
minetest.register_node(":"..node.."_"..d[1], {