chests can add tools with custom wear levels, code tidy & tweak

This commit is contained in:
tenplus1 2022-08-22 08:17:34 +01:00
parent 27fa7e1223
commit 874806563d
4 changed files with 319 additions and 312 deletions

@ -27,5 +27,6 @@ Changelog:
- 1.2 - Code tidy and fixed wishing well replacements - 1.2 - Code tidy and fixed wishing well replacements
- 1.3 - Add lightning staff as rare drop, tidy code, lightning fire check, slender potion - 1.3 - Add lightning staff as rare drop, tidy code, lightning fire check, slender potion
- 1.4 - Bug fix falling nodes, add worm farm drops - 1.4 - Bug fix falling nodes, add worm farm drops
- 1.5 - Filled chests can now add tools with custom wear levels, code tidy and tweaks
Lucky Blocks: 262 (depending on mods enabled) Lucky Blocks: 266 (depending on mods enabled)

12
api.txt

@ -150,11 +150,12 @@ Place a chest containing random items from default chest items list
{"nod", "default:chest", 0} {"nod", "default:chest", 0}
Place chest as above only add up to 5 roses and a 1/5 chance of mese also Place chest with a 1/5 chance of adding roses, up to 10x dirt and a worn shovel
{"nod", "default:chest", 0, { {"nod", "default:chest", 0, {
{name = "flowers:rose", max = 5}, {name = "default:dirt", max = 10},
{name = "default:mese", max = 1, chance = 5}, {name = "flowers:rose", max = 5, chance = 5},
{name = "default:shovel_wood", max = 1, min_wear = 20000, max_wear = 65535},
}} }}
Place fire at player position Place fire at player position
@ -331,9 +332,10 @@ Custom Function
--------------- ---------------
This allows mod makers to use there own functions when opening lucky blocks and This allows mod makers to use there own functions when opening lucky blocks and
passes the block position and player opening it. passes the block position, the player opening it and a def table with anything
else the function needs.
{"cus", myfunction} {"cus", myfunction, def}
e.g. e.g.

