From ae31b9afdeb26a9a8430a202af8d7cf375e7d6f3 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Wed, 30 Sep 2015 11:19:47 +0100 Subject: [PATCH] Added new api commands --- README.md | 1 + api.txt | 25 +++++++++++++++++++++++++ init.lua | 21 ++++++++++++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f858188..d55d81f 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,4 @@ https://forum.minetest.net/viewtopic.php?f=9&t=13284 Released under WTFPL 0.1 - Initial release +0.2 - New api commands added thanks to blert2112 diff --git a/api.txt b/api.txt index df17164..f6b5cb2 100644 --- a/api.txt +++ b/api.txt @@ -123,3 +123,28 @@ Add gold block with wood sound, then after 2 seconds remove with pop -= Lightning Strike (no settings, Lucky Block is hit by lightning and deals damage) {"lig"} + + +Additional Commands thanks to blert2112 + +lucky_block:purge_block_list() + +This removes all pre-defined lucky blocks and leaves the super lucky block. + + +lucky_block:purge_chest_items() + +This removes all pre-defined chest_stuff items and leaves it empty. + + +lucky_block:add_chest_items(list) + +This command adds items to the chest_stuff list for use inside of lucky chests: + +lucky_block:add_chest_items({ + {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} +}) diff --git a/init.lua b/init.lua index b0d2b16..5df6006 100644 --- a/init.lua +++ b/init.lua @@ -14,7 +14,12 @@ function lucky_block:add_blocks(list) end end --- import blocks +-- call to purge the block list +function lucky_block:purge_block_list() + lucky_list = {{"nod", "lucky_block:super_lucky_block", 0}} +end + +-- import default blocks dofile(minetest.get_modpath("lucky_block").."/blocks.lua") -- for random colour selection @@ -32,6 +37,18 @@ 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 +function lucky_block:add_chest_items(list) + for s = 1, #list do + table.insert(chest_stuff, list[s]) + end +end + -- particle effects function effect(pos, amount, texture, max_size) minetest.add_particlespawner({ @@ -82,7 +99,6 @@ end -- explosion function explosion(pos, radius) - local pos = vector.round(pos) local vm = VoxelManip() local minp, maxp = vm:read_from_map(vector.subtract(pos, radius), vector.add(pos, radius)) @@ -148,7 +164,6 @@ function explosion(pos, radius) end function fill_chest(pos, items) - local stacks = items or {} local meta = minetest.get_meta(pos) local inv = meta:get_inventory()