Minor style cleaning
This commit is contained in:
parent
2bc19694c1
commit
de94a402b9
@ -42,7 +42,8 @@ end
|
|||||||
|
|
||||||
function xdecor.sit_dig(pos, digger)
|
function xdecor.sit_dig(pos, digger)
|
||||||
for _, player in pairs(minetest.get_objects_inside_radius(pos, 0.1)) do
|
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
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
xdecor.box = {
|
xdecor.box = {
|
||||||
slab_y = function(height, shift)
|
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,
|
end,
|
||||||
slab_z = function(depth)
|
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,
|
end,
|
||||||
bar_y = function(radius)
|
bar_y = function(radius)
|
||||||
return { -radius, -0.5, -radius, radius, 0.5, radius }
|
return {-radius, -0.5, -radius, radius, 0.5, radius}
|
||||||
end,
|
end,
|
||||||
cuboid = function(radius_x, radius_y, radius_z)
|
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
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
xdecor.nodebox = {
|
xdecor.nodebox = {
|
||||||
regular = { type = "regular" },
|
regular = {type="regular"},
|
||||||
null = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } }
|
null = {type="fixed", fixed={0,0,0,0,0,0}}
|
||||||
}
|
}
|
||||||
|
|
||||||
xdecor.pixelbox = function(size, boxes)
|
xdecor.pixelbox = function(size, boxes)
|
||||||
@ -32,7 +33,7 @@ xdecor.pixelbox = function(size, boxes)
|
|||||||
((z + l) / size) - 0.5
|
((z + l) / size) - 0.5
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return { type = "fixed", fixed = fixed }
|
return {type="fixed", fixed=fixed}
|
||||||
end
|
end
|
||||||
|
|
||||||
local mt = {}
|
local mt = {}
|
||||||
@ -42,10 +43,10 @@ mt.__index = function(table, key)
|
|||||||
|
|
||||||
if ref_type == "function" then
|
if ref_type == "function" then
|
||||||
return function(...)
|
return function(...)
|
||||||
return { type = "fixed", fixed = ref(...) }
|
return {type="fixed", fixed=ref(...)}
|
||||||
end
|
end
|
||||||
elseif ref_type == "table" then
|
elseif ref_type == "table" then
|
||||||
return { type = "fixed", fixed = ref }
|
return {type="fixed", fixed=ref}
|
||||||
elseif ref_type == "nil" then
|
elseif ref_type == "nil" then
|
||||||
error(key.."could not be found among nodebox presets and functions")
|
error(key.."could not be found among nodebox presets and functions")
|
||||||
end
|
end
|
||||||
|
@ -43,10 +43,7 @@ local default_can_dig = function(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function xdecor.register(name, def)
|
function xdecor.register(name, def)
|
||||||
def.drawtype = def.drawtype
|
def.drawtype = def.drawtype or (def.mesh and "mesh") or (def.node_box and "nodebox")
|
||||||
or (def.mesh and "mesh")
|
|
||||||
or (def.node_box and "nodebox")
|
|
||||||
|
|
||||||
def.sounds = def.sounds or default.node_sound_defaults()
|
def.sounds = def.sounds or default.node_sound_defaults()
|
||||||
|
|
||||||
if not (def.drawtype == "normal" or def.drawtype == "signlike" or
|
if not (def.drawtype == "normal" or def.drawtype == "signlike" or
|
||||||
@ -79,7 +76,8 @@ function xdecor.register(name, def)
|
|||||||
local size = inventory.size or default_inventory_size
|
local size = inventory.size or default_inventory_size
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", size)
|
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
|
end
|
||||||
def.can_dig = def.can_dig or default_can_dig
|
def.can_dig = def.can_dig or default_can_dig
|
||||||
elseif infotext and not def.on_construct then
|
elseif infotext and not def.on_construct then
|
||||||
|
@ -77,7 +77,7 @@ function cauldron.idle_timer(pos)
|
|||||||
return true
|
return true
|
||||||
end
|
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 function eatable(itemstring)
|
||||||
local item = itemstring:match("[%w_:]+")
|
local item = itemstring:match("[%w_:]+")
|
||||||
local on_use_def = minetest.registered_items[item].on_use
|
local on_use_def = minetest.registered_items[item].on_use
|
||||||
|
@ -28,7 +28,8 @@ function enchanting:get_tooltip(enchant, orig_caps, fleshy)
|
|||||||
sum_caps_times = sum_caps_times + orig_caps.times[i]
|
sum_caps_times = sum_caps_times + orig_caps.times[i]
|
||||||
end
|
end
|
||||||
local average_caps_time = sum_caps_times / #orig_caps.times
|
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
|
end
|
||||||
if fleshy then
|
if fleshy then
|
||||||
bonus.damages = to_percent(fleshy, fleshy + enchanting.damages)
|
bonus.damages = to_percent(fleshy, fleshy + enchanting.damages)
|
||||||
@ -44,6 +45,14 @@ function enchanting:get_tooltip(enchant, orig_caps, fleshy)
|
|||||||
return minetest.colorize(specs[enchant][1], "\n"..cap(enchant)..specs[enchant][2])
|
return minetest.colorize(specs[enchant][1], "\n"..cap(enchant)..specs[enchant][2])
|
||||||
end
|
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)
|
function enchanting.formspec(pos, num)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -61,15 +70,6 @@ function enchanting.formspec(pos, num)
|
|||||||
tooltip[speed;Your speed is increased] ]]
|
tooltip[speed;Your speed is increased] ]]
|
||||||
..default.gui_slots..default.get_hotbar_bg(0.5,4.5)
|
..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 "")
|
formspec = formspec..(enchant_buttons[num] or "")
|
||||||
meta:set_string("formspec", formspec)
|
meta:set_string("formspec", formspec)
|
||||||
end
|
end
|
||||||
@ -92,9 +92,7 @@ function enchanting.on_put(pos, listname, _, stack)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function enchanting.fields(pos, _, fields, sender)
|
function enchanting.fields(pos, _, fields, sender)
|
||||||
if not next(fields) or fields.quit then
|
if not next(fields) or fields.quit then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
local tool = inv:get_stack("tool", 1)
|
local tool = inv:get_stack("tool", 1)
|
||||||
local mese = inv:get_stack("mese", 1)
|
local mese = inv:get_stack("mese", 1)
|
||||||
@ -103,7 +101,8 @@ function enchanting.fields(pos, _, fields, sender)
|
|||||||
local enchanted_tool = (mod or "")..":enchanted_"..(name or "").."_"..next(fields)
|
local enchanted_tool = (mod or "")..":enchanted_"..(name or "").."_"..next(fields)
|
||||||
|
|
||||||
if mese:get_count() >= mese_cost and minetest.registered_tools[enchanted_tool] then
|
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:replace(enchanted_tool)
|
||||||
tool:add_wear(orig_wear)
|
tool:add_wear(orig_wear)
|
||||||
mese:take_item(mese_cost)
|
mese:take_item(mese_cost)
|
||||||
@ -126,10 +125,10 @@ local function allowed(tool)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function enchanting.put(_, listname, _, stack)
|
function enchanting.put(_, listname, _, stack)
|
||||||
local item = stack:get_name():match("[^:]+$")
|
local stackname = stack:get_name()
|
||||||
if listname == "mese" and item == "mese_crystal" then
|
if listname == "mese" and stackname == "default:mese_crystal" then
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
elseif listname == "tool" and allowed(item) then
|
elseif listname == "tool" and allowed(stackname:match("[^:]+$")) then
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
@ -232,18 +231,20 @@ function enchanting:register_tools(mod, def)
|
|||||||
for enchant in def.tools[tool].enchants:gmatch("[%w_]+") do
|
for enchant in def.tools[tool].enchants:gmatch("[%w_]+") do
|
||||||
local original_tool = minetest.registered_tools[mod..":"..tool.."_"..material]
|
local original_tool = minetest.registered_tools[mod..":"..tool.."_"..material]
|
||||||
if not original_tool then break end
|
if not original_tool then break end
|
||||||
|
local original_toolcaps = original_tool.tool_capabilities
|
||||||
|
|
||||||
if original_tool.tool_capabilities then
|
if original_toolcaps then
|
||||||
local original_damage_groups = original_tool.tool_capabilities.damage_groups
|
local original_damage_groups = original_toolcaps.damage_groups
|
||||||
local original_groupcaps = original_tool.tool_capabilities.groupcaps
|
local original_groupcaps = original_toolcaps.groupcaps
|
||||||
local groupcaps = table.copy(original_groupcaps)
|
local groupcaps = table.copy(original_groupcaps)
|
||||||
local fleshy = original_damage_groups.fleshy
|
local fleshy = original_damage_groups.fleshy
|
||||||
local full_punch_interval = original_tool.tool_capabilities.full_punch_interval
|
local full_punch_interval = original_toolcaps.full_punch_interval
|
||||||
local max_drop_level = original_tool.tool_capabilities.max_drop_level
|
local max_drop_level = original_toolcaps.max_drop_level
|
||||||
local group = next(original_groupcaps)
|
local group = next(original_groupcaps)
|
||||||
|
|
||||||
if enchant == "durable" then
|
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
|
elseif enchant == "fast" then
|
||||||
for i, time in pairs(original_groupcaps[group].times) do
|
for i, time in pairs(original_groupcaps[group].times) do
|
||||||
groupcaps[group].times[i] = time - enchanting.times
|
groupcaps[group].times[i] = time - enchanting.times
|
||||||
@ -260,7 +261,8 @@ function enchanting:register_tools(mod, def)
|
|||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
groupcaps = groupcaps, damage_groups = {fleshy = fleshy},
|
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
|
end
|
||||||
|
@ -28,12 +28,12 @@ local function img_col(stack)
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
function mailbox:formspec(pos, owner, num)
|
function mailbox:formspec(pos, owner, is_owner)
|
||||||
local spos = pos.x..","..pos.y..","..pos.z
|
local spos = pos.x..","..pos.y..","..pos.z
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local giver, img = "", ""
|
local giver, img = "", ""
|
||||||
|
|
||||||
if num == 1 then
|
if is_owner then
|
||||||
for i = 1, 7 do
|
for i = 1, 7 do
|
||||||
local giving = meta:get_string("giver"..i)
|
local giving = meta:get_string("giver"..i)
|
||||||
if giving ~= "" then
|
if giving ~= "" then
|
||||||
@ -42,7 +42,8 @@ function mailbox:formspec(pos, owner, num)
|
|||||||
local stack_name = stack:match("[%w_:]+")
|
local stack_name = stack:match("[%w_:]+")
|
||||||
local stack_count = stack:match("%s(%d+)") or 1
|
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,"
|
img = img..i.."="..img_col(stack_name).."^\\[resize:16x16,"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -59,13 +60,12 @@ function mailbox:formspec(pos, owner, num)
|
|||||||
"list[nodemeta:"..spos..";mailbox;0,0.75;6,4;]"..
|
"list[nodemeta:"..spos..";mailbox;0,0.75;6,4;]"..
|
||||||
"listring[nodemeta:"..spos..";mailbox]"..
|
"listring[nodemeta:"..spos..";mailbox]"..
|
||||||
xbg..default.get_hotbar_bg(0.75,5.25)
|
xbg..default.get_hotbar_bg(0.75,5.25)
|
||||||
else
|
end
|
||||||
return [[ size[8,5]
|
return [[ size[8,5]
|
||||||
list[current_player;main;0,1.25;8,4;] ]]..
|
list[current_player;main;0,1.25;8,4;] ]]..
|
||||||
"label[0,0;Send your goods to\n"..minetest.colorize("#FFFF00", owner).."]"..
|
"label[0,0;Send your goods to\n"..minetest.colorize("#FFFF00", owner).."]"..
|
||||||
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
|
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
|
||||||
xbg..default.get_hotbar_bg(0,1.25)
|
xbg..default.get_hotbar_bg(0,1.25)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function mailbox.dig(pos, player)
|
function mailbox.dig(pos, player)
|
||||||
@ -94,11 +94,8 @@ function mailbox.rightclick(pos, node, clicker, itemstack, pointed_thing)
|
|||||||
local player = clicker:get_player_name()
|
local player = clicker:get_player_name()
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
|
|
||||||
if player == owner then
|
minetest.show_formspec(player, "xdecor:mailbox", mailbox:formspec(pos,
|
||||||
minetest.show_formspec(player, "xdecor:mailbox", mailbox:formspec(pos, owner, 1))
|
owner, (player == owner)))
|
||||||
else
|
|
||||||
minetest.show_formspec(player, "xdecor:mailbox", mailbox:formspec(pos, owner, 0))
|
|
||||||
end
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -108,7 +105,8 @@ function mailbox.put(pos, listname, _, stack, player)
|
|||||||
if inv:room_for_item("mailbox", stack) then
|
if inv:room_for_item("mailbox", stack) then
|
||||||
return -1
|
return -1
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
|
@ -26,7 +26,7 @@ for node, def in pairs(minetest.registered_nodes) do
|
|||||||
end
|
end
|
||||||
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 = {
|
workbench.custom_nodes_register = {
|
||||||
-- "default:leaves",
|
-- "default:leaves",
|
||||||
}
|
}
|
||||||
@ -172,7 +172,8 @@ end
|
|||||||
|
|
||||||
function workbench.put(_, listname, _, stack)
|
function workbench.put(_, listname, _, stack)
|
||||||
local stackname = stack:get_name()
|
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 == "input" and minetest.registered_nodes[stackname.."_cube"]) or
|
||||||
(listname == "hammer" and stackname == "xdecor:hammer") or
|
(listname == "hammer" and stackname == "xdecor:hammer") or
|
||||||
listname == "storage" then
|
listname == "storage" then
|
||||||
@ -243,7 +244,7 @@ xdecor.register("workbench", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
for _, d in pairs(workbench.defs) do
|
for _, d in pairs(workbench.defs) do
|
||||||
for i = 1, #nodes do
|
for i=1, #nodes do
|
||||||
local node = nodes[i]
|
local node = nodes[i]
|
||||||
local def = minetest.registered_nodes[node]
|
local def = minetest.registered_nodes[node]
|
||||||
|
|
||||||
@ -269,8 +270,9 @@ for i = 1, #nodes do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not minetest.registered_nodes["stairs:slab_"..node:match(":(.*)")] then
|
if not minetest.registered_nodes["stairs:slab_"..node:match(":(.*)")] then
|
||||||
stairs.register_stair_and_slab(node:match(":(.*)"), node, groups, tiles,
|
stairs.register_stair_and_slab(node:match(":(.*)"), node,
|
||||||
def.description.." Stair", def.description.." Slab", def.sounds)
|
groups, tiles, def.description.." Stair",
|
||||||
|
def.description.." Slab", def.sounds)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(":"..node.."_"..d[1], {
|
minetest.register_node(":"..node.."_"..d[1], {
|
||||||
|
Loading…
Reference in New Issue
Block a user