@ -13,17 +13,16 @@ lucky_block:add_schematics({
{"defpinetree", dpath .. "pine_tree_from_sapling.mts", {x = 2, y = 1, z = 2}}, {"defpinetree", dpath .. "pine_tree_from_sapling.mts", {x = 2, y = 1, z = 2}},
{"acaciatree", dpath .. "acacia_tree_from_sapling.mts", {x = 4, y = 1, z = 4}}, {"acaciatree", dpath .. "acacia_tree_from_sapling.mts", {x = 4, y = 1, z = 4}},
{"aspentree", dpath .. "aspen_tree_from_sapling.mts", {x = 2, y = 1, z = 2}}, {"aspentree", dpath .. "aspen_tree_from_sapling.mts", {x = 2, y = 1, z = 2}},
-- {"corals", dpath .. "corals.mts", {x = 2, y = 1, z = 2}},
{"largecactus", dpath .. "large_cactus.mts", {x = 2, y = 1, z = 2}}, {"largecactus", dpath .. "large_cactus.mts", {x = 2, y = 1, z = 2}},
{"defaultbush", dpath .. "bush.mts", {x = 1, y = 1, z = 1}}, {"defaultbush", dpath .. "bush.mts", {x = 1, y = 1, z = 1}},
{"acaciabush", dpath .. "acacia_bush.mts", {x = 1, y = 1, z = 1}}, {"acaciabush", dpath .. "acacia_bush.mts", {x = 1, y = 1, z = 1}},
{"corals", MP .. "/schematics/corals.mts", {x = 2, y = 1, z = 2}}
{"corals", MP .. "/schematics/corals.mts", {x = 2, y = 1, z = 2}},
}) })
-- Default blocks -- Default blocks
lucky_block:add_blocks({ lucky_block:add_blocks({
{"nod", {"default:chest"}, 0},
{"lig"}, {"lig"},
{"fal", {"default:wood", "default:gravel", "default:sand", {"fal", {"default:wood", "default:gravel", "default:sand",
"default:desert_sand", "default:stone", "default:dirt", "default:desert_sand", "default:stone", "default:dirt",
@ -37,7 +36,8 @@ lucky_block:add_blocks({
{name = "bucket:bucket_water", max = 1}, {name = "bucket:bucket_water", max = 1},
{name = "default:wood", max = 3}, {name = "default:wood", max = 3},
{name = "default:pick_diamond", max = 1}, {name = "default:pick_diamond", max = 1},
{name = "default:coal_lump", max = 3} } }, {name = "default:coal_lump", max = 3}
}},
{"sch", "sandtrap", 1, true}, {"sch", "sandtrap", 1, true},
{"sch", "defpinetree", 0, false}, {"sch", "defpinetree", 0, false},
{"sch", "lavatrap", 1, true}, {"sch", "lavatrap", 1, true},
@ -130,7 +130,7 @@ lucky_block:add_blocks({
{name = "default:sandstone", max = 20}, {name = "default:sandstone", max = 20},
{name = "default:gravel", max = 20}, {name = "default:gravel", max = 20},
}}, }},
{"dro", {"default:obsidian"}, 14}, {"dro", {"default:obsidian"}, 14}
}) })
local green = minetest.get_color_escape_sequence("#1eff00") local green = minetest.get_color_escape_sequence("#1eff00")
@ -181,9 +181,11 @@ local function pint(pos, player)
end, player) end, player)
end end
-- pint sized potion item
minetest.register_craftitem("lucky_block:pint_sized_potion", { minetest.register_craftitem("lucky_block:pint_sized_potion", {
description = S("Pint Sized Potion (DRINK ME)"), description = S("Pint Sized Potion (DRINK ME)"),
inventory_image = "lucky_pint_sized_potion.png", inventory_image = "lucky_pint_sized_potion.png",
groups = {vessel = 1},
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
itemstack:take_item() itemstack:take_item()
@ -201,16 +203,16 @@ minetest.register_craftitem("lucky_block:pint_sized_potion", {
pint(pos, user) pint(pos, user)
return itemstack return itemstack
end, end
groups = {vessel = 1},
}) })
-- pint sized potion recipe
minetest.register_craft({ minetest.register_craft({
output = "lucky_block:pint_sized_potion", output = "lucky_block:pint_sized_potion",
recipe = { recipe = {
{"default:bush_sapling", "flowers:tulip", "default:acacia_bush_sapling"}, {"default:bush_sapling", "flowers:tulip", "default:acacia_bush_sapling"},
{"dye:blue", "default:apple", "dye:cyan"}, {"dye:blue", "default:apple", "dye:cyan"},
{"", "vessels:glass_bottle", ""}, {"", "vessels:glass_bottle", ""}
} }
}) })
@ -246,9 +248,11 @@ local function slender(pos, player)
end, player) end, player)
end end
-- slender player potion item
minetest.register_craftitem("lucky_block:slender_player_potion", { minetest.register_craftitem("lucky_block:slender_player_potion", {
description = S("Slender Player Potion (DRINK ME)"), description = S("Slender Player Potion (DRINK ME)"),
inventory_image = "lucky_slender_potion.png", inventory_image = "lucky_slender_potion.png",
groups = {vessel = 1},
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
itemstack:take_item() itemstack:take_item()
@ -266,21 +270,21 @@ minetest.register_craftitem("lucky_block:slender_player_potion", {
slender(pos, user) slender(pos, user)
return itemstack return itemstack
end, end
groups = {vessel = 1},
}) })
-- slender player potion recipe
minetest.register_craft({ minetest.register_craft({
output = "lucky_block:slender_player_potion", output = "lucky_block:slender_player_potion",
recipe = { recipe = {
{"default:bush_sapling", "flowers:rose", "default:pine_bush_sapling"}, {"default:bush_sapling", "flowers:rose", "default:pine_bush_sapling"},
{"dye:red", "default:apple", "dye:orange"}, {"dye:red", "default:apple", "dye:orange"},
{"", "vessels:glass_bottle", ""}, {"", "vessels:glass_bottle", ""}
} }
}) })
-- custom function (drop player inventory and replace with dry shrubs) -- custom function (drop player inventory and replace with items and show msg)
local function bushy(pos, player) local function dropsy(pos, player, def)
local player_inv = player:get_inventory() local player_inv = player:get_inventory()
@ -295,15 +299,14 @@ local function bushy(pos, player)
obj:set_velocity({ obj:set_velocity({
x = math.random(-10, 10) / 9, x = math.random(-10, 10) / 9,
y = 5, y = 5,
z = math.random(-10, 10) / 9, z = math.random(-10, 10) / 9
}) })
end end
player_inv:set_stack("main", i, "default:dry_shrub") player_inv:set_stack("main", i, def.item)
end end
minetest.chat_send_player(player:get_player_name(), minetest.chat_send_player(player:get_player_name(), green .. S(def.msg))
green .. S("Dry shrub takeover!"))
end end
-- lightning staff -- lightning staff
@ -316,6 +319,7 @@ minetest.register_tool("lucky_block:lightning_staff", {
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local pos = user:get_pos() local pos = user:get_pos()
if pointed_thing.type == "object" then if pointed_thing.type == "object" then
pos = pointed_thing.ref:get_pos() pos = pointed_thing.ref:get_pos()
elseif pointed_thing.type == "node" then elseif pointed_thing.type == "node" then
@ -328,8 +332,7 @@ if not pos then return end
local bref = bnod and minetest.registered_items[bnod.name] local bref = bnod and minetest.registered_items[bnod.name]
if bref and bref.buildable_to == true then if bref and bref.buildable_to == true then
local nod = "fire:basic_flame" minetest.set_node(pos, {name = "fire:basic_flame"})
minetest.set_node(pos, {name = nod})
end end
local radius = 4 local radius = 4
@ -356,13 +359,13 @@ if not pos then return end
minetest.after(0.1, function() minetest.after(0.1, function()
objs[n]:punch(tmp_ent, 1.0, { objs[n]:punch(tmp_ent, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy = damage, fire = 1}, damage_groups = {fleshy = damage, fire = 1}
}, pos) }, pos)
end) end)
else else
objs[n]:punch(tmp_ent, 1.0, { objs[n]:punch(tmp_ent, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy = damage, fire = 1}, damage_groups = {fleshy = damage, fire = 1}
}, pos) }, pos)
end end
end end
@ -375,24 +378,21 @@ if not pos then return end
collisiondetection = false, collisiondetection = false,
texture = "lucky_lightning.png", texture = "lucky_lightning.png",
size = 100, size = 100,
glow = 15, glow = 15
}) })
minetest.sound_play("lightning", { minetest.sound_play("lightning", {
pos = pos, pos = pos, gain = 1.0, max_hear_distance = 25}, true)
gain = 1.0,
max_hear_distance = 25
}, true)
itemstack:add_wear(65535 / 50) -- 50 uses itemstack:add_wear(65535 / 50) -- 50 uses
return itemstack return itemstack
end, end
}) })
lucky_block:add_blocks({ lucky_block:add_blocks({
{"cus", pint}, {"cus", pint},
{"cus", bushy}, {"cus", dropsy, {item = "default:dry_shrub", msg = "Dry shrub takeover!"}},
{"cus", punchy}, {"cus", punchy},
{"cus", slender}, {"cus", slender},
{"dro", {"lucky_block:pint_sized_potion"}, 1}, {"dro", {"lucky_block:pint_sized_potion"}, 1},
@ -404,21 +404,24 @@ lucky_block:add_blocks({
{name = "default:pine_bush_stem", max = 10}, {name = "default:pine_bush_stem", max = 10},
{name = "default:grass_1", max = 10}, {name = "default:grass_1", max = 10},
{name = "default:dry_grass_1", max = 10}, {name = "default:dry_grass_1", max = 10},
{name = "lucky_block:lightning_staff", max = 1, chance = 10}}}, {name = "lucky_block:lightning_staff", max = 1, chance = 10}
}}
}) })
-- wool mod -- wool mod
if minetest.get_modpath("wool") then if minetest.get_modpath("wool") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"sch", "sandtrap", 1, true, {{"default:sand", "wool:red"}} }, {"sch", "sandtrap", 1, true, {{"default:sand", "wool:red"}} },
{"dro", {"wool:"}, 10, true}, {"dro", {"wool:"}, 10, true},
{"sch", "sandtrap", 1, true, {{"default:sand", "wool:green"}} }, {"sch", "sandtrap", 1, true, {{"default:sand", "wool:green"}} },
{"dro", {"wool:white"}, 10}, {"dro", {"wool:white"}, 10}
}) })
end end
-- extra doors mod -- extra doors mod
if minetest.get_modpath("extra_doors") then if minetest.get_modpath("extra_doors") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"default:steel_rod"}, 10}, {"dro", {"default:steel_rod"}, 10},
{"dro", {"extra_doors:door_woodpanel1"}, 1}, {"dro", {"extra_doors:door_woodpanel1"}, 1},
@ -439,12 +442,13 @@ if minetest.get_modpath("extra_doors") then
{"dro", {"extra_doors:door_door_dungeon2"}, 1}, {"dro", {"extra_doors:door_door_dungeon2"}, 1},
{"dro", {"extra_doors:door_door_steelpanel1"}, 1}, {"dro", {"extra_doors:door_door_steelpanel1"}, 1},
{"dro", {"extra_doors:door_door_steelglass1"}, 1}, {"dro", {"extra_doors:door_door_steelglass1"}, 1},
{"dro", {"extra_doors:door_door_steelglass2"}, 1}, {"dro", {"extra_doors:door_door_steelglass2"}, 1}
}) })
end end
-- Flowers mod -- Flowers mod
if minetest.get_modpath("flowers") then if minetest.get_modpath("flowers") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"nod", "flowers:rose", 0}, {"nod", "flowers:rose", 0},
{"dro", {"flowers:mushroom_red"}, 5}, {"dro", {"flowers:mushroom_red"}, 5},
@ -460,13 +464,14 @@ if minetest.get_modpath("flowers") then
{name = "flowers:rose", max = 15}, {name = "flowers:rose", max = 15},
{name = "flowers:mushroom_brown", max = 10}, {name = "flowers:mushroom_brown", max = 10},
{name = "flowers:mushroom_red", max = 10}, {name = "flowers:mushroom_red", max = 10},
{name = "flowers:waterlily", max = 10}, {name = "flowers:waterlily", max = 10}
}}, }}
}) })
end end
-- Doors mod -- Doors mod
if minetest.get_modpath("doors") then if minetest.get_modpath("doors") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"doors:door_wood"}}, {"dro", {"doors:door_wood"}},
{"dro", {"doors:door_steel"}}, {"dro", {"doors:door_steel"}},
@ -478,7 +483,7 @@ if minetest.get_modpath("doors") then
{"dro", {"doors:gate_aspen_wood_closed"}}, {"dro", {"doors:gate_aspen_wood_closed"}},
{"dro", {"doors:gate_wood_closed"}}, {"dro", {"doors:gate_wood_closed"}},
{"dro", {"doors:gate_pine_wood_closed"}}, {"dro", {"doors:gate_pine_wood_closed"}},
{"dro", {"doors:gate_junglewood_closed"}}, {"dro", {"doors:gate_junglewood_closed"}}
}) })
end end
@ -486,20 +491,24 @@ end
if minetest.get_modpath("screwdriver") then if minetest.get_modpath("screwdriver") then
if screwdriver and screwdriver.handler then if screwdriver and screwdriver.handler then
minetest.register_tool(":screwdriver:screwdriver_magenta", { minetest.register_tool(":screwdriver:screwdriver_magenta", {
description = S("Super Mega Magenta Ultra Screwdriver 2500\n(left-click to rotate face, right-click to rotates axis)"), description = S("Super Mega Magenta Ultra Screwdriver 2500"
.. "\n(left-click to rotate face, right-click to rotates axis)"),
inventory_image = "screwdriver.png^[colorize:#ff009970", inventory_image = "screwdriver.png^[colorize:#ff009970",
groups = {not_in_creative_inventory = 1}, groups = {not_in_creative_inventory = 1},
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, 2500) screwdriver.handler(itemstack, user, pointed_thing,
screwdriver.ROTATE_FACE, 2500)
return itemstack return itemstack
end, end,
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS, 2500) screwdriver.handler(itemstack, user, pointed_thing,
screwdriver.ROTATE_AXIS, 2500)
return itemstack return itemstack
end, end
}) })
end end
@ -511,28 +520,31 @@ end
-- Vessels mod -- Vessels mod
if minetest.get_modpath("vessels") then if minetest.get_modpath("vessels") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"vessels:shelf", "vessels:drinking_glass", "vessels:glass_bottle", {"dro", {"vessels:shelf", "vessels:drinking_glass", "vessels:glass_bottle",
"vessels:steel_bottle", "vessels:glass_fragments"}, 5}, "vessels:steel_bottle", "vessels:glass_fragments"}, 5},
{"nod", "vessels:drinking_glass", 0}, {"nod", "vessels:drinking_glass", 0},
{"nod", "vessels:glass_bottle", 0}, {"nod", "vessels:glass_bottle", 0},
{"nod", "vessels:steel_bottle", 0}, {"nod", "vessels:steel_bottle", 0}
}) })
end end
-- Farming mod (default) -- Farming mod (default)
if minetest.get_modpath("farming") then if minetest.get_modpath("farming") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"farming:bread"}, 5}, {"dro", {"farming:bread"}, 5},
{"sch", "instafarm", 0, true}, {"sch", "instafarm", 0, true},
{"nod", "default:water_source", 1}, {"nod", "default:water_source", 1},
{"nod", "farming:straw", 0}, {"nod", "farming:straw", 0},
{"dro", {"farming:straw"}, 8}, {"dro", {"farming:straw"}, 8}
}) })
end end
-- Home Decor mod -- Home Decor mod
if minetest.get_modpath("homedecor") then if minetest.get_modpath("homedecor") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"nod", "homedecor:toilet", 0}, {"nod", "homedecor:toilet", 0},
{"nod", "homedecor:table", 0}, {"nod", "homedecor:table", 0},
@ -552,41 +564,46 @@ if minetest.get_modpath("homedecor") then
{"dro", {"homedecor:shutter_violet"}, 5}, {"dro", {"homedecor:shutter_violet"}, 5},
{"dro", {"homedecor:table_legs_wrought_iron", "homedecor:utility_table_legs"}, 5}, {"dro", {"homedecor:table_legs_wrought_iron", "homedecor:utility_table_legs"}, 5},
{"dro", {"homedecor:pole_wrought_iron"}, 10}, {"dro", {"homedecor:pole_wrought_iron"}, 10},
{"dro", {"homedecor:fence_picket_white"}, 20}, {"dro", {"homedecor:fence_picket_white"}, 20}
}) })
end end
-- Boats mod -- Boats mod
if minetest.get_modpath("boats") then if minetest.get_modpath("boats") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"boats:boat"}}, {"dro", {"boats:boat"}}
}) })
end end
-- Beds mod -- Beds mod
if minetest.get_modpath("beds") then if minetest.get_modpath("beds") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"beds:bed"}}, {"dro", {"beds:bed"}},
{"dro", {"beds:fancy_bed"}}, {"dro", {"beds:fancy_bed"}}
}) })
end end
-- Walls mod -- Walls mod
if minetest.get_modpath("walls") then if minetest.get_modpath("walls") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"walls:cobble"}, 10}, {"dro", {"walls:cobble"}, 10},
{"dro", {"walls:mossycobble"}, 10}, {"dro", {"walls:mossycobble"}, 10},
{"dro", {"walls:desertcobble"}, 10}, {"dro", {"walls:desertcobble"}, 10}
}) })
end end
-- Carts mod -- Carts mod
if minetest.get_modpath("carts") if minetest.get_modpath("carts")
or minetest.get_modpath("boost_cart") then or minetest.get_modpath("boost_cart") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"carts:cart"}}, {"dro", {"carts:cart"}},
{"dro", {"default:rail"}, 10}, {"dro", {"default:rail"}, 10},
{"dro", {"carts:powerrail"}, 5}, {"dro", {"carts:powerrail"}, 5},
{"dro", {"carts:brakerail"}, 5}
}) })
end end
@ -622,6 +639,7 @@ end
-- 3D Armor's Shields mod -- 3D Armor's Shields mod
if minetest.get_modpath("shields") then if minetest.get_modpath("shields") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"shields:shield_wood"}}, {"dro", {"shields:shield_wood"}},
{"dro", {"shields:shield_steel"}}, {"dro", {"shields:shield_steel"}},
@ -634,6 +652,7 @@ end
-- Fire mod -- Fire mod
if minetest.get_modpath("fire") then if minetest.get_modpath("fire") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"fire:flint_and_steel"}}, {"dro", {"fire:flint_and_steel"}},
{"dro", {"default:flint"}, 5}, {"dro", {"default:flint"}, 5},
@ -645,9 +664,11 @@ end
-- Caverealms -- Caverealms
if minetest.get_modpath("caverealms") then if minetest.get_modpath("caverealms") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"sch", "sandtrap", 1, true, {{"default:sand", "caverealms:coal_dust"}} }, {"sch", "sandtrap", 1, true, {{"default:sand", "caverealms:coal_dust"}} },
{"sch", "obsidiantrap", 1, true, {{"default:obsidian", "caverealms:glow_obsidian_brick_2"}} }, {"sch", "obsidiantrap", 1, true, {{"default:obsidian",
"caverealms:glow_obsidian_brick_2"}} },
{"flo", 5, {"caverealms:stone_with_moss"}, 2}, {"flo", 5, {"caverealms:stone_with_moss"}, 2},
{"flo", 5, {"caverealms:stone_with_lichen"}, 2}, {"flo", 5, {"caverealms:stone_with_lichen"}, 2},
{"flo", 5, {"caverealms:stone_with_algae"}, 2}, {"flo", 5, {"caverealms:stone_with_algae"}, 2},
@ -656,16 +677,19 @@ end
-- TNT mod -- TNT mod
if minetest.get_modpath("tnt") then if minetest.get_modpath("tnt") then
local p = "tnt:tnt_burning" local p = "tnt:tnt_burning"
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"tnt:gunpowder"}, 5}, {"dro", {"tnt:gunpowder"}, 5},
{"fal", {p, p, p, p, p}, 1, true, 4}, {"fal", {p, p, p, p, p}, 1, true, 4},
{"nod", "tnt:tnt_burning", 0}, {"nod", "tnt:tnt_burning", 0}
}) })
end end
-- More Ore's mod -- More Ore's mod
if minetest.get_modpath("moreores") then if minetest.get_modpath("moreores") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"nod", "moreores:tin_block", 0}, {"nod", "moreores:tin_block", 0},
{"nod", "moreores:silver_block", 0}, {"nod", "moreores:silver_block", 0},
@ -690,29 +714,31 @@ lucky_block:add_blocks({
{name = "default:iron_lump", max = 10}, {name = "default:iron_lump", max = 10},
{name = "default:tin_lump", max = 10}, {name = "default:tin_lump", max = 10},
{name = "default:coal_lump", max = 10}, {name = "default:coal_lump", max = 10},
{name = "default:clay_lump", max = 10}, {name = "default:clay_lump", max = 10}
}}, }}
}) })
if minetest.get_modpath("3d_armor") then if minetest.get_modpath("3d_armor") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"3d_armor:helmet_mithril"}}, {"dro", {"3d_armor:helmet_mithril"}},
{"dro", {"3d_armor:chestplate_mithril"}}, {"dro", {"3d_armor:chestplate_mithril"}},
{"dro", {"3d_armor:leggings_mithril"}}, {"dro", {"3d_armor:leggings_mithril"}},
{"dro", {"3d_armor:boots_mithril"}}, {"dro", {"3d_armor:boots_mithril"}}
}) })
end end
if minetest.get_modpath("shields") then if minetest.get_modpath("shields") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"shields:shield_mithril"}}, {"dro", {"shields:shield_mithril"}}
}) })
end end
end -- END moreores end -- END moreores
-- Moreblocks mod -- Moreblocks mod
if minetest.get_modpath("moreblocks") then if minetest.get_modpath("moreblocks") then
local p = "moreblocks:" local p = "moreblocks:"
local lav = {name = "default:lava_source"} local lav = {name = "default:lava_source"}
local air = {name = "air"} local air = {name = "air"}
@ -726,12 +752,12 @@ local trapstone_trap = {
lav, lav, lav, air, air, air, air, air, air, lav, lav, lav, air, air, air, air, air, air,
air, air, air, air, trg, air, trs, air, trs, air, air, air, air, trg, air, trs, air, trs,
lav, lav, lav, air, air, air, air, air, air, lav, lav, lav, air, air, air, air, air, air,
air, air, air, air, air, air, trs, trs, trs, air, air, air, air, air, air, trs, trs, trs
}, }
} }
lucky_block:add_schematics({ lucky_block:add_schematics({
{"trapstonetrap", trapstone_trap, {x = 1, y = 6, z = 1}}, {"trapstonetrap", trapstone_trap, {x = 1, y = 6, z = 1}}
}) })
lucky_block:add_blocks({ lucky_block:add_blocks({
@ -774,7 +800,8 @@ lucky_block:add_blocks({
{"dro", {p.."all_faces_aspen_tree"}, 10}, {"dro", {p.."all_faces_aspen_tree"}, 10},
{"flo", 3, {p.."all_faces_acacia_tree"}, 1}, {"flo", 3, {p.."all_faces_acacia_tree"}, 1},
{"dro", {p.."plankstone"}, 10}, {"dro", {p.."plankstone"}, 10},
{"fal", {p.."all_faces_tree", p.."all_faces_tree", p.."all_faces_tree", p.."all_faces_tree", p.."all_faces_tree"}, 0}, {"fal", {p.."all_faces_tree", p.."all_faces_tree", p.."all_faces_tree",
p.."all_faces_tree", p.."all_faces_tree"}, 0},
{"dro", {p.."glow_glass"}, 10}, {"dro", {p.."glow_glass"}, 10},
{"dro", {p.."super_glow_glass"}, 10}, {"dro", {p.."super_glow_glass"}, 10},
{"dro", {p.."clean_glass"}, 10}, {"dro", {p.."clean_glass"}, 10},
@ -783,24 +810,27 @@ lucky_block:add_blocks({
{name = p.."sweeper", max = 1}, {name = p.."sweeper", max = 1},
{name = p.."circular_saw", max = 1}, {name = p.."circular_saw", max = 1},
{name = p.."grey_bricks", max = 10}, {name = p.."grey_bricks", max = 10},
{name = p.."tar", max = 3}}}, {name = p.."tar", max = 3}
{"flo", 3, {"moreblocks:copperpatina"}, 1}, }},
{"flo", 3, {"moreblocks:copperpatina"}, 1}
}) })
end end
-- Bags mod -- Bags mod
if minetest.get_modpath("bags") or minetest.get_modpath("sfinv_bags") then if minetest.get_modpath("bags") or minetest.get_modpath("sfinv_bags") then
minetest.register_craftitem(":bags:spar", { minetest.register_craftitem(":bags:spar", {
description = "Spar Bag", description = "Spar Bag",
inventory_image = "bags_spar.png", inventory_image = "bags_spar.png",
groups = {bagslots = 2, flammable = 2}, groups = {bagslots = 2, flammable = 2}
}) })
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"bags:spar"}}, {"dro", {"bags:spar"}},
{"dro", {"bags:small"}}, {"dro", {"bags:small"}},
{"dro", {"bags:medium"}}, {"dro", {"bags:medium"}},
{"dro", {"bags:large"}}, {"dro", {"bags:large"}},
{"dro", {"bags:trolley"}}, {"dro", {"bags:trolley"}}
}) })
end end
@ -829,8 +859,7 @@ if minetest.get_modpath("nether") then
{name = p.."rack", max = 5}, {name = p.."rack", max = 5},
{name = p.."axe_nether", max = 1}, {name = p.."axe_nether", max = 1},
{name = p.."sword_nether", max = 1}, {name = p.."sword_nether", max = 1},
{name = p.."nether_lump", max = 3}, {name = p.."nether_lump", max = 3}
}}, }},
{"exp", 2}, {"exp", 2},
{"sch", "wishingwell", 0, true, { {"sch", "wishingwell", 0, true, {
@ -867,12 +896,14 @@ if minetest.get_modpath("nether") then
end end
if minetest.get_modpath("shields") then if minetest.get_modpath("shields") then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"shields:shield_nether"}} {"dro", {"shields:shield_nether"}}
}) })
end end
if minetest.get_modpath("xpanes") and minetest.registered_nodes["nether:geode"] then if minetest.get_modpath("xpanes") and minetest.registered_nodes["nether:geode"] then
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"xpanes:nether_crystal_pane_flat"}, 5}, {"dro", {"xpanes:nether_crystal_pane_flat"}, 5},
{"nod", "nether_geode", 0}, {"nod", "nether_geode", 0},
@ -884,33 +915,6 @@ end
-- worm farm mod -- worm farm mod
if minetest.get_modpath("worm_farm") then if minetest.get_modpath("worm_farm") then
-- custom function (drop player inventory and replace with dry shrubs)
local function wormy(pos, player)
local player_inv = player:get_inventory()
pos = player:get_pos() or pos
for i = 1, player_inv:get_size("main") do
local obj = minetest.add_item(pos, player_inv:get_stack("main", i))
if obj then
obj:set_velocity({
x = math.random(-10, 10) / 9,
y = 5,
z = math.random(-10, 10) / 9,
})
end
player_inv:set_stack("main", i, "ethereal:worm")
end
minetest.chat_send_player(player:get_player_name(),
green .. S("Worm Attack!"))
end
lucky_block:add_blocks({ lucky_block:add_blocks({
{"nod", "default:chest", 0, { {"nod", "default:chest", 0, {
{name = "ethereal:worm", max = 5}, {name = "ethereal:worm", max = 5},
@ -918,7 +922,7 @@ if minetest.get_modpath("worm_farm") then
{name = "ethereal:worm", max = 5}, {name = "ethereal:worm", max = 5},
{name = "worm_farm:worm_farm", max = 1} {name = "worm_farm:worm_farm", max = 1}
}}, }},
{"cus", wormy}, {"cus", dropsy, {item = "ethereal:worm", msg = "Worm Attack!"}},
{"dro", {"worm_farm:worm_farm"}, 1} {"dro", {"worm_farm:worm_farm"}, 1}
}) })
end end
@ -960,11 +964,11 @@ minetest.register_node("lucky_block:void_mirror", {
tiles = {"default_obsidian_glass.png^[brighten"}, tiles = {"default_obsidian_glass.png^[brighten"},
use_texture_alpha = "clip", use_texture_alpha = "clip",
groups = {snappy = 3, not_in_creative_inventory = 1}, groups = {snappy = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults()
}) })
lucky_block:add_blocks({ lucky_block:add_blocks({
{"dro", {"lucky_block:void_mirror"}}, {"dro", {"lucky_block:void_mirror"}}
}) })
-- Troll -- Troll
@ -979,7 +983,7 @@ local function fake_items(pos, player, def)
pos = { pos = {
x = pos.x + math.random(-20, 20) / 10, x = pos.x + math.random(-20, 20) / 10,
y = pos.y, y = pos.y,
z = pos.z + math.random(-20, 20) / 10, z = pos.z + math.random(-20, 20) / 10
}, },
velocity = {x = 0, y = 2, z = 0}, velocity = {x = 0, y = 2, z = 0},
acceleration = {x = 0, y = -10, z = 0}, acceleration = {x = 0, y = -10, z = 0},
@ -989,9 +993,8 @@ local function fake_items(pos, player, def)
glow = 2, glow = 2,
size = 5, size = 5,
collisiondetection = true, collisiondetection = true,
vertical = true, vertical = true
}) })
end end
minetest.chat_send_player(player:get_player_name(), minetest.chat_send_player(player:get_player_name(),
@ -1001,7 +1004,7 @@ end
lucky_block:add_blocks({ lucky_block:add_blocks({
{"cus", fake_items, {tex = "default_diamond.png", txt = "diamonds"} }, {"cus", fake_items, {tex = "default_diamond.png", txt = "diamonds"} },
{"cus", fake_items, {tex = "default_gold_ingot.png", txt = "ingots"} }, {"cus", fake_items, {tex = "default_gold_ingot.png", txt = "ingots"} },
{"cus", fake_items, {tex = "default_mese_crystal.png", txt = "crystals"} }, {"cus", fake_items, {tex = "default_mese_crystal.png", txt = "crystals"} }
}) })
-- Void Pick -- Void Pick
@ -1056,6 +1059,6 @@ lucky_block:add_blocks({
{name = "default:stone_with_copper", max = 5}, {name = "default:stone_with_copper", max = 5},
{name = "default:stone_with_mese", max = 5}, {name = "default:stone_with_mese", max = 5},
{name = "default:stone_with_gold", max = 5}, {name = "default:stone_with_gold", max = 5},
{name = "default:stone_with_diamond", max = 5}, {name = "default:stone_with_diamond", max = 5}
}} }}
}) })

