Minor style cleaning
This commit is contained in:
parent
76da7309d2
commit
e096e19e4e
@ -20,10 +20,8 @@ end
|
|||||||
|
|
||||||
function enchanting.is_allowed_tool(toolname)
|
function enchanting.is_allowed_tool(toolname)
|
||||||
local tdef = minetest.registered_tools[toolname]
|
local tdef = minetest.registered_tools[toolname]
|
||||||
if tdef and string.find(toolname, "default:") and not
|
if tdef and toolname:find("default:") and not toolname:find("sword") and not
|
||||||
string.find(toolname, "sword") and not
|
toolname:find("stone") and not toolname:find("wood") then
|
||||||
string.find(toolname, "stone") and not
|
|
||||||
string.find(toolname, "wood") then
|
|
||||||
return 1
|
return 1
|
||||||
else return 0 end
|
else return 0 end
|
||||||
end
|
end
|
||||||
@ -40,7 +38,7 @@ function enchanting.fields(pos, formname, fields, sender)
|
|||||||
|
|
||||||
for _, e in pairs(enchs) do
|
for _, e in pairs(enchs) do
|
||||||
if enchanting.is_allowed_tool(toolname) ~= 0 and mese > 0 and fields[e] then
|
if enchanting.is_allowed_tool(toolname) ~= 0 and mese > 0 and fields[e] then
|
||||||
toolstack:replace("xdecor:enchanted_"..string.sub(toolname, 9).."_"..e)
|
toolstack:replace("xdecor:enchanted_"..toolname:sub(9).."_"..e)
|
||||||
toolstack:add_wear(toolwear)
|
toolstack:add_wear(toolwear)
|
||||||
mesestack:take_item()
|
mesestack:take_item()
|
||||||
inv:set_stack("mese", 1, mesestack)
|
inv:set_stack("mese", 1, mesestack)
|
||||||
@ -74,8 +72,7 @@ function enchanting.put(pos, listname, index, stack, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function enchanting.move(pos, from_list, from_index, to_list, to_index, count, player)
|
function enchanting.move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
return 0
|
return 0 end
|
||||||
end
|
|
||||||
|
|
||||||
xdecor.register("enchantment_table", {
|
xdecor.register("enchantment_table", {
|
||||||
description = "Enchantment Table",
|
description = "Enchantment Table",
|
||||||
@ -94,10 +91,10 @@ xdecor.register("enchantment_table", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function enchanting.register_enchtools(init, m, def)
|
function enchanting.register_enchtools(init, m, def)
|
||||||
local longer = init["uses"] * 1.2 -- Higher number = longer use.
|
local longer = init.uses * 1.2 -- Higher number = longer use.
|
||||||
local faster = {}
|
local faster = {}
|
||||||
for i = 1, 3 do
|
for i = 1, 3 do
|
||||||
faster[i] = init["times"][i] - 0.1 -- Higher number = faster dig.
|
faster[i] = init.times[i] - 0.1 -- Higher number = faster dig.
|
||||||
end
|
end
|
||||||
|
|
||||||
local fast = {times=faster, uses=def.uses, maxlevel=def.maxlvl}
|
local fast = {times=faster, uses=def.uses, maxlevel=def.maxlvl}
|
||||||
@ -111,10 +108,9 @@ function enchanting.register_enchtools(init, m, def)
|
|||||||
for _, x in pairs(enchtools) do
|
for _, x in pairs(enchtools) do
|
||||||
local t, e, g = x[1], x[2], x[3]
|
local t, e, g = x[1], x[2], x[3]
|
||||||
minetest.register_tool("xdecor:enchanted_"..t.."_"..m.."_"..e, {
|
minetest.register_tool("xdecor:enchanted_"..t.."_"..m.."_"..e, {
|
||||||
description = "Enchanted "..string.gsub(m, "%l", string.upper, 1)..
|
description = "Enchanted "..m:gsub("%l", string.upper, 1).." "..
|
||||||
" "..string.gsub(t, "%l", string.upper, 1)..
|
t:gsub("%l", string.upper, 1).." ("..e:gsub("%l", string.upper, 1)..")",
|
||||||
" ("..string.gsub(e, "%l", string.upper, 1)..")",
|
inventory_image = minetest.registered_tools["default:"..t.."_"..m].inventory_image,
|
||||||
inventory_image = minetest.registered_tools["default:"..t.."_"..m]["inventory_image"],
|
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
tool_capabilities = {groupcaps = g, damage_groups = def.dmg}
|
tool_capabilities = {groupcaps = g, damage_groups = def.dmg}
|
||||||
})
|
})
|
||||||
@ -127,17 +123,17 @@ local tools = {
|
|||||||
local materials = {"steel", "bronze", "mese", "diamond"}
|
local materials = {"steel", "bronze", "mese", "diamond"}
|
||||||
|
|
||||||
for _, t in pairs(tools) do
|
for _, t in pairs(tools) do
|
||||||
for _, m in pairs(materials) do
|
for _, material in pairs(materials) do
|
||||||
local tool, group = t[1], t[2]
|
local tool, group = t[1], t[2]
|
||||||
local toolname = tool.."_"..m
|
local toolname = tool.."_"..material
|
||||||
local init_def = minetest.registered_tools["default:"..toolname]["tool_capabilities"]["groupcaps"][group]
|
local init_def = minetest.registered_tools["default:"..toolname].tool_capabilities.groupcaps[group]
|
||||||
|
|
||||||
local tooldef = {
|
local tooldef = {
|
||||||
times = init_def["times"],
|
times = init_def.times,
|
||||||
uses = init_def["uses"],
|
uses = init_def.uses,
|
||||||
dmg = init_def["damage_groups"],
|
dmg = init_def.damage_groups,
|
||||||
maxlvl = init_def["maxlevel"]
|
maxlvl = init_def.maxlevel
|
||||||
}
|
}
|
||||||
enchanting.register_enchtools(init_def, m, tooldef)
|
enchanting.register_enchtools(init_def, material, tooldef)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,7 @@ xdecor.box = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
hive.lua
18
hive.lua
@ -1,4 +1,6 @@
|
|||||||
local function hive_construct(pos)
|
local hive = {}
|
||||||
|
|
||||||
|
function hive.construct(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", "size[8,5;]"..xdecor.fancy_gui..
|
meta:set_string("formspec", "size[8,5;]"..xdecor.fancy_gui..
|
||||||
"label[1.35,0;Bees are making honey\nwith pollen around...]"..
|
"label[1.35,0;Bees are making honey\nwith pollen around...]"..
|
||||||
@ -14,13 +16,11 @@ local function hive_construct(pos)
|
|||||||
inv:set_size("honey", 1)
|
inv:set_size("honey", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hive_dig(pos, player)
|
function hive.dig(pos, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
if not inv:is_empty("honey") then
|
if not inv:is_empty("honey") then return false end
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -35,8 +35,8 @@ xdecor.register("hive", {
|
|||||||
"xdecor_hive_front.png",
|
"xdecor_hive_front.png",
|
||||||
},
|
},
|
||||||
groups = {snappy=3, flammable=1},
|
groups = {snappy=3, flammable=1},
|
||||||
on_construct = hive_construct,
|
on_construct = hive.construct,
|
||||||
can_dig = hive_dig,
|
can_dig = hive.dig,
|
||||||
on_punch = function(pos, node, puncher, pointed_thing)
|
on_punch = function(pos, node, puncher, pointed_thing)
|
||||||
local health = puncher:get_hp()
|
local health = puncher:get_hp()
|
||||||
puncher:set_hp(health-4)
|
puncher:set_hp(health-4)
|
||||||
@ -59,8 +59,6 @@ minetest.register_abm({
|
|||||||
local maxp = {x=pos.x+radius, y=pos.y+radius, z=pos.z+radius}
|
local maxp = {x=pos.x+radius, y=pos.y+radius, z=pos.z+radius}
|
||||||
local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
|
local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
|
||||||
|
|
||||||
if #flowers >= 4 then
|
if #flowers >= 4 then inv:add_item("honey", "xdecor:honey") end
|
||||||
inv:add_item("honey", "xdecor:honey")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -243,7 +243,7 @@ local door_types = {"woodglass", "japanese"}
|
|||||||
|
|
||||||
for _, d in pairs(door_types) do
|
for _, d in pairs(door_types) do
|
||||||
doors.register_door("xdecor:"..d.."_door", {
|
doors.register_door("xdecor:"..d.."_door", {
|
||||||
description = string.gsub(d, "%l", string.upper, 1).." Door",
|
description = d:gsub("%l", string.upper, 1).." Door",
|
||||||
inventory_image = "xdecor_"..d.."_door_inv.png",
|
inventory_image = "xdecor_"..d.."_door_inv.png",
|
||||||
groups = {choppy=3, flammable=2, door=1},
|
groups = {choppy=3, flammable=2, door=1},
|
||||||
tiles_bottom = {"xdecor_"..d.."_door_b.png", "xdecor_brown.png"},
|
tiles_bottom = {"xdecor_"..d.."_door_b.png", "xdecor_brown.png"},
|
||||||
|
18
rope.lua
18
rope.lua
@ -1,16 +1,13 @@
|
|||||||
local rope_sbox = {
|
local rope = {}
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Code by Mirko K. (modified by Temperest, Wulfsdad and kilbith) (License: GPL).
|
-- Code by Mirko K. (modified by Temperest, Wulfsdad and kilbith) (License: GPL).
|
||||||
minetest.register_on_punchnode(function(pos, oldnode, digger)
|
minetest.register_on_punchnode(function(pos, oldnode, digger)
|
||||||
if oldnode.name == "xdecor:rope" then
|
if oldnode.name == "xdecor:rope" then
|
||||||
remove_rope(pos, oldnode, digger, "xdecor:rope")
|
rope.remove(pos, oldnode, digger, "xdecor:rope")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function place_rope(itemstack, placer, pointed_thing)
|
function rope.place(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
@ -29,7 +26,7 @@ local function place_rope(itemstack, placer, pointed_thing)
|
|||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
function remove_rope(pos, oldnode, digger, rope_name)
|
function rope.remove(pos, oldnode, digger, rope_name)
|
||||||
local num = 0
|
local num = 0
|
||||||
local below = {x=pos.x, y=pos.y, z=pos.z}
|
local below = {x=pos.x, y=pos.y, z=pos.z}
|
||||||
local digger_inv = digger:get_inventory()
|
local digger_inv = digger:get_inventory()
|
||||||
@ -50,9 +47,12 @@ xdecor.register("rope", {
|
|||||||
walkable = false,
|
walkable = false,
|
||||||
climbable = true,
|
climbable = true,
|
||||||
groups = {dig_immediate=3, flammable=3},
|
groups = {dig_immediate=3, flammable=3},
|
||||||
selection_box = rope_sbox,
|
|
||||||
tiles = {"xdecor_rope.png"},
|
tiles = {"xdecor_rope.png"},
|
||||||
inventory_image = "xdecor_rope_inv.png",
|
inventory_image = "xdecor_rope_inv.png",
|
||||||
wield_image = "xdecor_rope_inv.png",
|
wield_image = "xdecor_rope_inv.png",
|
||||||
on_place = place_rope
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
|
||||||
|
},
|
||||||
|
on_place = rope.place
|
||||||
})
|
})
|
||||||
|
@ -45,7 +45,7 @@ function worktable.construct(pos)
|
|||||||
"label[5,1.5;Tool]"..
|
"label[5,1.5;Tool]"..
|
||||||
"list[current_name;tool;5,2;1,1;]"..
|
"list[current_name;tool;5,2;1,1;]"..
|
||||||
"image[6,2;1,1;xdecor_anvil.png]"..
|
"image[6,2;1,1;xdecor_anvil.png]"..
|
||||||
"label[6.8,1.5;Hammer]]"..
|
"label[6.8,1.5;Hammer]"..
|
||||||
"list[current_name;hammer;7,2;1,1;]"..
|
"list[current_name;hammer;7,2;1,1;]"..
|
||||||
"list[current_player;main;0,3.25;8,4;]")
|
"list[current_player;main;0,3.25;8,4;]")
|
||||||
meta:set_string("infotext", "Work Table")
|
meta:set_string("infotext", "Work Table")
|
||||||
@ -64,15 +64,16 @@ function worktable.fields(pos, formname, fields, sender)
|
|||||||
local outputstack = inv:get_stack("output", 1)
|
local outputstack = inv:get_stack("output", 1)
|
||||||
local outputcount = outputstack:get_count()
|
local outputcount = outputstack:get_count()
|
||||||
local inputname = inputstack:get_name()
|
local inputname = inputstack:get_name()
|
||||||
|
local outputname = outputstack:get_name()
|
||||||
local shape, get = {}, {}
|
local shape, get = {}, {}
|
||||||
local anz = 0
|
local anz = 0
|
||||||
|
|
||||||
for _, d in pairs(def) do
|
for _, d in pairs(def) do
|
||||||
local nb, anz = d[1], d[2]
|
local nb, anz = d[1], d[2]
|
||||||
if outputcount < 99 and fields[nb] then
|
if outputcount < 99 and fields[nb] then
|
||||||
local outputshape = string.match(outputstack:get_name(), nb)
|
local outputshape = outputname:match(nb)
|
||||||
if nb ~= outputshape and outputcount > 0 then return end
|
if nb ~= outputshape and outputcount > 0 then return end
|
||||||
shape = "xdecor:"..nb.."_"..string.sub(inputname, 9)
|
shape = "xdecor:"..nb.."_"..inputname:sub(9)
|
||||||
get = shape.." "..anz
|
get = shape.." "..anz
|
||||||
|
|
||||||
if minetest.registered_nodes[shape] then
|
if minetest.registered_nodes[shape] then
|
||||||
@ -101,8 +102,7 @@ function worktable.put(pos, listname, index, stack, player)
|
|||||||
|
|
||||||
if listname == "output" then return 0 end
|
if listname == "output" then return 0 end
|
||||||
if listname == "input" then
|
if listname == "input" then
|
||||||
if string.find(stackname, "default:") then return count
|
if stackname:find("default:") then return count else return 0 end
|
||||||
else return 0 end
|
|
||||||
end
|
end
|
||||||
if listname == "hammer" then
|
if listname == "hammer" then
|
||||||
if not (stackname == "xdecor:hammer") then return 0 end
|
if not (stackname == "xdecor:hammer") then return 0 end
|
||||||
@ -117,8 +117,7 @@ function worktable.put(pos, listname, index, stack, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function worktable.move(pos, from_list, from_index, to_list, to_index, count, player)
|
function worktable.move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
return 0
|
return 0 end
|
||||||
end
|
|
||||||
|
|
||||||
xdecor.register("worktable", {
|
xdecor.register("worktable", {
|
||||||
description = "Work Table",
|
description = "Work Table",
|
||||||
@ -145,11 +144,11 @@ for n=1, #def do
|
|||||||
|
|
||||||
local function description(m)
|
local function description(m)
|
||||||
if m == "cloud" then return "" end
|
if m == "cloud" then return "" end
|
||||||
return string.gsub(m, "%l", string.upper, 1).." "..string.gsub(w[1], "%l", string.upper, 1)
|
return m:gsub("%l", string.upper, 1).." "..w[1]:gsub("%l", string.upper, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function groups(m)
|
local function groups(m)
|
||||||
if string.find(m, "tree") or string.find(m, "wood") or m == "cactus" then
|
if m:find("tree") or m:find("wood") or m == "cactus" then
|
||||||
return {choppy=3, not_in_creative_inventory=1}
|
return {choppy=3, not_in_creative_inventory=1}
|
||||||
elseif m == "clay" or m == "snowblock" then
|
elseif m == "clay" or m == "snowblock" then
|
||||||
return {snappy=3, not_in_creative_inventory=1}
|
return {snappy=3, not_in_creative_inventory=1}
|
||||||
@ -158,7 +157,7 @@ for n=1, #def do
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function shady(w)
|
local function shady(w)
|
||||||
if string.find(w, "stair") or w == "slab" then return false end
|
if w:find("stair") or w == "slab" then return false end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
11
xwall.lua
11
xwall.lua
@ -29,11 +29,8 @@ local function clone_table(table)
|
|||||||
local newtable = {}
|
local newtable = {}
|
||||||
|
|
||||||
for idx, item in pairs(table) do
|
for idx, item in pairs(table) do
|
||||||
if type(item) == "table" then
|
if type(item) == "table" then newtable[idx] = clone_table(item)
|
||||||
newtable[idx] = clone_table(item)
|
else newtable[idx] = item end
|
||||||
else
|
|
||||||
newtable[idx] = item
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return newtable
|
return newtable
|
||||||
@ -66,7 +63,7 @@ function xwall.update_one_node(pos, name, digged)
|
|||||||
|
|
||||||
local newnode = xwall.get_candidate[id]
|
local newnode = xwall.get_candidate[id]
|
||||||
if newnode and newnode[1] then
|
if newnode and newnode[1] then
|
||||||
local newname = string.sub(name, 1, string.len(name)-3)..newnode[1]
|
local newname = name:sub(1, name:len()-3)..newnode[1]
|
||||||
if newname and minetest.registered_nodes[newname] then
|
if newname and minetest.registered_nodes[newname] then
|
||||||
minetest.swap_node(pos, {name=newname, param2=newnode[2]})
|
minetest.swap_node(pos, {name=newname, param2=newnode[2]})
|
||||||
elseif newnode[1] == '_c0' and not minetest.registered_nodes[newname] then
|
elseif newnode[1] == '_c0' and not minetest.registered_nodes[newname] then
|
||||||
@ -189,7 +186,7 @@ function xwall.register_wall(name, tiles, def)
|
|||||||
|
|
||||||
if def then return end
|
if def then return end
|
||||||
def = {
|
def = {
|
||||||
description = string.sub(string.gsub(name, "%l", string.upper, 7), 8, -6).." Wall",
|
description = string.sub(name:gsub("%l", string.upper, 7), 8, -6).." Wall",
|
||||||
textures = {tiles, tiles, tiles, tiles},
|
textures = {tiles, tiles, tiles, tiles},
|
||||||
sounds = xdecor.stone,
|
sounds = xdecor.stone,
|
||||||
groups = {cracky=3, stone=1, pane=1},
|
groups = {cracky=3, stone=1, pane=1},
|
||||||
|
Loading…
Reference in New Issue
Block a user