add blocks for bags and bonemeal mods, fix dry shrub takeover position

This commit is contained in:
TenPlus1 2017-06-08 14:36:57 +01:00
parent 94a64db889
commit b12e8ce2f4
2 changed files with 57 additions and 10 deletions

@ -55,7 +55,7 @@ lucky_block:add_blocks({
"default:fence_junglewood", "default:fence_pine_wood"}, 15},
})
-- default dev blocks
-- default coral blocks
if minetest.registered_nodes["default:coral_brown"] then
lucky_block:add_blocks({
{"dro", {"default:coral_brown", "default:coral_orange", "default:coral_skeleton"}, 5},
@ -63,6 +63,7 @@ if minetest.registered_nodes["default:coral_brown"] then
})
end
-- default mese post light or sands
if minetest.registered_nodes["default:mese_post_light"] then
lucky_block:add_blocks({
{"dro", {"default:mese_post_light", "default:fence_wood"}, 5},
@ -104,7 +105,7 @@ if minetest.get_modpath("farming") then
{"nod", "default:water_source", 1},
})
end -- END farming mod
end
-- Home Decor mod
if minetest.get_modpath("homedecor") then
@ -209,7 +210,7 @@ lucky_block:add_blocks({
})
end
end
end -- END moreores
-- Bows mod
if minetest.get_modpath("bows") then
@ -223,3 +224,17 @@ lucky_block:add_blocks({
{"dro", {"bows:arrow_diamond"}, 5},
})
end
-- Bags mod
if minetest.get_modpath("bags") then
lucky_block:add_blocks({
{"dro", {"bags:small", "bags:medium", "bags:large", "bags:trolley"}, 1},
})
end
-- Bonemeal mod
if minetest.get_modpath("bonemeal") then
lucky_block:add_blocks({
{"dro", {"bonemeal:mulch", "bonemeal:bonemeal", "bonemeal:fertiliser"}, 8},
})
end

@ -3,18 +3,25 @@ lucky_block = {}
lucky_schems = {}
lucky_block.seed = PseudoRandom(os.time())
-- example custom function (punches player with 5 damage)
local function punchy(pos, player)
player:punch(player, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 5}
}, nil)
minetest.chat_send_player(player:get_player_name(), "Stop hitting yourself!")
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,
@ -23,16 +30,21 @@ local function drop(pos, itemstack)
end
end
-- custom function to drop player inventory and replace with dry shrubs
local function bushy(pos, player)
local player_inv = player:get_inventory()
local player_inv = player:get_inventory() ; pos = player:getpos() or pos
for i = 1, player_inv:get_size("main") do
drop(pos, player_inv:get_stack("main", i))
player_inv:set_stack("main", i, "default:dry_shrub")
end
minetest.chat_send_player(player:get_player_name(), "Dry Shrub Takeover!")
end
-- default blocks
local lucky_list = {
{"cus", bushy},
@ -43,6 +55,7 @@ local lucky_list = {
{"exp", 2, true},
}
-- ability to add new blocks to list
function lucky_block:add_blocks(list)
@ -51,6 +64,7 @@ function lucky_block:add_blocks(list)
end
end
-- call to purge the block list
function lucky_block:purge_block_list()
lucky_list = {
@ -58,6 +72,7 @@ function lucky_block:purge_block_list()
}
end
-- add schematics to global list
function lucky_block:add_schematics(list)
@ -66,10 +81,12 @@ function lucky_block:add_schematics(list)
end
end
-- import schematics and default blocks
dofile(minetest.get_modpath("lucky_block") .. "/schems.lua")
dofile(minetest.get_modpath("lucky_block") .. "/blocks.lua")
-- for random colour selection
local all_colours = {
"grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta",
@ -85,12 +102,14 @@ local chest_stuff = {
{name = "default:pick_steel", max = 1}
}
-- call to purge the chest items list
function lucky_block:purge_chest_items()
chest_stuff = {}
end
-- ability to add chest items
-- ability to add to chest items list
function lucky_block:add_chest_items(list)
for s = 1, #list do
@ -98,6 +117,7 @@ function lucky_block:add_chest_items(list)
end
end
-- particle effects
function effect(pos, amount, texture, max_size)
@ -118,6 +138,7 @@ function effect(pos, amount, texture, max_size)
})
end
-- modified from TNT mod to deal entity damage only
function entity_physics(pos, radius)
@ -144,13 +165,14 @@ function entity_physics(pos, radius)
objs[n]:punch(objs[n], 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = damage},
}, nil)
}, pos) -- nil)
end
end
end
-- get node but use fallback for nil or unknown
function node_ok(pos, fallback)
@ -171,6 +193,7 @@ function node_ok(pos, fallback)
return minetest.registered_nodes[fallback]
end
-- set content id's
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
@ -238,6 +261,8 @@ function explosion(pos, radius, fire)
end
end
-- fill chest with random items from list
function fill_chest(pos, items)
local stacks = items or {}
@ -257,14 +282,15 @@ function fill_chest(pos, items)
end
end
-- this is what happens when you dig a lucky block
local lucky_block = function(pos, digger)
local luck = math.random(1, #lucky_list) ; -- luck = 1
local luck = math.random(1, #lucky_list) ; -- luck = 6
local action = lucky_list[luck][1]
local schem
print ("luck ["..luck.." of "..#lucky_list.."]", action)
-- print ("luck ["..luck.." of "..#lucky_list.."]", action)
-- place schematic
if action == "sch" then
@ -279,14 +305,14 @@ local lucky_block = function(pos, digger)
local force = lucky_list[luck][4]
if switch == 1 then
pos = vector.round( digger:getpos() )
pos = vector.round(digger:getpos())
end
for i = 1, #lucky_schems do
if schem == lucky_schems[i][1] then
local p1 = vector.subtract(pos, lucky_schems[i][3])
local p1 = vector.subtract(pos, lucky_schems[i][3])
minetest.place_schematic(p1, lucky_schems[i][2], "", {}, force)
@ -425,6 +451,7 @@ local lucky_block = function(pos, digger)
local obj = minetest.add_item(pos, item)
if obj then
obj:setvelocity({
x = math.random(-10, 10) / 9,
y = 5,
@ -559,6 +586,7 @@ local lucky_block = function(pos, digger)
end
end
-- lucky block itself
minetest.register_node('lucky_block:lucky_block', {
description = "Lucky Block",
@ -594,6 +622,7 @@ minetest.register_craft({
}
})
-- super lucky block
minetest.register_node('lucky_block:super_lucky_block', {
description = "Super Lucky Block (use Pick)",
@ -637,6 +666,7 @@ minetest.register_node('lucky_block:super_lucky_block', {
end,
})
-- used to drop items inside a chest or container
local drop_items = function(pos, invstring)
@ -660,6 +690,7 @@ local drop_items = function(pos, invstring)
end
-- override chest node so it drops items on explode
minetest.override_item("default:chest", {
@ -675,6 +706,7 @@ minetest.override_item("default:chest", {
})
minetest.after(0, function()
print ("[MOD] Lucky Blocks loaded (" .. #lucky_list .. " in total)")
end)