mirror of
https://notabug.org/TenPlus1/lucky_block.git
synced 2024-10-04 03:33:05 +02:00
tweaked code for drops,schems replacements, added blocks
This commit is contained in:
parent
ad970aa667
commit
c14129c7a9
@ -21,5 +21,6 @@ Changelog:
|
||||
- 0.6 - Use TNT mod for explosions and if not active do entity damage only
|
||||
- 0.7 - Added new floor feature and moreblocks support
|
||||
- 0.8 - Added wishing well with random block drops
|
||||
- 0.9 - Tweak item drops, add replacements to schematics, tidy wishing well code
|
||||
|
||||
Lucky Blocks: 211 (depending on mods enabled)
|
||||
Lucky Blocks: 225 (depending on mods enabled)
|
||||
|
8
api.txt
8
api.txt
@ -137,7 +137,7 @@ random colours can be used also.
|
||||
|
||||
e.g.
|
||||
|
||||
Drop 5x torches
|
||||
Drop 5x torches as itemstack
|
||||
{"dro", {"default:torch"}, 5}
|
||||
|
||||
Drop 10x randomly coloured wool (colour name added to end of item string)
|
||||
@ -153,7 +153,7 @@ Place Schematic
|
||||
This command lets you place a pre-added schematic file or definition in place
|
||||
of the lucky block or at the player position.
|
||||
|
||||
{"sch", "schematic name", position, force placement}
|
||||
{"sch", "schematic name", position, force placement, replacements}
|
||||
|
||||
e.g.
|
||||
|
||||
@ -163,6 +163,9 @@ Place lucky platform at player position and force placement
|
||||
Place apple tree where lucky block use to be
|
||||
{"sch", "appletree", 0, false}
|
||||
|
||||
Place apple tree where lucky block use to be and change wood into stone
|
||||
{"sch", "appletree", 0, false, {{"default:wood", "default:stone"}} }
|
||||
|
||||
|
||||
Spawn Entity or Mob
|
||||
-------------------
|
||||
@ -288,6 +291,7 @@ Have a woolen floor at 5 width with offset of 2 to keep it centred
|
||||
|
||||
{"flo", 5, {"wool:red", "wool:blue", "wool:white", "wool:orange"}, 2}
|
||||
|
||||
|
||||
Custom Function
|
||||
---------------
|
||||
|
||||
|
56
blocks.lua
56
blocks.lua
@ -46,6 +46,7 @@ lucky_block:add_blocks({
|
||||
{"dro", {"dye:"}, 10, true},
|
||||
{"dro", {"default:sword_steel"}},
|
||||
{"sch", "jungletree", 0, false},
|
||||
{"sch", "sandtrap", 1, true, {{"default:sand", "default:silver_sand"}} },
|
||||
{"dro", {"default:pick_steel"}},
|
||||
{"dro", {"default:shovel_steel"}},
|
||||
{"dro", {"default:coal_lump"}, 3},
|
||||
@ -61,6 +62,7 @@ lucky_block:add_blocks({
|
||||
{"sch", "aspentree", 0, false},
|
||||
{"dro", {"default:shovel_bronze"}},
|
||||
{"nod", "default:gravel", 0},
|
||||
{"sch", "sandtrap", 1, true, {{"default:sand", "default:gravel"}} },
|
||||
{"sch", "largecactus", 0, false},
|
||||
{"dro", {"default:axe_bronze"}},
|
||||
{"dro", {"default:bookshelf", "default:book", "default:paper"}, 5},
|
||||
@ -70,6 +72,7 @@ lucky_block:add_blocks({
|
||||
{"dro", {"default:fence_junglewood"}, 10},
|
||||
{"dro", {"default:fence_pine_wood"}, 10},
|
||||
{"sch", "obsidiantrap", 1, true},
|
||||
{"sch", "sandtrap", 1, true, {{"default:sand", "default:desert_sand"}} },
|
||||
})
|
||||
|
||||
-- default coral blocks
|
||||
@ -282,12 +285,24 @@ lucky_block:add_blocks({
|
||||
})
|
||||
end
|
||||
|
||||
-- Caverealms
|
||||
if minetest.get_modpath("caverealms") then
|
||||
lucky_block:add_blocks({
|
||||
{"sch", "sandtrap", 1, true, {{"default:sand", "caverealms:coal_dust"}} },
|
||||
{"sch", "obsidiantrap", 1, true, {{"default:obsidian", "caverealms:glow_obsidian_brick_2"}} },
|
||||
{"flo", 5, {"caverealms:stone_with_moss"}, 2},
|
||||
{"flo", 5, {"caverealms:stone_with_lichen"}, 2},
|
||||
{"flo", 5, {"caverealms:stone_with_algae"}, 2},
|
||||
})
|
||||
end
|
||||
|
||||
-- TNT mod
|
||||
if minetest.get_modpath("tnt") then
|
||||
local p = "tnt:tnt_burning"
|
||||
lucky_block:add_blocks({
|
||||
{"dro", {"tnt:gunpowder"}, 5, true},
|
||||
{"dro", {"tnt:gunpowder"}, 5},
|
||||
{"fal", {p, p, p, p, p}, 1, true, 4},
|
||||
{"nod", "tnt:tnt_burning", 0},
|
||||
})
|
||||
end
|
||||
|
||||
@ -353,13 +368,9 @@ lucky_block:add_schematics({
|
||||
|
||||
lucky_block:add_blocks({
|
||||
{"dro", {p.."wood_tile"}, 10},
|
||||
{"dro", {p.."wood_tile_flipped"}, 10},
|
||||
{"dro", {p.."wood_tile_center"}, 10},
|
||||
{"dro", {p.."wood_tile_full"}, 10},
|
||||
{"dro", {p.."wood_tile_up"}, 10},
|
||||
{"dro", {p.."wood_tile_down"}, 10},
|
||||
{"dro", {p.."wood_tile_left"}, 10},
|
||||
{"dro", {p.."wood_tile_right"}, 10},
|
||||
{"dro", {p.."wood_tile_offset"}, 10},
|
||||
{"dro", {p.."circle_stone_bricks"}, 20},
|
||||
{"dro", {p.."grey_bricks"}, 20},
|
||||
{"dro", {p.."stone_tile"}, 10},
|
||||
@ -379,12 +390,21 @@ lucky_block:add_blocks({
|
||||
{"dro", {p.."iron_checker"}, 10},
|
||||
{"dro", {p.."iron_stone_bricks"}, 10},
|
||||
{"dro", {p.."iron_glass"}, 10},
|
||||
{"dro", {p.."trap_obsidian"}, 10},
|
||||
{"dro", {p.."trap_sandstone"}, 10},
|
||||
{"dro", {p.."trap_desert_stone"}, 10},
|
||||
{"dro", {p.."trap_stone"}, 10},
|
||||
{"dro", {p.."trap_glass"}, 10},
|
||||
{"dro", {p.."trap_glow_glass"}, 10},
|
||||
{"dro", {p.."trap_obsidian_glass"}, 10},
|
||||
{"lig"},
|
||||
{"sch", "trapstonetrap", 0, true},
|
||||
{"dro", {p.."all_faces_tree"}, 10},
|
||||
{"dro", {p.."all_faces_jungle_tree"}, 10},
|
||||
{"dro", {p.."all_faces_pine_tree"}, 10},
|
||||
{"dro", {p.."all_faces_acacia_tree"}, 10},
|
||||
{"dro", {p.."all_faces_aspen_tree"}, 10},
|
||||
{"flo", 3, {p.."all_faces_acacia_tree"}, 1},
|
||||
{"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},
|
||||
{"dro", {p.."glow_glass"}, 10},
|
||||
@ -420,6 +440,30 @@ lucky_block:add_blocks({
|
||||
})
|
||||
end
|
||||
|
||||
-- Additional Wishing Well Styles
|
||||
lucky_block:add_blocks({
|
||||
{"sch", "wishingwell", 0, true, {
|
||||
{"default:stonebrick", "default:silver_sandstone_brick"},
|
||||
{"stairs:slab_stonebrick", "stairs:slab_silver_sandstone_brick"},
|
||||
{"default:fence_wood", "default:fence_aspen_wood"}
|
||||
} },
|
||||
{"sch", "wishingwell", 0, true, {
|
||||
{"default:stonebrick", "default:sandstonebrick"},
|
||||
{"stairs:slab_stonebrick", "stairs:slab_sandstonebrick"},
|
||||
{"default:fence_wood", "default:fence_junglewood"}
|
||||
} },
|
||||
{"sch", "wishingwell", 0, true, {
|
||||
{"default:stonebrick", "default:desert_stonebrick"},
|
||||
{"stairs:slab_stonebrick", "stairs:slab_desert_stonebrick"},
|
||||
{"default:fence_wood", "default:fence_acacia_wood"}
|
||||
} },
|
||||
{"sch", "wishingwell", 0, true, {
|
||||
{"default:stonebrick", "default:desert_sandstone_brick"},
|
||||
{"stairs:slab_stonebrick", "stairs:slab_desert_sandstone_brick"},
|
||||
{"default:fence_wood", "default:fence_pine_wood"}
|
||||
} },
|
||||
})
|
||||
|
||||
-- Special items
|
||||
minetest.register_node("lucky_block:void_mirror", {
|
||||
description = S("Void Mirror (Place to see through solid walls during daytime)"),
|
||||
|
80
init.lua
80
init.lua
@ -10,6 +10,7 @@ local S, NS = dofile(MP.."/intllib.lua")
|
||||
-- a wee bit of colour
|
||||
local green = minetest.get_color_escape_sequence("#1eff00")
|
||||
|
||||
|
||||
-- example custom function (punches player with 5 damage)
|
||||
local function punchy(pos, player)
|
||||
|
||||
@ -47,28 +48,24 @@ local function pint(pos, player)
|
||||
end
|
||||
|
||||
|
||||
local function drop(pos, itemstack)
|
||||
|
||||
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count()))
|
||||
|
||||
if obj then
|
||||
|
||||
obj:setvelocity({
|
||||
x = math.random(-10, 10) / 9,
|
||||
y = 5,
|
||||
z = math.random(-10, 10) / 9,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- custom function to drop player inventory and replace with dry shrubs
|
||||
local function bushy(pos, player)
|
||||
|
||||
local player_inv = player:get_inventory() ; pos = player:get_pos() or pos
|
||||
|
||||
for i = 1, player_inv:get_size("main") do
|
||||
drop(pos, player_inv:get_stack("main", i))
|
||||
|
||||
local obj = minetest.add_item(pos, player_inv:get_stack("main", i))
|
||||
|
||||
if obj then
|
||||
|
||||
obj:setvelocity({
|
||||
x = math.random(-10, 10) / 9,
|
||||
y = 5,
|
||||
z = math.random(-10, 10) / 9,
|
||||
})
|
||||
end
|
||||
|
||||
player_inv:set_stack("main", i, "default:dry_shrub")
|
||||
end
|
||||
|
||||
@ -225,7 +222,6 @@ local function entity_physics(pos, radius)
|
||||
|
||||
else --if ent.health then
|
||||
|
||||
--objs[n]:punch(objs[n], 1.0, {
|
||||
objs[n]:punch(tmp_ent, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = damage},
|
||||
@ -288,7 +284,7 @@ local lucky_block = function(pos, digger)
|
||||
|
||||
local luck = math.random(1, #lucky_list) ; -- luck = 1
|
||||
local action = lucky_list[luck][1]
|
||||
local schem
|
||||
--local schem
|
||||
|
||||
-- print ("luck ["..luck.." of "..#lucky_list.."]", action)
|
||||
|
||||
@ -303,6 +299,7 @@ local lucky_block = function(pos, digger)
|
||||
local schem = lucky_list[luck][2]
|
||||
local switch = lucky_list[luck][3] or 0
|
||||
local force = lucky_list[luck][4]
|
||||
local reps = lucky_list[luck][5] or {}
|
||||
|
||||
if switch == 1 then
|
||||
pos = vector.round(digger:get_pos())
|
||||
@ -314,7 +311,7 @@ local lucky_block = function(pos, digger)
|
||||
|
||||
local p1 = vector.subtract(pos, lucky_schems[i][3])
|
||||
|
||||
minetest.place_schematic(p1, lucky_schems[i][2], "", {}, force)
|
||||
minetest.place_schematic(p1, lucky_schems[i][2], "", reps, force)
|
||||
|
||||
break
|
||||
end
|
||||
@ -437,18 +434,40 @@ local lucky_block = function(pos, digger)
|
||||
local colours = lucky_list[luck][4]
|
||||
local items = #lucky_list[luck][2]
|
||||
|
||||
for i = 1, num do
|
||||
-- drop multiple different items or colours
|
||||
if items > 1 or colours then
|
||||
|
||||
local item = lucky_list[luck][2][math.random(1, items)]
|
||||
for i = 1, num do
|
||||
|
||||
if colours then
|
||||
item = item .. all_colours[math.random(#all_colours)]
|
||||
local item = lucky_list[luck][2][math.random(1, items)]
|
||||
|
||||
if colours then
|
||||
item = item .. all_colours[math.random(#all_colours)]
|
||||
end
|
||||
|
||||
if not minetest.registered_items[item] then
|
||||
item = "default:coal_lump"
|
||||
end
|
||||
|
||||
local obj = minetest.add_item(pos, item)
|
||||
|
||||
if obj then
|
||||
|
||||
obj:set_velocity({
|
||||
x = math.random(-10, 10) / 9,
|
||||
y = 5,
|
||||
z = math.random(-10, 10) / 9,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if not minetest.registered_nodes[item]
|
||||
and not minetest.registered_craftitems[item]
|
||||
and not minetest.registered_tools[item] then
|
||||
item = "default:coal_lump"
|
||||
else -- drop single item in a stack
|
||||
|
||||
local item = lucky_list[luck][2][1]
|
||||
if not minetest.registered_items[item] then
|
||||
item = ItemStack("default:coal_lump " .. tonumber(num))
|
||||
else
|
||||
item = ItemStack(item .. " " .. tonumber(num))
|
||||
end
|
||||
|
||||
local obj = minetest.add_item(pos, item)
|
||||
@ -466,10 +485,9 @@ local lucky_block = function(pos, digger)
|
||||
-- lightning strike
|
||||
elseif action == "lig" then
|
||||
|
||||
local nod = lucky_list[luck][2]
|
||||
local nod = lucky_list[luck][2] or "fire:basic_flame"
|
||||
|
||||
if nod and not minetest.registered_nodes[nod] then
|
||||
print (nod)
|
||||
if not minetest.registered_nodes[nod] then
|
||||
nod = "fire:basic_flame"
|
||||
end
|
||||
|
||||
@ -498,8 +516,6 @@ local lucky_block = function(pos, digger)
|
||||
max_hear_distance = 25
|
||||
})
|
||||
|
||||
minetest.set_node(pos, {name = "fire:permanent_flame"})
|
||||
|
||||
-- falling nodes
|
||||
elseif action == "fal" then
|
||||
|
||||
|
102
schems.lua
102
schems.lua
@ -179,6 +179,49 @@ lucky_block:add_schematics({
|
||||
{"wishingwell", path .. "lb_wishing_well.mts", {x = 1, y = 1, z = 1}},
|
||||
})
|
||||
|
||||
-- Global list containing well blocks that can be dropped
|
||||
lucky_block.wellblocks = {
|
||||
{"default:ice", 7},
|
||||
{"default:bronzeblock", 5},
|
||||
{"default:coalblock", 5},
|
||||
{"default:sand", 7},
|
||||
{"default:goldblock", 5},
|
||||
{"default:cactus", 7},
|
||||
{"default:cobble", 7},
|
||||
{"default:brick", 8},
|
||||
{"default:desert_sand", 7},
|
||||
{"default:obsidian", 7},
|
||||
{"default:diamondblock", 4},
|
||||
{"default:dirt", 7},
|
||||
{"default:clay", 7},
|
||||
{"default:copperblock", 5},
|
||||
{"default:mese", 5},
|
||||
{"default:silver_sand", 7},
|
||||
{"default:snowblock", 7},
|
||||
{"default:mossycobble", 7},
|
||||
{"default:lava_source", 5},
|
||||
}
|
||||
|
||||
local add_wblock = function(name, number)
|
||||
local total = #lucky_block.wellblocks
|
||||
lucky_block.wellblocks[total + 1] = {name, number}
|
||||
end
|
||||
|
||||
-- Add additional well blocks
|
||||
if minetest.get_modpath("tnt") then
|
||||
add_wblock("tnt:tnt_burning", 8)
|
||||
add_wblock("tnt:tnt_burning", 4)
|
||||
add_wblock("tnt:tnt_burning", 8)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("ethereal") then
|
||||
add_wblock("ethereal:crystal_block", 5)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("bones") then
|
||||
add_wblock("bones:bones", 5)
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
|
||||
label = "Lucky Block Wishing Well Block",
|
||||
@ -201,58 +244,23 @@ minetest.register_abm({
|
||||
max_hear_distance = 10
|
||||
})
|
||||
|
||||
local blocks = {
|
||||
{"default:ice", 7},
|
||||
{"default:bronzeblock", 5},
|
||||
{"default:coalblock", 5},
|
||||
{"default:sand", 7},
|
||||
{"default:goldblock", 5},
|
||||
{"default:cactus", 7},
|
||||
{"default:cobble", 7},
|
||||
{"default:brick", 8},
|
||||
{"default:desert_sand", 7},
|
||||
{"default:obsidian", 7},
|
||||
{"default:diamondblock", 4},
|
||||
{"default:dirt", 7},
|
||||
{"default:clay", 7},
|
||||
{"default:copperblock", 5},
|
||||
{"default:mese", 5},
|
||||
{"default:silver_sand", 7},
|
||||
{"default:snowblock", 7},
|
||||
{"default:mossycobble", 7},
|
||||
}
|
||||
local tot = #blocks
|
||||
local b_no = math.random(#lucky_block.wellblocks)
|
||||
local item = lucky_block.wellblocks[b_no][1]
|
||||
|
||||
if minetest.registered_nodes["tnt:tnt_burning"] then
|
||||
tot = tot + 1
|
||||
blocks[tot] = {"tnt:tnt_burning", 8}
|
||||
tot = tot + 1
|
||||
blocks[tot] = {"tnt:tnt_burning", 4}
|
||||
tot = tot + 1
|
||||
blocks[tot] = {"tnt:tnt_burning", 8}
|
||||
end
|
||||
for n = 1, lucky_block.wellblocks[b_no][2] do
|
||||
|
||||
if minetest.registered_nodes["ethereal:crystal_block"] then
|
||||
tot = tot + 1
|
||||
blocks[tot] = {"ethereal:crystal_block", 5}
|
||||
end
|
||||
local nod = minetest.registered_nodes[item]
|
||||
|
||||
if minetest.registered_nodes["bones:bones"] then
|
||||
tot = tot + 1
|
||||
blocks[tot] = {"bones:bones", 5}
|
||||
end
|
||||
if nod then
|
||||
|
||||
local b_no = math.random(#blocks)
|
||||
local obj = minetest.add_entity({
|
||||
x = pos.x + math.random(-7, 7),
|
||||
y = pos.y + 7,
|
||||
z = pos.z + math.random(-7, 7)
|
||||
}, "__builtin:falling_node")
|
||||
|
||||
for n = 1, blocks[b_no][2] do
|
||||
|
||||
local xx = math.random(-7, 7)
|
||||
local zz = math.random(-7, 7)
|
||||
local p2 = {x = pos.x + xx, y = pos.y + 7, z = pos.z + zz}
|
||||
local nod = minetest.registered_nodes[blocks[b_no][1]]
|
||||
local obj = minetest.add_entity(p2, "__builtin:falling_node")
|
||||
|
||||
obj:get_luaentity():set_node(nod)
|
||||
obj:get_luaentity():set_node(nod)
|
||||
end
|
||||
end
|
||||
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user