Skip to content
Snippets Groups Projects
Commit e096e19e authored by jp's avatar jp
Browse files

Minor style cleaning

parent 76da7309
No related branches found
No related tags found
No related merge requests found
......@@ -20,10 +20,8 @@ end
function enchanting.is_allowed_tool(toolname)
local tdef = minetest.registered_tools[toolname]
if tdef and string.find(toolname, "default:") and not
string.find(toolname, "sword") and not
string.find(toolname, "stone") and not
string.find(toolname, "wood") then
if tdef and toolname:find("default:") and not toolname:find("sword") and not
toolname:find("stone") and not toolname:find("wood") then
return 1
else return 0 end
end
......@@ -40,7 +38,7 @@ function enchanting.fields(pos, formname, fields, sender)
for _, e in pairs(enchs) do
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)
mesestack:take_item()
inv:set_stack("mese", 1, mesestack)
......@@ -74,8 +72,7 @@ function enchanting.put(pos, listname, index, stack, player)
end
function enchanting.move(pos, from_list, from_index, to_list, to_index, count, player)
return 0
end
return 0 end
xdecor.register("enchantment_table", {
description = "Enchantment Table",
......@@ -94,10 +91,10 @@ xdecor.register("enchantment_table", {
})
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 = {}
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
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
local t, e, g = x[1], x[2], x[3]
minetest.register_tool("xdecor:enchanted_"..t.."_"..m.."_"..e, {
description = "Enchanted "..string.gsub(m, "%l", string.upper, 1)..
" "..string.gsub(t, "%l", string.upper, 1)..
" ("..string.gsub(e, "%l", string.upper, 1)..")",
inventory_image = minetest.registered_tools["default:"..t.."_"..m]["inventory_image"],
description = "Enchanted "..m:gsub("%l", string.upper, 1).." "..
t:gsub("%l", string.upper, 1).." ("..e:gsub("%l", string.upper, 1)..")",
inventory_image = minetest.registered_tools["default:"..t.."_"..m].inventory_image,
groups = {not_in_creative_inventory=1},
tool_capabilities = {groupcaps = g, damage_groups = def.dmg}
})
......@@ -127,17 +123,17 @@ local tools = {
local materials = {"steel", "bronze", "mese", "diamond"}
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 toolname = tool.."_"..m
local init_def = minetest.registered_tools["default:"..toolname]["tool_capabilities"]["groupcaps"][group]
local toolname = tool.."_"..material
local init_def = minetest.registered_tools["default:"..toolname].tool_capabilities.groupcaps[group]
local tooldef = {
times = init_def["times"],
uses = init_def["uses"],
dmg = init_def["damage_groups"],
maxlvl = init_def["maxlevel"]
times = init_def.times,
uses = init_def.uses,
dmg = init_def.damage_groups,
maxlvl = init_def.maxlevel
}
enchanting.register_enchtools(init_def, m, tooldef)
enchanting.register_enchtools(init_def, material, tooldef)
end
end
......@@ -6,7 +6,7 @@ xdecor.box = {
}
xdecor.nodebox = {
regular = { type="regular" },
regular = { type = "regular" },
null = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } }
}
......
local function hive_construct(pos)
local hive = {}
function hive.construct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[8,5;]"..xdecor.fancy_gui..
"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)
end
local function hive_dig(pos, player)
function hive.dig(pos, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("honey") then
return false
end
if not inv:is_empty("honey") then return false end
return true
end
......@@ -35,8 +35,8 @@ xdecor.register("hive", {
"xdecor_hive_front.png",
},
groups = {snappy=3, flammable=1},
on_construct = hive_construct,
can_dig = hive_dig,
on_construct = hive.construct,
can_dig = hive.dig,
on_punch = function(pos, node, puncher, pointed_thing)
local health = puncher:get_hp()
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 flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
if #flowers >= 4 then
inv:add_item("honey", "xdecor:honey")
end
if #flowers >= 4 then inv:add_item("honey", "xdecor:honey") end
end
})
......@@ -243,7 +243,7 @@ local door_types = {"woodglass", "japanese"}
for _, d in pairs(door_types) do
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",
groups = {choppy=3, flammable=2, door=1},
tiles_bottom = {"xdecor_"..d.."_door_b.png", "xdecor_brown.png"},
......
local rope_sbox = {
type = "fixed",
fixed = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
}
local rope = {}
-- Code by Mirko K. (modified by Temperest, Wulfsdad and kilbith) (License: GPL).
minetest.register_on_punchnode(function(pos, oldnode, digger)
if oldnode.name == "xdecor:rope" then
remove_rope(pos, oldnode, digger, "xdecor:rope")
rope.remove(pos, oldnode, digger, "xdecor:rope")
end
end)
local function place_rope(itemstack, placer, pointed_thing)
function rope.place(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local under = pointed_thing.under
local above = pointed_thing.above
......@@ -29,7 +26,7 @@ local function place_rope(itemstack, placer, pointed_thing)
return itemstack
end
function remove_rope(pos, oldnode, digger, rope_name)
function rope.remove(pos, oldnode, digger, rope_name)
local num = 0
local below = {x=pos.x, y=pos.y, z=pos.z}
local digger_inv = digger:get_inventory()
......@@ -50,9 +47,12 @@ xdecor.register("rope", {
walkable = false,
climbable = true,
groups = {dig_immediate=3, flammable=3},
selection_box = rope_sbox,
tiles = {"xdecor_rope.png"},
inventory_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]"..
"list[current_name;tool;5,2;1,1;]"..
"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_player;main;0,3.25;8,4;]")
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 outputcount = outputstack:get_count()
local inputname = inputstack:get_name()
local outputname = outputstack:get_name()
local shape, get = {}, {}
local anz = 0
for _, d in pairs(def) do
local nb, anz = d[1], d[2]
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
shape = "xdecor:"..nb.."_"..string.sub(inputname, 9)
shape = "xdecor:"..nb.."_"..inputname:sub(9)
get = shape.." "..anz
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 == "input" then
if string.find(stackname, "default:") then return count
else return 0 end
if stackname:find("default:") then return count else return 0 end
end
if listname == "hammer" then
if not (stackname == "xdecor:hammer") then return 0 end
......@@ -117,8 +117,7 @@ function worktable.put(pos, listname, index, stack, player)
end
function worktable.move(pos, from_list, from_index, to_list, to_index, count, player)
return 0
end
return 0 end
xdecor.register("worktable", {
description = "Work Table",
......@@ -145,11 +144,11 @@ for n=1, #def do
local function description(m)
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
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}
elseif m == "clay" or m == "snowblock" then
return {snappy=3, not_in_creative_inventory=1}
......@@ -158,7 +157,7 @@ for n=1, #def do
end
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
end
......
......@@ -29,11 +29,8 @@ local function clone_table(table)
local newtable = {}
for idx, item in pairs(table) do
if type(item) == "table" then
newtable[idx] = clone_table(item)
else
newtable[idx] = item
end
if type(item) == "table" then newtable[idx] = clone_table(item)
else newtable[idx] = item end
end
return newtable
......@@ -66,7 +63,7 @@ function xwall.update_one_node(pos, name, digged)
local newnode = xwall.get_candidate[id]
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
minetest.swap_node(pos, {name=newname, param2=newnode[2]})
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
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},
sounds = xdecor.stone,
groups = {cracky=3, stone=1, pane=1},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment