tidy and tweak code

This commit is contained in:
tenplus1 2024-08-13 13:15:47 +01:00
parent d70a52c6f8
commit 09b388cfdf
8 changed files with 169 additions and 145 deletions

161
init.lua
View File

@ -1,9 +1,12 @@
-- mod check
-- translation and mod support
local S = minetest.get_translator("lucky_block")
local def = minetest.get_modpath("default")
local mcl = minetest.get_modpath("mcl_core")
-- global
lucky_block = {
mod_def = def,
mod_mcl = mcl,
@ -17,44 +20,28 @@ lucky_block = {
def_flame = mcl and "mcl_fire:fire" or "fire:basic_flame",
def_gold = mcl and "mcl_core:goldblock" or "default:goldblock",
def_glass = mcl and "mcl_core:glass" or "default:glass",
green = minetest.get_color_escape_sequence("#1eff00")
green = minetest.get_color_escape_sequence("#1eff00"),
S = S
}
lucky_schems = {}
-- quick sound setup
if mcl then
if mcl then
lucky_block.snd_glass = mcl_sounds.node_sound_glass_defaults()
lucky_block.snd_wood = mcl_sounds.node_sound_wood_defaults()
lucky_block.snd_stone = mcl_sounds.node_sound_stone_defaults()
end
-- translation support
local S
if minetest.get_translator then
S = minetest.get_translator("lucky_block") -- 5.x translation function
else -- boilerplate function
S = function(str, ...)
local args = {...}
return str:gsub("@%d+", function(match)
return args[tonumber(match:sub(2))]
end)
end
end
lucky_block.intllib = S
-- default blocks
local lucky_list = {
{"nod", "lucky_block:super_lucky_block", 0}
}
-- ability to add new blocks to list
function lucky_block:add_blocks(list)
for s = 1, #list do
@ -62,8 +49,8 @@ function lucky_block:add_blocks(list)
end
end
-- call to purge the block list
function lucky_block:purge_block_list()
lucky_list = {
@ -71,8 +58,8 @@ function lucky_block:purge_block_list()
}
end
-- add schematics to global list
function lucky_block:add_schematics(list)
for s = 1, #list do
@ -80,32 +67,33 @@ function lucky_block:add_schematics(list)
end
end
-- for random colour selection
local all_colours = {
"grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta",
"orange", "violet", "brown", "pink", "dark_grey", "dark_green", "white"
}
if lucky_block.mcl then
all_colours = {
"red", "blue", "cyan", "grey", "silver", "black", "yellow", "green", "magenta",
"orange", "purple", "brown", "pink", "lime", "light_blue", "white"
}
end
-- default chests items
local chest_stuff = {}
-- call to purge the chest item list
function lucky_block:purge_chest_items()
chest_stuff = {}
end
-- ability to add to chest item list
function lucky_block:add_chest_items(list)
for s = 1, #list do
@ -113,8 +101,8 @@ function lucky_block:add_chest_items(list)
end
end
-- particle effects
local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow)
radius = radius or 2
@ -138,8 +126,8 @@ local effect = function(pos, amount, texture, min_size, max_size, radius, gravit
})
end
-- temp entity for mob damage
minetest.register_entity("lucky_block:temp", {
physical = true,
collisionbox = {0, 0, 0, 0, 0, 0},
@ -152,14 +140,12 @@ minetest.register_entity("lucky_block:temp", {
self.timer = (self.timer or 0) + dtime
if self.timer > 0.5 then
self.object:remove()
end
if self.timer > 0.5 then self.object:remove() end
end
})
-- modified from TNT mod to deal entity damage only
local function entity_physics(pos, radius)
radius = radius * 2
@ -188,18 +174,16 @@ local function entity_physics(pos, radius)
end
end
-- fill chest at position
-- function to fill chest at position
local function fill_chest(pos, items)
local stacks = items or chest_stuff
local meta = minetest.get_meta(pos)
local inv = meta and meta:get_inventory()
local inv = meta and meta:get_inventory() ; if not inv then return end
local size = inv and inv:get_size("main")
local stack
if not inv then return end
-- loop through inventory
for _, def in ipairs(stacks) do
@ -223,8 +207,8 @@ local function fill_chest(pos, items)
end
end
-- explosion with protection check
local function explode(pos, radius, sound)
sound = sound or "tnt_explode"
@ -242,12 +226,12 @@ local function explode(pos, radius, sound)
end
end
-- place schematic
local lb_schematic = function(pos, digger, def)
if #lucky_schems == 0 then
print ("[lucky block] No schematics")
return
print ("[lucky block] No schematics") ; return
end
local schem = def[2]
@ -255,9 +239,7 @@ local lb_schematic = function(pos, digger, def)
local force = def[4]
local reps = def[5] or {}
if switch == 1 then
pos = vector.round(digger:get_pos())
end
if switch == 1 then pos = vector.round(digger:get_pos()) end
for i = 1, #lucky_schems do
@ -271,11 +253,10 @@ local lb_schematic = function(pos, digger, def)
end
end
if switch == 1 then
digger:set_pos(pos, false)
end
if switch == 1 then digger:set_pos(pos, false) end
end
-- place node
local lb_node = function(pos, digger, def)
@ -283,9 +264,7 @@ local lb_node = function(pos, digger, def)
local switch = def[3]
local items = def[4]
if switch == 1 then
pos = digger:get_pos()
end
if switch == 1 then pos = digger:get_pos() end
if not minetest.registered_nodes[nod] then
nod = lucky_block.def_node
@ -295,12 +274,12 @@ local lb_node = function(pos, digger, def)
minetest.set_node(pos, {name = nod})
if nod == "default:chest"
or nod == "mcl_chests:chest_small" then
if nod == "default:chest" or nod == "mcl_chests:chest_small" then
fill_chest(pos, items)
end
end
-- spawn entity/mob
local lb_spawn = function(pos, digger, def)
@ -351,15 +330,12 @@ local lb_spawn = function(pos, digger, def)
local ent = obj:get_luaentity()
if tame then
ent.tamed = true
end
if tame then ent.tamed = true end
if own then
ent.owner = digger:get_player_name()
end
if own then ent.owner = digger:get_player_name() end
if name then
ent.nametag = name
ent.object:set_properties({
nametag = name,
@ -374,6 +350,7 @@ local lb_spawn = function(pos, digger, def)
end
end
-- explosion
local lb_explode = function(pos, def)
@ -383,6 +360,7 @@ local lb_explode = function(pos, def)
explode(pos, rad, snd)
end
-- teleport player
local lb_teleport = function(pos, digger, def)
@ -403,6 +381,7 @@ local lb_teleport = function(pos, digger, def)
lucky_block.green .. S("Random Teleport!"))
end
-- drop items
local lb_drop = function(pos, digger, def)
@ -410,8 +389,7 @@ local lb_drop = function(pos, digger, def)
local colours = def[4]
local items = #def[2]
-- drop multiple different items or colours
if items > 1 or colours then
if items > 1 or colours then -- drop multiple different items or colours
for i = 1, num do
@ -460,23 +438,20 @@ local lb_drop = function(pos, digger, def)
end
end
-- lightning bolt
local lb_lightning = function(pos, digger, def)
local nod = def[2]
if not minetest.registered_nodes[nod] then
nod = lucky_block.def_flame
end
if not minetest.registered_nodes[nod] then nod = lucky_block.def_flame end
pos = digger:get_pos()
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
if bref and bref.buildable_to then minetest.set_node(pos, {name = nod}) end
minetest.add_particle({
pos = pos,
@ -492,9 +467,10 @@ local lb_lightning = function(pos, digger, def)
entity_physics(pos, 2)
minetest.sound_play("lightning", {
pos = pos, gain = 1.0, max_hear_distance = 25}, true)
pos = pos, gain = 1.2, max_hear_distance = 30}, true)
end
-- falling nodes
local lb_falling = function(pos, digger, def)
@ -503,9 +479,7 @@ local lb_falling = function(pos, digger, def)
local spread = def[4]
local range = def[5] or 5
if switch == 1 then
pos = digger:get_pos()
end
if switch == 1 then pos = digger:get_pos() end
if spread then
pos.y = pos.y + 10
@ -548,6 +522,7 @@ local lb_falling = function(pos, digger, def)
end
end
-- troll block
local lb_troll = function(pos, def)
@ -555,9 +530,7 @@ local lb_troll = function(pos, def)
local snd = def[3]
local exp = def[4]
if not minetest.registered_nodes[nod] then
nod = lucky_block.def_gold
end
if not minetest.registered_nodes[nod] then nod = lucky_block.def_gold end
minetest.set_node(pos, {name = nod})
@ -567,21 +540,18 @@ local lb_troll = function(pos, def)
minetest.after(2.0, function()
if exp then
minetest.set_node(pos, {name = "air"})
if exp then
explode(pos, 2)
else
minetest.set_node(pos, {name = "air"})
minetest.sound_play(lucky_block.snd_pop, {
pos = pos, gain = 1.0, max_hear_distance = 10}, true)
end
end)
end
-- floor of nodes
local lb_floor = function(pos, def)
@ -613,8 +583,8 @@ local lb_floor = function(pos, def)
end
end
-- this is what happens when you dig a lucky block
function lucky_block:open(pos, digger, blocks_list)
-- check for custom blocks list or use default
@ -624,7 +594,7 @@ function lucky_block:open(pos, digger, blocks_list)
math.randomseed(minetest.get_timeofday() + pos.x + pos.z - os.time())
local luck = math.random(#blocks_list) ; -- luck = 1
local result = blocks_list[luck]
local result = blocks_list[luck] ; if not result then return end
local action = result[1]
-- print ("luck ["..luck.." of "..#blocks_list.."]", action)
@ -665,8 +635,8 @@ function lucky_block:open(pos, digger, blocks_list)
end
end
-- lucky block node
-- lucky block itself
minetest.register_node("lucky_block:lucky_block", {
description = S("Lucky Block"),
tiles = {{
@ -680,7 +650,7 @@ minetest.register_node("lucky_block:lucky_block", {
is_ground_content = false,
paramtype = "light",
light_source = 3,
groups = {handy = 2, oddly_breakable_by_hand = 3, unbreakable = 1},
groups = {handy = 1, oddly_breakable_by_hand = 3, unbreakable = 1},
drop = {},
sounds = lucky_block.snd_wood,
@ -696,10 +666,11 @@ minetest.register_node("lucky_block:lucky_block", {
on_blast = function() end,
_mcl_hardness = 1,
_mcl_hardness = 0.7,
_mcl_blast_resistance = 1200
})
-- lucky block recipe
local gitem = mcl and "mcl_core:gold_ingot" or "default:gold_ingot"
local citem = mcl and "mcl_chests:chest" or "default:chest"
@ -713,16 +684,17 @@ minetest.register_craft({
}
})
-- set default groups for super lucky block and change if mineclone found
local grp = {cracky = 1, level = 2, unbreakable = 1}
-- change super lucky block groups for mineclone
if mcl then
grp.handy = 5
grp.level = nil
end
-- super lucky block
minetest.register_node("lucky_block:super_lucky_block", {
description = S("Super Lucky Block (use pick)"),
tiles = {{
@ -773,28 +745,23 @@ minetest.register_node("lucky_block:super_lucky_block", {
_mcl_blast_resistance = 1200
})
-- get mod path and import blocks
local path = minetest.get_modpath("lucky_block")
-- import schematics
dofile(path .. "/lb_schems.lua")
dofile(path .. "/lb_schems.lua") -- schematics
dofile(path .. "/lb_well.lua") -- wishing well & drops
dofile(path .. "/lb_special.lua") -- special items & drops
-- wishing well & drops
dofile(path .. "/lb_well.lua")
-- lucky block special items and blocks
dofile(path .. "/lb_special.lua")
-- if mineclone detected then load specific lucky blocks
if mcl then
dofile(path .. "/lb_mineclone.lua")
dofile(path .. "/lb_mineclone.lua") -- mineclone only
else
dofile(path .. "/lb_default.lua")
dofile(path .. "/lb_default.lua") -- default drops
end
-- 3rd party mod lucky blocks
dofile(path .. "/lb_other.lua")
dofile(path .. "/lb_other.lua") -- 3rd party mod drops
-- wait until mods loaded and show how many lucky blocks we have in use
minetest.after(0, function()
print("[MOD] Lucky Blocks loaded: ", #lucky_list)

View File

@ -1,8 +1,9 @@
local S = lucky_block.intllib
local S = lucky_block.S
local MP = minetest.get_modpath("lucky_block")
-- default mod
if lucky_block.def_mod then
-- chest items
@ -174,8 +175,8 @@ if lucky_block.def_mod then
})
end
-- wool mod
if minetest.get_modpath("wool") then
lucky_block:add_blocks({
@ -187,6 +188,7 @@ if minetest.get_modpath("wool") then
end
-- Flowers mod
if minetest.get_modpath("flowers") then
lucky_block:add_blocks({
@ -210,6 +212,7 @@ if minetest.get_modpath("flowers") then
end
-- Doors mod
if minetest.get_modpath("doors") then
lucky_block:add_blocks({
@ -228,6 +231,7 @@ if minetest.get_modpath("doors") then
end
-- Screwdriver mod
if minetest.get_modpath("screwdriver") then
if screwdriver and screwdriver.handler then
@ -259,6 +263,7 @@ if minetest.get_modpath("screwdriver") then
end
-- Vessels mod
if minetest.get_modpath("vessels") then
lucky_block:add_blocks({
@ -271,6 +276,7 @@ if minetest.get_modpath("vessels") then
end
-- Farming mod (default)
if minetest.get_modpath("farming") then
lucky_block:add_blocks({
@ -283,6 +289,7 @@ if minetest.get_modpath("farming") then
end
-- Boats mod
if minetest.get_modpath("boats") then
lucky_block:add_blocks({
@ -291,6 +298,7 @@ if minetest.get_modpath("boats") then
end
-- Beds mod
if minetest.get_modpath("beds") then
lucky_block:add_blocks({
@ -300,6 +308,7 @@ if minetest.get_modpath("beds") then
end
-- Walls mod
if minetest.get_modpath("walls") then
lucky_block:add_blocks({
@ -310,8 +319,8 @@ if minetest.get_modpath("walls") then
end
-- Carts mod
if minetest.get_modpath("carts")
or minetest.get_modpath("boost_cart") then
if minetest.get_modpath("carts") or minetest.get_modpath("boost_cart") then
lucky_block:add_blocks({
{"dro", {"carts:cart"}},
@ -322,6 +331,7 @@ or minetest.get_modpath("boost_cart") then
end
-- 3D Armor mod
if minetest.get_modpath("3d_armor") then
lucky_block:add_blocks({
@ -352,6 +362,7 @@ if minetest.get_modpath("3d_armor") then
end
-- 3D Armor's Shields mod
if minetest.get_modpath("shields") then
lucky_block:add_blocks({
@ -365,6 +376,7 @@ if minetest.get_modpath("shields") then
end
-- Fire mod
if minetest.get_modpath("fire") then
lucky_block:add_blocks({
@ -377,6 +389,7 @@ if minetest.get_modpath("fire") then
end
-- TNT mod
if minetest.get_modpath("tnt") then
local p = "tnt:tnt_burning"
@ -389,6 +402,7 @@ if minetest.get_modpath("tnt") then
end
-- More Ore's mod
if minetest.get_modpath("moreores") then
lucky_block:add_blocks({
@ -438,6 +452,7 @@ if minetest.get_modpath("moreores") then
end -- END moreores
-- Bags mod
if minetest.get_modpath("bags") or minetest.get_modpath("sfinv_bags") then
minetest.register_craftitem(":bags:spar", {
@ -456,6 +471,7 @@ if minetest.get_modpath("bags") or minetest.get_modpath("sfinv_bags") then
end
-- Nether Mod
if minetest.get_modpath("nether") then
local p = "nether:"

View File

@ -1,8 +1,10 @@
local S = lucky_block.intllib
local S = lucky_block.S
local mpath = minetest.get_modpath("mcl_core") .. "/schematics/"
local tmp -- helper
-- chest items
lucky_block:add_chest_items({
{name = "mcl_core:wood", max = 5},
{name = "mcl_core:apple", max = 3},
@ -12,10 +14,8 @@ lucky_block:add_chest_items({
{name = "mcl_core:pick_iron", max = 1, chance = 2, min_wear = 20000, max_wear = 65536}
})
local mpath = minetest.get_modpath("mcl_core") .. "/schematics/"
-- Default tree schematics
lucky_block:add_schematics({
{"oaktree1", mpath .. "mcl_core_oak_large_1.mts", {x = 2, y = 1, z = 2}},
-- {"oaktree2", mpath .. "mcl_core_oak_large_2.mts", {x = 1, y = 1, z = 1}},
@ -42,7 +42,8 @@ lucky_block:add_schematics({
-- {"redmushroom2", mpath .. "mcl_mushrooms_giant_red.mts", {x = 1, y = 1, z = 1}}
})
-- mineclone tree's
-- mineclone trees
lucky_block:add_blocks({
{"sch", "oaktree1", 0, false},
{"sch", "oaktreeswamp", 0, false},
@ -57,6 +58,7 @@ lucky_block:add_blocks({
})
-- mineclone lucky blocks
lucky_block:add_blocks({
{"nod", "mcl_chests_small:chest", 0, {
{name = "mcl_core:glass_red", max = 5},
@ -165,6 +167,7 @@ lucky_block:add_blocks({
})
-- Additional Wishing Well Styles
lucky_block:add_blocks({
{"sch", "wishingwell", 0, true, {
{"default:stonebrick", "mcl_core:sandstone"},
@ -176,6 +179,7 @@ lucky_block:add_blocks({
})
-- mcl_crafting_table
if minetest.get_modpath("mcl_crafting_table") then
lucky_block:add_blocks({
@ -185,6 +189,7 @@ if minetest.get_modpath("mcl_crafting_table") then
end
-- mcl_dye
if minetest.get_modpath("mcl_dye") then
lucky_block:add_blocks({
@ -193,6 +198,7 @@ if minetest.get_modpath("mcl_dye") then
end
-- mcl_buckets
if minetest.get_modpath("mcl_buckets") then
lucky_block:add_blocks({
@ -206,6 +212,7 @@ if minetest.get_modpath("mcl_buckets") then
end
-- mcl_books
if minetest.get_modpath("mcl_books") then
lucky_block:add_blocks({
@ -215,6 +222,7 @@ if minetest.get_modpath("mcl_books") then
end
-- mcl_wool
if minetest.get_modpath("mcl_wool") then
lucky_block:add_blocks({
@ -226,6 +234,7 @@ if minetest.get_modpath("mcl_wool") then
end
-- mcl_flowers
if minetest.get_modpath("mcl_flowers") then
tmp = "mcl_flowers:"
@ -261,6 +270,7 @@ if minetest.get_modpath("mcl_flowers") then
end
-- mcl_hoppers
if minetest.get_modpath("mcl_hoppers") then
lucky_block:add_blocks({
@ -269,6 +279,7 @@ if minetest.get_modpath("mcl_hoppers") then
end
-- mcl_doors
if minetest.get_modpath("mcl_doors") then
lucky_block:add_blocks({
@ -291,6 +302,7 @@ if minetest.get_modpath("mcl_doors") then
end
-- mcl_fences
if minetest.get_modpath("mcl_fences") then
tmp = "mcl_fences:"
@ -308,6 +320,7 @@ if minetest.get_modpath("mcl_fences") then
end
-- Screwdriver mod
if minetest.get_modpath("screwdriver") then
if screwdriver and screwdriver.handler then
@ -339,6 +352,7 @@ if minetest.get_modpath("screwdriver") then
end
-- mcl_farming
if minetest.get_modpath("mcl_farming") then
lucky_block:add_blocks({
@ -384,6 +398,7 @@ if minetest.get_modpath("mcl_farming") then
end
-- mcl_boats
if minetest.get_modpath("mcl_boats") then
lucky_block:add_blocks({
@ -393,6 +408,7 @@ if minetest.get_modpath("mcl_boats") then
end
-- mcl_beds
if minetest.get_modpath("mcl_beds") then
lucky_block:add_blocks({
@ -401,6 +417,7 @@ if minetest.get_modpath("mcl_beds") then
end
-- mcl_walls
if minetest.get_modpath("mcl_walls") then
lucky_block:add_blocks({
@ -424,6 +441,7 @@ if minetest.get_modpath("mcl_walls") then
end
-- mcl_minecarts
if minetest.get_modpath("mcl_minecarts") then
lucky_block:add_blocks({
@ -437,6 +455,7 @@ if minetest.get_modpath("mcl_minecarts") then
end
-- mcl_armor
if minetest.get_modpath("mcl_armor") then
tmp = "mcl_armor:"
@ -470,6 +489,7 @@ if minetest.get_modpath("mcl_armor") then
end
-- mcl_fire
if minetest.get_modpath("mcl_fire") then
lucky_block:add_blocks({
@ -481,6 +501,7 @@ if minetest.get_modpath("mcl_fire") then
end
-- mcl_tnt
if minetest.get_modpath("mcl_tnt") then
lucky_block:add_blocks({
@ -492,6 +513,7 @@ if minetest.get_modpath("mcl_tnt") then
end
-- mobs_mc
if minetest.get_modpath("mobs_mc") then
lucky_block:add_blocks({
@ -511,6 +533,7 @@ if minetest.get_modpath("mobs_mc") then
end
-- mcl_mobitems
if minetest.get_modpath("mcl_mobitems") then
tmp = "mcl_mobitems:"
@ -536,6 +559,7 @@ if minetest.get_modpath("mcl_mobitems") then
end
-- mcl_potions
if minetest.get_modpath("mcl_potions") then
tmp = "mcl_potions:"
@ -551,6 +575,7 @@ if minetest.get_modpath("mcl_potions") then
end
-- mcl_torches
if minetest.get_modpath("mcl_torches") then
lucky_block:add_blocks({
@ -560,6 +585,7 @@ if minetest.get_modpath("mcl_torches") then
end
-- mcl_cake
if minetest.get_modpath("mcl_cake") then
lucky_block:add_blocks({
@ -576,6 +602,7 @@ if minetest.get_modpath("mcl_cake") then
end
-- mcl_fishing
if minetest.get_modpath("mcl_fishing") then
tmp = "mcl_fishing:"
@ -588,6 +615,7 @@ if minetest.get_modpath("mcl_fishing") then
end
-- mcl_nether
if minetest.get_modpath("mcl_nether") then
tmp = "mcl_nether:"

View File

@ -1,5 +1,6 @@
-- extra doors mod
if minetest.get_modpath("extra_doors") then
lucky_block:add_blocks({
@ -27,6 +28,7 @@ if minetest.get_modpath("extra_doors") then
end
-- Home Decor mod
if minetest.get_modpath("homedecor") then
lucky_block:add_blocks({
@ -53,6 +55,7 @@ if minetest.get_modpath("homedecor") then
end
-- Caverealms
if minetest.get_modpath("caverealms") then
lucky_block:add_blocks({
@ -66,6 +69,7 @@ if minetest.get_modpath("caverealms") then
end
-- Moreblocks mod
if minetest.get_modpath("moreblocks") then
local p = "moreblocks:"
@ -146,6 +150,7 @@ if minetest.get_modpath("moreblocks") then
end
-- worm farm mod
if minetest.get_modpath("worm_farm") then
lucky_block:add_blocks({

View File

@ -1,8 +1,8 @@
local S = lucky_block.intllib
local S = lucky_block.S
-- custom function (punches player with 5 damage)
local function punchy(pos, player)
player:punch(player, 1.0, {
@ -16,8 +16,8 @@ local function punchy(pos, player)
lucky_block.green .. S("Stop hitting yourself!"))
end
-- custom function (pint sized player) and potion with recipe
local function pint(pos, player)
player:set_properties({
@ -50,10 +50,12 @@ local function pint(pos, player)
end
-- pint sized potion item
minetest.register_craftitem("lucky_block:pint_sized_potion", {
description = S("Pint Sized Potion (DRINK ME)"),
inventory_image = "lucky_pint_sized_potion.png",
groups = {vessel = 1},
on_use = function(itemstack, user, pointed_thing)
itemstack:take_item()
@ -75,6 +77,7 @@ minetest.register_craftitem("lucky_block:pint_sized_potion", {
})
-- pint sized potion recipe (default)
if lucky_block.mod_def then
minetest.register_craft({
@ -87,8 +90,8 @@ if lucky_block.mod_def then
})
end
-- custom function (slender player) and potion with recipe
local function slender(pos, player)
player:set_properties({
@ -121,10 +124,12 @@ local function slender(pos, player)
end
-- slender player potion item
minetest.register_craftitem("lucky_block:slender_player_potion", {
description = S("Slender Player Potion (DRINK ME)"),
inventory_image = "lucky_slender_potion.png",
groups = {vessel = 1},
on_use = function(itemstack, user, pointed_thing)
itemstack:take_item()
@ -146,6 +151,7 @@ minetest.register_craftitem("lucky_block:slender_player_potion", {
})
-- slender player potion recipe
if lucky_block.mod_def then
minetest.register_craft({
@ -158,8 +164,8 @@ if lucky_block.mod_def then
})
end
-- lightning staff
minetest.register_tool("lucky_block:lightning_staff", {
description = S("Lightning Staff"),
inventory_image = "lucky_lightning_staff.png",
@ -240,8 +246,8 @@ minetest.register_tool("lucky_block:lightning_staff", {
end
})
-- custom function (drop player inventory and replace with items and show msg)
local function dropsy(pos, player, def)
local player_inv = player:get_inventory()
@ -267,10 +273,11 @@ local function dropsy(pos, player, def)
minetest.chat_send_player(player:get_player_name(), lucky_block.green .. S(def.msg))
end
local tex = lucky_block.mod_mcl and "default_glass.png" or "default_obsidian_glass.png^[brighten"
-- void mirror block (place to see through solid walls)
local tex = lucky_block.mod_mcl and "default_glass.png"
or "default_obsidian_glass.png^[brighten"
minetest.register_node("lucky_block:void_mirror", {
description = S("Void Mirror (Place to see through solid walls during daytime)"),
drawtype = "normal",
@ -281,8 +288,8 @@ minetest.register_node("lucky_block:void_mirror", {
_mcl_hardness = 0.6
})
-- Troll item drop
local function fake_items(pos, player, def)
for n = 1, 25 do
@ -310,8 +317,8 @@ local function fake_items(pos, player, def)
lucky_block.green .. S("Wow! So many faux " .. def.txt .. "!"))
end
-- Void Pick (disable for mineclone since it has silk touch tools)
if not lucky_block.mod_mcl then
local old_handle_node_drops = minetest.handle_node_drops
@ -346,9 +353,7 @@ if not lucky_block.mod_mcl then
max_drop_level = 3,
groupcaps = {
cracky = {
times = {[1] = 2.4, [2] = 1.2, [3] = 0.60},
uses = 20,
maxlevel = 3
times = {[1] = 2.4, [2] = 1.2, [3] = 0.60}, uses = 20, maxlevel = 3
}
},
damage_groups = {fleshy = 5},
@ -359,6 +364,7 @@ if not lucky_block.mod_mcl then
end
-- add custom functions and special drops
lucky_block:add_blocks({
{"cus", pint},
{"cus", punchy},
@ -368,8 +374,8 @@ lucky_block:add_blocks({
{"dro", {"lucky_block:void_mirror"}}
})
-- custom items for default mod
if lucky_block.mod_def then
lucky_block:add_blocks({
@ -398,12 +404,11 @@ if lucky_block.mod_def then
})
end
-- pova mod effects
if minetest.get_modpath("pova") then
-- slowmo effect
local function slowmo(pos, player, def)
local function slowmo(pos, player, def) -- slowmo effect
local name = player:get_player_name()
@ -424,8 +429,7 @@ if minetest.get_modpath("pova") then
end, player)
end
-- high jump effect
local function highfly(pos, player, def)
local function highfly(pos, player, def) -- high jump effect
local name = player:get_player_name()

View File

@ -1,5 +1,6 @@
-- well block (player stands near and it triggers drops)
minetest.register_node("lucky_block:well_block", {
description = "Well Block",
tiles = {"default_glass.png"},
@ -9,8 +10,8 @@ minetest.register_node("lucky_block:well_block", {
drop = {}
})
-- wishing well schematic layout
local stb = {name = "default:steelblock", param1 = 255}
local sbr = {name = "default:stonebrick", param1 = 255}
local fwd = {name = "default:fence_wood", param1 = 255}
@ -43,18 +44,18 @@ local wishing_well = {
}
}
-- add schematic to list
lucky_block:add_schematics({
{"wishingwell", wishing_well, {x = 1, y = 1, z = 1}}
})
-- Global list containing well blocks that can be dropped
lucky_block.wellblocks = {}
-- helper function
local add_wblock = function(list)
for s = 1, #list do
@ -62,6 +63,7 @@ local add_wblock = function(list)
end
end
-- add default well blocks
if lucky_block.mod_def then
@ -106,6 +108,8 @@ if lucky_block.mod_def then
})
end
-- tnt mod
if minetest.get_modpath("tnt") then
add_wblock({
@ -115,6 +119,8 @@ if minetest.get_modpath("tnt") then
})
end
-- ethereal
if minetest.get_modpath("ethereal") then
add_wblock({
@ -122,6 +128,8 @@ if minetest.get_modpath("ethereal") then
})
end
-- bones
if minetest.get_modpath("bones") then
add_wblock({
@ -129,6 +137,8 @@ if minetest.get_modpath("bones") then
})
end
-- mineclone
if lucky_block.mod_mcl then
add_wblock({
@ -145,8 +155,8 @@ if lucky_block.mod_mcl then
})
end
-- abm function to detect player and trigger drops
minetest.register_abm({
label = "Lucky Block Wishing Well Block",
nodenames = {"lucky_block:well_block"},

View File

@ -1,15 +1,9 @@
# textdomain: lucky_block
# author:
# last update: 2017/Aug/28
### init.lua ###
Stop hitting yourself!=Прекратите удары себя
Dry shrub takeover!=Поглощение сухих кустов
Random teleport!=Случайный телепорт!
Lucky Block=Удачливый блок
Super Lucky Block (use pick)=Супер удачливый блок (используйте кирку)
[MOD] Lucky Blocks loaded (@1 in total)=[MOD] Удачливый блок нагруженный (Всего @1)
### blocks.lua ###
Super Mega Magenta Ultra Screwdriver 2500\n(left-click to rotate face, right-click to rotates axis)"=Пурпурная супер мега ультра отвёртка 2500\n(левая кнопка для вращения лицевой части, правая кнопка для вращения осей)
Void Mirror (Place to see through solid walls during daytime=Пустое зеркало (Установите, чтобы видеть сквозь сплошные стены в дневное время)

View File

@ -1,4 +1,4 @@
name = lucky_block
depends =
optional_depends = default, mcl_core, mcl_sounds, tnt, screwdriver, pova
description = Adds lucky blocks into the game which may give good, bad, hurtful items when open :)
optional_depends = default, mcl_core, mcl_sounds, tnt, screwdriver, pova
min_minetest_version = 5.0