mirror of
https://notabug.org/TenPlus1/lucky_block.git
synced 2024-07-07 15:45:21 +02:00
tweak and tidy code
This commit is contained in:
parent
7705d08e33
commit
f6c4b9d693
@ -1,7 +1,7 @@
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
local S, NS = dofile(MP .. "/intllib.lua")
|
||||
|
||||
|
||||
-- Default tree schematics
|
||||
|
619
init.lua
619
init.lua
@ -5,7 +5,7 @@ lucky_schems = {}
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
local S, NS = dofile(MP .. "/intllib.lua")
|
||||
|
||||
-- a wee bit of colour
|
||||
local green = minetest.get_color_escape_sequence("#1eff00")
|
||||
@ -80,7 +80,9 @@ local lucky_list = {
|
||||
{"sch", "wishingwell", 0, true},
|
||||
{"cus", bushy},
|
||||
{"cus", punchy},
|
||||
{"fal", {"default:wood", "default:gravel", "default:sand", "default:desert_sand", "default:stone", "default:dirt", "default:goldblock"}, 0},
|
||||
{"fal", {"default:wood", "default:gravel", "default:sand",
|
||||
"default:desert_sand", "default:stone", "default:dirt",
|
||||
"default:goldblock"}, 0},
|
||||
{"lig"},
|
||||
{"nod", "lucky_block:super_lucky_block", 0},
|
||||
{"exp", 2},
|
||||
@ -153,10 +155,7 @@ end
|
||||
local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow)
|
||||
|
||||
radius = radius or 2
|
||||
min_size = min_size or 0.5
|
||||
max_size = max_size or 1
|
||||
gravity = gravity or -10
|
||||
glow = glow or 0
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = amount,
|
||||
@ -169,10 +168,10 @@ local effect = function(pos, amount, texture, min_size, max_size, radius, gravit
|
||||
maxacc = {x = 0, y = gravity, z = 0},
|
||||
minexptime = 0.1,
|
||||
maxexptime = 1,
|
||||
minsize = min_size,
|
||||
maxsize = max_size,
|
||||
minsize = min_size or 0.5,
|
||||
maxsize = max_size or 1.0,
|
||||
texture = texture,
|
||||
glow = glow,
|
||||
glow = glow or 0,
|
||||
})
|
||||
end
|
||||
|
||||
@ -212,6 +211,7 @@ local function entity_physics(pos, radius)
|
||||
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)
|
||||
@ -240,11 +240,15 @@ local function fill_chest(pos, items)
|
||||
inv:set_size("main", 8 * 4)
|
||||
|
||||
for i = 0, 2, 1 do
|
||||
|
||||
local stuff = chest_stuff[math.random(1, #chest_stuff)]
|
||||
table.insert(stacks, {name = stuff.name, count = math.random(1, stuff.max)})
|
||||
|
||||
table.insert(stacks, {
|
||||
name = stuff.name, count = math.random(1, stuff.max)})
|
||||
end
|
||||
|
||||
for s = 1, #stacks do
|
||||
|
||||
if not inv:contains_item("main", stacks[s]) then
|
||||
inv:set_stack("main", math.random(1, 32), stacks[s])
|
||||
end
|
||||
@ -276,198 +280,168 @@ local function explode(pos, radius, sound)
|
||||
end
|
||||
|
||||
|
||||
-- this is what happens when you dig a lucky block
|
||||
local lucky_block = function(pos, digger)
|
||||
local lb_schematic = function(pos, digger, def)
|
||||
|
||||
-- make sure it's really random
|
||||
math.randomseed(os.time() + minetest.get_timeofday())
|
||||
if #lucky_schems == 0 then
|
||||
print ("[lucky block] No schematics")
|
||||
return
|
||||
end
|
||||
|
||||
local luck = math.random(1, #lucky_list) ; -- luck = 1
|
||||
local action = lucky_list[luck][1]
|
||||
--local schem
|
||||
local schem = def[2]
|
||||
local switch = def[3] or 0
|
||||
local force = def[4]
|
||||
local reps = def[5] or {}
|
||||
|
||||
-- print ("luck ["..luck.." of "..#lucky_list.."]", action)
|
||||
if switch == 1 then
|
||||
pos = vector.round(digger:get_pos())
|
||||
end
|
||||
|
||||
-- place schematic
|
||||
if action == "sch" then
|
||||
for i = 1, #lucky_schems do
|
||||
|
||||
if #lucky_schems == 0 then
|
||||
print ("[lucky block] No schematics")
|
||||
return
|
||||
if schem == lucky_schems[i][1] then
|
||||
|
||||
local p1 = vector.subtract(pos, lucky_schems[i][3])
|
||||
|
||||
minetest.place_schematic(p1, lucky_schems[i][2], "", reps, force)
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
digger:set_pos(pos, false)
|
||||
end
|
||||
end
|
||||
|
||||
if switch == 1 then
|
||||
pos = vector.round(digger:get_pos())
|
||||
end
|
||||
|
||||
for i = 1, #lucky_schems do
|
||||
local lb_node = function(pos, digger, def)
|
||||
|
||||
if schem == lucky_schems[i][1] then
|
||||
local nod = def[2]
|
||||
local switch = def[3]
|
||||
local items = def[4]
|
||||
|
||||
local p1 = vector.subtract(pos, lucky_schems[i][3])
|
||||
if switch == 1 then
|
||||
pos = digger:get_pos()
|
||||
end
|
||||
|
||||
minetest.place_schematic(p1, lucky_schems[i][2], "", reps, force)
|
||||
if not minetest.registered_nodes[nod] then
|
||||
nod = "default:goldblock"
|
||||
end
|
||||
|
||||
break
|
||||
effect(pos, 25, "tnt_smoke.png", 8, 8, 2, 1, 0)
|
||||
|
||||
minetest.set_node(pos, {name = nod})
|
||||
|
||||
if nod == "default:chest" then
|
||||
fill_chest(pos, items)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local lb_spawn = function(pos, digger, def)
|
||||
|
||||
local pos2 = {}
|
||||
local num = def[3] or 1
|
||||
local tame = def[4]
|
||||
local own = def[5]
|
||||
local range = def[6] or 5
|
||||
local name = def[7]
|
||||
|
||||
for i = 1, num do
|
||||
|
||||
pos2.x = pos.x + math.random(-range, range)
|
||||
pos2.y = pos.y + 1
|
||||
pos2.z = pos.z + math.random(-range, range)
|
||||
|
||||
local nod = minetest.get_node(pos2)
|
||||
local nodef = minetest.registered_nodes[nod.name]
|
||||
|
||||
if nodef and nodef.walkable == false then
|
||||
|
||||
local entity = def[2]
|
||||
|
||||
-- coloured sheep
|
||||
if entity == "mobs:sheep" then
|
||||
local colour = "_" .. all_colours[math.random(#all_colours)]
|
||||
entity = "mobs:sheep" .. colour
|
||||
end
|
||||
|
||||
-- has entity been registered?
|
||||
if minetest.registered_entities[entity] then
|
||||
|
||||
local ent = minetest.add_entity(pos2, entity):get_luaentity()
|
||||
|
||||
if tame then
|
||||
ent.tamed = true
|
||||
end
|
||||
|
||||
if own then
|
||||
ent.owner = digger:get_player_name()
|
||||
end
|
||||
|
||||
if name then
|
||||
ent.nametag = name
|
||||
ent.object:set_properties({
|
||||
nametag = name,
|
||||
nametag_color = "#FFFF00"
|
||||
})
|
||||
end
|
||||
else
|
||||
print ("[lucky_block] " .. entity .. " could not be spawned")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if switch == 1 then
|
||||
digger:set_pos(pos, false)
|
||||
end
|
||||
|
||||
-- place node (if chest then fill chest)
|
||||
elseif action == "nod" then
|
||||
local lb_explode = function(pos, def)
|
||||
|
||||
local nod = lucky_list[luck][2]
|
||||
local switch = lucky_list[luck][3]
|
||||
local items = lucky_list[luck][4]
|
||||
local rad = def[2] or 2
|
||||
local snd = def[3] or "tnt_explode"
|
||||
|
||||
if switch == 1 then
|
||||
pos = digger:get_pos()
|
||||
end
|
||||
explode(pos, rad, snd)
|
||||
end
|
||||
|
||||
if not minetest.registered_nodes[nod] then
|
||||
print (nod)
|
||||
nod = "default:goldblock"
|
||||
end
|
||||
|
||||
effect(pos, 25, "tnt_smoke.png", 8, 8, 2, 1, 0)
|
||||
local lb_teleport = function(pos, digger, def)
|
||||
|
||||
minetest.set_node(pos, {name = nod})
|
||||
local xz_range = def[2] or 10
|
||||
local y_range = def[3] or 5
|
||||
|
||||
if nod == "default:chest" then
|
||||
fill_chest(pos, items)
|
||||
end
|
||||
pos.x = pos.x + math.random(-xz_range, xz_range)
|
||||
pos.x = pos.y + math.random(-y_range, y_range)
|
||||
pos.x = pos.z + math.random(-xz_range, xz_range)
|
||||
|
||||
-- place entity
|
||||
elseif action == "spw" then
|
||||
effect(pos, 25, "tnt_smoke.png", 8, 8, 1, -10, 0)
|
||||
|
||||
local pos2 = {}
|
||||
local num = lucky_list[luck][3] or 1
|
||||
local tame = lucky_list[luck][4]
|
||||
local own = lucky_list[luck][5]
|
||||
local range = lucky_list[luck][6] or 5
|
||||
local name = lucky_list[luck][7]
|
||||
digger:set_pos(pos, false)
|
||||
|
||||
effect(pos, 25, "tnt_smoke.png", 8, 8, 1, -10, 0)
|
||||
|
||||
minetest.chat_send_player(digger:get_player_name(),
|
||||
green .. S("Random Teleport!"))
|
||||
end
|
||||
|
||||
|
||||
local lb_drop = function(pos, digger, def)
|
||||
|
||||
local num = def[3] or 1
|
||||
local colours = def[4]
|
||||
local items = #def[2]
|
||||
|
||||
-- drop multiple different items or colours
|
||||
if items > 1 or colours then
|
||||
|
||||
for i = 1, num do
|
||||
|
||||
pos2.x = pos.x + math.random(-range, range)
|
||||
pos2.y = pos.y + 1
|
||||
pos2.z = pos.z + math.random(-range, range)
|
||||
local item = def[2][math.random(1, items)]
|
||||
|
||||
local nod = minetest.get_node(pos2)
|
||||
local def = minetest.registered_nodes[nod.name]
|
||||
|
||||
if def and def.walkable == false then
|
||||
|
||||
local entity = lucky_list[luck][2]
|
||||
|
||||
-- coloured sheep
|
||||
if entity == "mobs:sheep" then
|
||||
local colour = "_" .. all_colours[math.random(#all_colours)]
|
||||
entity = "mobs:sheep" .. colour
|
||||
end
|
||||
|
||||
-- has entity been registered?
|
||||
if minetest.registered_entities[entity] then
|
||||
|
||||
local ent = minetest.add_entity(pos2, entity):get_luaentity()
|
||||
|
||||
if tame then
|
||||
ent.tamed = true
|
||||
end
|
||||
|
||||
if own then
|
||||
ent.owner = digger:get_player_name()
|
||||
end
|
||||
|
||||
if name then
|
||||
ent.nametag = name
|
||||
ent.object:set_properties({
|
||||
nametag = name,
|
||||
nametag_color = "#FFFF00"
|
||||
})
|
||||
end
|
||||
else
|
||||
print ("[lucky_block] " .. entity .. " could not be spawned")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- explosion
|
||||
elseif action == "exp" then
|
||||
|
||||
local rad = lucky_list[luck][2] or 2
|
||||
local snd = lucky_list[luck][3] or "tnt_explode"
|
||||
|
||||
explode(pos, rad, snd)
|
||||
|
||||
-- teleport
|
||||
elseif action == "tel" then
|
||||
|
||||
local xz_range = lucky_list[luck][2] or 10
|
||||
local y_range = lucky_list[luck][3] or 5
|
||||
|
||||
pos.x = pos.x + math.random(-xz_range, xz_range)
|
||||
pos.x = pos.y + math.random(-y_range, y_range)
|
||||
pos.x = pos.z + math.random(-xz_range, xz_range)
|
||||
|
||||
effect(pos, 25, "tnt_smoke.png", 8, 8, 1, -10, 0)
|
||||
|
||||
digger:set_pos(pos, false)
|
||||
|
||||
effect(pos, 25, "tnt_smoke.png", 8, 8, 1, -10, 0)
|
||||
|
||||
minetest.chat_send_player(digger:get_player_name(),
|
||||
green .. S("Random Teleport!"))
|
||||
|
||||
-- drop items
|
||||
elseif action == "dro" then
|
||||
|
||||
local num = lucky_list[luck][3] or 1
|
||||
local colours = lucky_list[luck][4]
|
||||
local items = #lucky_list[luck][2]
|
||||
|
||||
-- drop multiple different items or colours
|
||||
if items > 1 or colours then
|
||||
|
||||
for i = 1, num do
|
||||
|
||||
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
|
||||
if colours then
|
||||
item = item .. all_colours[math.random(#all_colours)]
|
||||
end
|
||||
|
||||
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))
|
||||
item = "default:coal_lump"
|
||||
end
|
||||
|
||||
local obj = minetest.add_item(pos, item)
|
||||
@ -482,152 +456,241 @@ local lucky_block = function(pos, digger)
|
||||
end
|
||||
end
|
||||
|
||||
-- lightning strike
|
||||
elseif action == "lig" then
|
||||
else -- drop single item in a stack
|
||||
|
||||
local nod = lucky_list[luck][2] or "fire:basic_flame"
|
||||
local item = def[2][1]
|
||||
|
||||
if not minetest.registered_nodes[nod] then
|
||||
nod = "fire:basic_flame"
|
||||
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)
|
||||
|
||||
if obj then
|
||||
|
||||
obj:set_velocity({
|
||||
x = math.random(-10, 10) / 9,
|
||||
y = 5,
|
||||
z = math.random(-10, 10) / 9,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local lb_lightning = function(pos, digger, def)
|
||||
|
||||
local nod = def[2]
|
||||
|
||||
if not minetest.registered_nodes[nod] then
|
||||
nod = "fire:basic_flame"
|
||||
end
|
||||
|
||||
pos = digger:get_pos()
|
||||
|
||||
if nod then
|
||||
minetest.set_node(pos, {name = nod})
|
||||
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,
|
||||
})
|
||||
|
||||
entity_physics(pos, 2)
|
||||
|
||||
minetest.sound_play("lightning", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 25
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
local lb_falling = function(pos, digger, def)
|
||||
|
||||
local nods = def[2]
|
||||
local switch = def[3]
|
||||
local spread = def[4]
|
||||
local range = def[5] or 5
|
||||
|
||||
if switch == 1 then
|
||||
pos = digger:get_pos()
|
||||
end
|
||||
|
||||
if nod then
|
||||
minetest.set_node(pos, {name = nod})
|
||||
end
|
||||
if spread then
|
||||
pos.y = pos.y + 10
|
||||
else
|
||||
pos.y = pos.y + #nods
|
||||
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.remove_node(pos)
|
||||
|
||||
entity_physics(pos, 2)
|
||||
local pos2 = {x = pos.x, y = pos.y, z = pos.z}
|
||||
|
||||
minetest.sound_play("lightning", {
|
||||
for s = 1, #nods do
|
||||
|
||||
minetest.after(0.5 * s, function()
|
||||
|
||||
if spread then
|
||||
pos2.x = pos.x + math.random(-range, range)
|
||||
pos2.z = pos.z + math.random(-range, range)
|
||||
end
|
||||
|
||||
local n = minetest.registered_nodes[nods[s]]
|
||||
|
||||
if n then
|
||||
|
||||
local obj = minetest.add_entity(pos2, "__builtin:falling_node")
|
||||
|
||||
obj:get_luaentity():set_node(n)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local lb_troll = function(pos, def)
|
||||
|
||||
local nod = def[2]
|
||||
local snd = def[3]
|
||||
local exp = def[4]
|
||||
|
||||
minetest.set_node(pos, {name = nod})
|
||||
|
||||
if snd then
|
||||
|
||||
minetest.sound_play(snd, {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 25
|
||||
max_hear_distance = 10
|
||||
})
|
||||
end
|
||||
|
||||
-- falling nodes
|
||||
elseif action == "fal" then
|
||||
if not minetest.registered_nodes[nod] then
|
||||
nod = "default:goldblock"
|
||||
end
|
||||
|
||||
local nods = lucky_list[luck][2]
|
||||
local switch = lucky_list[luck][3]
|
||||
local spread = lucky_list[luck][4]
|
||||
local range = lucky_list[luck][5] or 5
|
||||
minetest.after(2.0, function()
|
||||
|
||||
if switch == 1 then
|
||||
pos = digger:get_pos()
|
||||
end
|
||||
if exp then
|
||||
|
||||
if spread then
|
||||
pos.y = pos.y + 10
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
|
||||
explode(pos, 2)
|
||||
else
|
||||
pos.y = pos.y + #nods
|
||||
end
|
||||
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
|
||||
local pos2 = {x = pos.x, y = pos.y, z = pos.z}
|
||||
|
||||
for s = 1, #nods do
|
||||
|
||||
minetest.after(0.5 * s, function()
|
||||
|
||||
if spread then
|
||||
pos2.x = pos.x + math.random(-range, range)
|
||||
pos2.z = pos.z + math.random(-range, range)
|
||||
end
|
||||
|
||||
local n = minetest.registered_nodes[nods[s]]
|
||||
|
||||
if n then
|
||||
|
||||
local obj = minetest.add_entity(pos2, "__builtin:falling_node")
|
||||
|
||||
obj:get_luaentity():set_node(n)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- troll block, disappears or explodes after 2 seconds
|
||||
elseif action == "tro" then
|
||||
|
||||
local nod = lucky_list[luck][2]
|
||||
local snd = lucky_list[luck][3]
|
||||
local exp = lucky_list[luck][4]
|
||||
|
||||
minetest.set_node(pos, {name = nod})
|
||||
|
||||
if snd then
|
||||
minetest.sound_play(snd, {
|
||||
minetest.sound_play("default_hard_footstep", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 10
|
||||
})
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if not minetest.registered_nodes[nod] then
|
||||
print (nod)
|
||||
nod = "default:goldblock"
|
||||
end
|
||||
|
||||
minetest.after(2.0, function()
|
||||
local lb_floor = function(pos, def)
|
||||
|
||||
if exp then
|
||||
local size = def[2] or 1
|
||||
local nods = def[3] or {"default:dirt"}
|
||||
local offs = def[4] or 0
|
||||
local num = 1
|
||||
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
for x = 0, size - 1 do
|
||||
for z = 0, size - 1 do
|
||||
|
||||
explode(pos, 2)
|
||||
else
|
||||
minetest.after(0.5 * num, function()
|
||||
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
minetest.set_node({
|
||||
x = (pos.x + x) - offs,
|
||||
y = pos.y - 1,
|
||||
z = (pos.z + z) - offs
|
||||
}, {name = nods[math.random(#nods)]})
|
||||
|
||||
minetest.sound_play("default_hard_footstep", {
|
||||
minetest.sound_play("default_place_node", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 10
|
||||
})
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
num = num + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- this is what happens when you dig a lucky block
|
||||
local lucky_block = function(pos, digger)
|
||||
|
||||
-- make sure it's really random
|
||||
math.randomseed(minetest.get_timeofday() + pos.x + pos.z) -- os.time()
|
||||
|
||||
local luck = math.random(1, #lucky_list) ; -- luck = 1
|
||||
local action = lucky_list[luck][1]
|
||||
|
||||
-- print ("luck ["..luck.." of "..#lucky_list.."]", action)
|
||||
|
||||
-- place schematic
|
||||
if action == "sch" then
|
||||
|
||||
lb_schematic(pos, digger, lucky_list[luck])
|
||||
|
||||
-- place node (if chest then fill chest)
|
||||
elseif action == "nod" then
|
||||
|
||||
lb_node(pos, digger, lucky_list[luck])
|
||||
|
||||
-- place entity
|
||||
elseif action == "spw" then
|
||||
|
||||
lb_spawn(pos, digger, lucky_list[luck])
|
||||
|
||||
-- explosion
|
||||
elseif action == "exp" then
|
||||
|
||||
lb_explode(pos, lucky_list[luck])
|
||||
|
||||
-- teleport
|
||||
elseif action == "tel" then
|
||||
|
||||
lb_teleport(pos, digger, lucky_list[luck])
|
||||
|
||||
-- drop items
|
||||
elseif action == "dro" then
|
||||
|
||||
lb_drop(pos, digger, lucky_list[luck])
|
||||
|
||||
-- lightning strike
|
||||
elseif action == "lig" then
|
||||
|
||||
lb_lightning(pos, digger, lucky_list[luck])
|
||||
|
||||
-- falling nodes
|
||||
elseif action == "fal" then
|
||||
|
||||
lb_falling(pos, digger, lucky_list[luck])
|
||||
|
||||
-- troll block, disappears or explodes after 2 seconds
|
||||
elseif action == "tro" then
|
||||
|
||||
lb_troll(pos, lucky_list[luck])
|
||||
|
||||
-- floor paint
|
||||
elseif action == "flo" then
|
||||
|
||||
local size = lucky_list[luck][2] or 1
|
||||
local nods = lucky_list[luck][3] or {"default:dirt"}
|
||||
local offs = lucky_list[luck][4] or 0
|
||||
local num = 1
|
||||
|
||||
for x = 0, size - 1 do
|
||||
for z = 0, size - 1 do
|
||||
|
||||
minetest.after(0.5 * num, function()
|
||||
|
||||
minetest.set_node({
|
||||
x = (pos.x + x) - offs,
|
||||
y = pos.y - 1,
|
||||
z = (pos.z + z) - offs
|
||||
}, {name = nods[math.random(#nods)]})
|
||||
|
||||
minetest.sound_play("default_place_node", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 10
|
||||
})
|
||||
end)
|
||||
|
||||
num = num + 1
|
||||
end
|
||||
end
|
||||
lb_floor(pos, lucky_list[luck])
|
||||
|
||||
-- custom function
|
||||
elseif action == "cus" then
|
||||
@ -682,7 +745,7 @@ minetest.register_craft({
|
||||
minetest.register_node('lucky_block:super_lucky_block', {
|
||||
description = S("Super Lucky Block (use pick)"),
|
||||
tiles = {{
|
||||
name="lucky_block_super_animated.png",
|
||||
name = "lucky_block_super_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
@ -699,7 +762,9 @@ minetest.register_node('lucky_block:super_lucky_block', {
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("infotext", "Super Lucky Block")
|
||||
end,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user