mirror of
https://notabug.org/TenPlus1/lucky_block.git
synced 2024-12-05 03:23:46 +01:00
add lightning staff drop, fire placement check, corals.mts, chest chance
This commit is contained in:
parent
2fa8a04d00
commit
af5fc79aec
@ -25,5 +25,6 @@ Changelog:
|
||||
- 1.0 - Added ability for custom lucky blocks to use their own block list
|
||||
- 1.1 - Spawning mobs can now select randomly from a table or single string
|
||||
- 1.2 - Code tidy and fixed wishing well replacements
|
||||
- 1.3 - Add lightning staff as rare drop, tidy code, lightning fire check
|
||||
|
||||
Lucky Blocks: 259 (depending on mods enabled)
|
||||
Lucky Blocks: 260 (depending on mods enabled)
|
||||
|
9
api.txt
9
api.txt
@ -57,7 +57,7 @@ e.g.
|
||||
lucky_block:add_chest_items({
|
||||
{name = "default:apple", max = 3},
|
||||
{name = "default:steel_ingot", max = 2},
|
||||
{name = "default:pick_steel", max = 1}
|
||||
{name = "default:pick_diamond", max = 1, chance = 5},
|
||||
})
|
||||
|
||||
|
||||
@ -150,9 +150,12 @@ Place a chest containing random items from default chest items list
|
||||
|
||||
{"nod", "default:chest", 0}
|
||||
|
||||
Place chest as above only add up to 5x roses as well
|
||||
Place chest as above only add up to 5 roses and a 1/5 chance of mese also
|
||||
|
||||
{"nod", "default:chest", 0, { {name = "flowers:rose, max = 4} }}
|
||||
{"nod", "default:chest", 0, {
|
||||
{name = "flowers:rose", max = 5},
|
||||
{name = "default:mese", max = 1, chance = 5},
|
||||
}}
|
||||
|
||||
Place fire at player position
|
||||
|
||||
|
79
blocks.lua
79
blocks.lua
@ -227,11 +227,90 @@ local function bushy(pos, player)
|
||||
green .. S("Dry shrub takeover!"))
|
||||
end
|
||||
|
||||
-- lightning staff
|
||||
minetest.register_tool("lucky_block:lightning_staff", {
|
||||
description = S("Lightning Staff"),
|
||||
inventory_image = "lucky_lightning_staff.png",
|
||||
range = 10,
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
|
||||
local pos = user:get_pos()
|
||||
if pointed_thing.type == "object" then
|
||||
pos = pointed_thing.ref:get_pos()
|
||||
elseif pointed_thing.type == "node" then
|
||||
pos = pointed_thing.above
|
||||
end
|
||||
|
||||
local bnod = minetest.get_node_or_nil(pos)
|
||||
local bref = bnod and minetest.registered_items[bnod.name]
|
||||
|
||||
if bref and bref.buildable_to == true then
|
||||
local nod = "fire:basic_flame"
|
||||
minetest.set_node(pos, {name = nod})
|
||||
end
|
||||
|
||||
local radius = 4
|
||||
local objs = minetest.get_objects_inside_radius(pos, radius)
|
||||
local obj_pos, dist
|
||||
|
||||
-- add temp entity to cause damage
|
||||
local tmp_ent = minetest.add_entity(pos, "lucky_block:temp")
|
||||
|
||||
for n = 1, #objs do
|
||||
|
||||
obj_pos = objs[n]:get_pos()
|
||||
|
||||
dist = vector.distance(pos, obj_pos)
|
||||
|
||||
if dist < 1 then dist = 1 end
|
||||
|
||||
local damage = math.floor((4 / dist) * radius)
|
||||
local ent = objs[n]:get_luaentity()
|
||||
|
||||
objs[n]:punch(tmp_ent, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = damage},
|
||||
}, pos)
|
||||
end
|
||||
|
||||
minetest.add_particle({
|
||||
pos = pos,
|
||||
velocity = {x = 0, y = 0, z = 0},
|
||||
acceleration = {x = 0, y = 0, z = 0},
|
||||
expirationtime = 1.0,
|
||||
collisiondetection = false,
|
||||
texture = "lucky_lightning.png",
|
||||
size = math.random(100, 150),
|
||||
glow = 15,
|
||||
})
|
||||
|
||||
minetest.sound_play("lightning", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 25
|
||||
})
|
||||
|
||||
itemstack:add_wear(65535 / 100) -- 100 uses
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
lucky_block:add_blocks({
|
||||
{"cus", pint},
|
||||
{"cus", bushy},
|
||||
{"cus", punchy},
|
||||
{"dro", {"lucky_block:pint_sized_potion"}, 1},
|
||||
{"nod", "default:chest", 0, {
|
||||
{name = "default:stick", max = 10},
|
||||
{name = "default:acacia_bush_stem", max = 10},
|
||||
{name = "default:bush_stem", max = 10},
|
||||
{name = "default:pine_bush_stem", max = 10},
|
||||
{name = "default:grass_1", max = 10},
|
||||
{name = "default:dry_grass_1", max = 10},
|
||||
{name = "lucky_block:lightning_staff", max = 1, chance = 10}}},
|
||||
})
|
||||
|
||||
-- wool mod
|
||||
|
16
init.lua
16
init.lua
@ -55,9 +55,10 @@ local all_colours = {
|
||||
local chest_stuff = {
|
||||
{name = "default:apple", max = 3},
|
||||
{name = "default:steel_ingot", max = 2},
|
||||
{name = "default:gold_ingot", max = 2},
|
||||
{name = "default:diamond", max = 1},
|
||||
{name = "default:pick_steel", max = 1}
|
||||
{name = "default:gold_ingot", max = 2, chance = 2},
|
||||
{name = "default:diamond", max = 1, chance = 2},
|
||||
{name = "default:pick_steel", max = 1, chance = 2},
|
||||
{name = "default:mese_fragment", max = 3, chance = 3},
|
||||
}
|
||||
|
||||
|
||||
@ -175,6 +176,9 @@ local function fill_chest(pos, items)
|
||||
|
||||
if not inv:contains_item("main", stacks[s]) then
|
||||
|
||||
if not stacks[s].chance
|
||||
or math.random(1, stacks[s].chance) == 1 then
|
||||
|
||||
inv:set_stack("main", math.random(1, 32), {
|
||||
name = stacks[s].name,
|
||||
count = math.random(1, stacks[s].max)
|
||||
@ -182,6 +186,7 @@ local function fill_chest(pos, items)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- explosion with protection check
|
||||
@ -425,7 +430,10 @@ local lb_lightning = function(pos, digger, def)
|
||||
|
||||
pos = digger:get_pos()
|
||||
|
||||
if nod then
|
||||
local bnod = minetest.get_node_or_nil(pos)
|
||||
local bref = bnod and minetest.registered_items[bnod.name]
|
||||
|
||||
if bref and bref.buildable_to then
|
||||
minetest.set_node(pos, {name = nod})
|
||||
end
|
||||
|
||||
|
BIN
schematics/corals.mts
Normal file
BIN
schematics/corals.mts
Normal file
Binary file not shown.
BIN
textures/lucky_lightning_staff.png
Normal file
BIN
textures/lucky_lightning_staff.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 B |
Loading…
Reference in New Issue
Block a user