@ -58,7 +58,7 @@ local chest_stuff = {
{name = "default:steel_ingot", max = 2}, {name = "default:steel_ingot", max = 2},
{name = "default:gold_ingot", max = 2, chance = 2}, {name = "default:gold_ingot", max = 2, chance = 2},
{name = "default:diamond", max = 1, chance = 3}, {name = "default:diamond", max = 1, chance = 3},
{name = "default:pick_steel", max = 1, chance = 2}, {name = "default:pick_steel", max = 1, chance = 2, min_wear = 20000, max_wear = 65536},
{name = "default:mese_crystal_fragment", max = 3, chance = 3}, {name = "default:mese_crystal_fragment", max = 3, chance = 3},
} }
@ -159,34 +159,35 @@ local function entity_physics(pos, radius)
end end
-- fill chest with random items from list -- function to fill chest at position
local function fill_chest(pos, items) local function fill_chest(pos, items)
local stacks = items or {} local stacks = items or chest_stuff
local inv = minetest.get_meta(pos):get_inventory() local meta = minetest.get_meta(pos)
local inv = meta and meta:get_inventory()
local size = inv and inv:get_size("main")
local stack
inv:set_size("main", 8 * 4) if not inv then return end
for i = 0, 2, 1 do -- loop through inventory
for _, def in ipairs(stacks) do
local stuff = chest_stuff[math.random(1, #chest_stuff)] if math.random((def.chance or 1)) == 1 then
table.insert(stacks, {name = stuff.name, max = stuff.max}) -- only add if item existd
if minetest.registered_items[def.name] then
stack = ItemStack(def.name .. " " .. math.random((def.max or 1)))
-- if wear levels found choose random wear between both values
if def.max_wear and def.min_wear then
stack:set_wear(65535 - (math.random(def.max_wear, def.min_wear)))
end end
for s = 1, #stacks do -- set stack in random position
inv:set_stack("main", math.random(size), stack)
if not inv:contains_item("main", stacks[s]) then
if not stacks[s].chance
or math.random(1, stacks[s].chance) == 1 then
if minetest.registered_items[stacks[s].name] then
inv:set_stack("main", math.random(32), {
name = stacks[s].name,
count = math.random(stacks[s].max)
})
end
end end
end end
end end