First upload

master
DonBatman 2016-06-27 09:11:16 -07:00
commit 69b4d5a675
18 changed files with 558 additions and 0 deletions

6
Readme.md Normal file
View File

@ -0,0 +1,6 @@
#myregenchest
Chests that will spawn items when the chest is opened. The chest will close after a set amount of time. After it closes you can open again and the items will spawn again.
Licence - DWYWPL

130
armor_chest.lua Normal file
View File

@ -0,0 +1,130 @@
local time_between_regen = 120 --time in seconds between the time the chest is opened and when it closes to be used again
local items = { --the number is the chance of spawning. 1 means everytime. 3 means 1 in3 chance of spawning
{5, "3d_armor:helmet_wood"},
{5, "3d_armor:chestplate_wood"},
{5, "3d_armor:leggings_wood"},
{5, "3d_armor:boots_wood"},
{500, "3d_armor:chestplate_diamond"},
}
local item_spawn = function(pos, node)
for i in ipairs(items)do
local r = items[i][1]
local i = items[i][2]
local rand = math.random(r)
if rand == 1 then minetest.spawn_item({x=pos.x,y=pos.y+0.5,z=pos.z}, i) end
end
minetest.set_node(pos, {name="myregenchest:armor_chest_open", param2=node.param2})
local timer = minetest.get_node_timer(pos)
timer:start(time_between_regen)
minetest.swap_node(pos, {name="myregenchest:armor_chest_open", param2=node.param2})
end
local check_air = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if nodea.name ~= "air" then
minetest.chat_send_player( placer:get_player_name(), "Need room above chest" )
return
end
return minetest.item_place(itemstack, placer, pointed_thing)
end
local dig_it = function(pos, node, digger)
if minetest.get_player_privs(digger:get_player_name()).myregenchest ~= true then
minetest.chat_send_player( digger:get_player_name(), "You do not have the privelege to remove the chest" )
return
end
end
local closed_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.3125, 0.5, 0.3125, 0.375},
}
}
local open_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.3125, 0.5, -0.1875, 0.375},
{-0.5, -0.5, 0.3125, 0.5, 0.1875, 0.375},
{-0.5, -0.5, -0.3125, -0.4375, 0.1875, 0.375},
{0.4375, -0.5, -0.3125, 0.5, 0.1875, 0.375},
{-0.5, -0.5, -0.3125, 0.5, 0.1875, -0.25},
{-0.5, 0.1875, 0.4375, 0.5, 0.875, 0.5},
{-0.5, 0.1875, 0.375, 0.5, 0.25, 0.5},
{-0.5, 0.8125, 0.375, 0.5, 0.875, 0.5},
{-0.5, 0.1875, 0.375, -0.4375, 0.875, 0.5},
{0.4375, 0.1875, 0.375, 0.5, 0.875, 0.5},
}
}
minetest.register_node("myregenchest:armor_chest", {
description = "Armor Chest",
tiles = {
"myitemchest_chest_top.png",
"myitemchest_chest_top.png",
"myitemchest_chest_side.png^[transformFX",
"myitemchest_chest_side.png",
"myitemchest_chest_back.png",
"myitemchest_chest_front.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {choppy = 2},
sounds = default.node_sound_wood_defaults(),
node_box = closed_box,
selection_box = closed_box,
on_place = check_air,
on_rightclick = item_spawn,
on_dig = dig_it,
})
minetest.register_node("myregenchest:armor_chest_open", {
description = "Armor Chest Open",
tiles = {
"myitemchest_chest_open_top.png",
"myitemchest_chest_open_top.png",
"myitemchest_chest_side.png^[transformFx",
"myitemchest_chest_side.png",
"myitemchest_chest_back.png",
"myitemchest_chest_front_open.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
drop = "myregenchest:armor_chest",
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
node_box = open_box,
selection_box = open_box,
on_timer = function(pos, elapsed)
local timer = minetest.get_node_timer(pos)
local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = "myregenchest:armor_chest", param2=node.param2})
local all_objects = minetest.get_objects_inside_radius(pos, 0.5)
local players = {}
local _,obj
for _,obj in ipairs(all_objects) do
if obj:is_player() == false then
obj:remove()
end
end
end,
})

3
depends.txt Normal file
View File

@ -0,0 +1,3 @@
default
farming
3d_armor?

1
description.txt Normal file
View File

@ -0,0 +1 @@
A chest the spawns items when opened.

130
food_chest.lua Normal file
View File

@ -0,0 +1,130 @@
local time_between_regen = 120 --time in seconds between the time the chest is opened and when it closes to be used again
local items = { --the number is the chance of spawning. 1 means everytime. 3 means 1 in3 chance of spawning
{1, "default:apple 4"},
{3, "default:apple 4"},
{1, "farming:bread 1"},
{10, "farming:bread 2"},
{500, "default:axe_steel"},
}
local item_spawn = function(pos, node)
for i in ipairs(items)do
local r = items[i][1]
local i = items[i][2]
local rand = math.random(r)
if rand == 1 then minetest.spawn_item({x=pos.x,y=pos.y+0.5,z=pos.z}, i) end
end
minetest.set_node(pos, {name="myregenchest:food_chest_open", param2=node.param2})
local timer = minetest.get_node_timer(pos)
timer:start(time_between_regen)
minetest.swap_node(pos, {name="myregenchest:food_chest_open", param2=node.param2})
end
local check_air = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if nodea.name ~= "air" then
minetest.chat_send_player( placer:get_player_name(), "Need room above chest" )
return
end
return minetest.item_place(itemstack, placer, pointed_thing)
end
local dig_it = function(pos, node, digger)
if minetest.get_player_privs(digger:get_player_name()).myregenchest ~= true then
minetest.chat_send_player( digger:get_player_name(), "You do not have the privelege to remove the chest" )
return
end
end
local closed_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.3125, 0.5, 0.3125, 0.375},
}
}
local open_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.3125, 0.5, -0.1875, 0.375},
{-0.5, -0.5, 0.3125, 0.5, 0.1875, 0.375},
{-0.5, -0.5, -0.3125, -0.4375, 0.1875, 0.375},
{0.4375, -0.5, -0.3125, 0.5, 0.1875, 0.375},
{-0.5, -0.5, -0.3125, 0.5, 0.1875, -0.25},
{-0.5, 0.1875, 0.4375, 0.5, 0.875, 0.5},
{-0.5, 0.1875, 0.375, 0.5, 0.25, 0.5},
{-0.5, 0.8125, 0.375, 0.5, 0.875, 0.5},
{-0.5, 0.1875, 0.375, -0.4375, 0.875, 0.5},
{0.4375, 0.1875, 0.375, 0.5, 0.875, 0.5},
}
}
minetest.register_node("myregenchest:food_chest", {
description = "Food Chest",
tiles = {
"myitemchest_chest_top.png",
"myitemchest_chest_top.png",
"myitemchest_chest_side.png^[transformFX",
"myitemchest_chest_side.png",
"myitemchest_chest_back.png",
"myitemchest_chest_front.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {choppy = 2},
sounds = default.node_sound_wood_defaults(),
node_box = closed_box,
selection_box = closed_box,
on_place = check_air,
on_rightclick = item_spawn,
on_dig = dig_it,
})
minetest.register_node("myregenchest:food_chest_open", {
description = "Food Chest Open",
tiles = {
"myitemchest_chest_open_top.png",
"myitemchest_chest_open_top.png",
"myitemchest_chest_side.png^[transformFx",
"myitemchest_chest_side.png",
"myitemchest_chest_back.png",
"myitemchest_chest_front_open.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
drop = "myregenchest:chest",
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
node_box = open_box,
selection_box = open_box,
on_timer = function(pos, elapsed)
local timer = minetest.get_node_timer(pos)
local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = "myregenchest:food_chest", param2=node.param2})
local all_objects = minetest.get_objects_inside_radius(pos, 0.5)
local players = {}
local _,obj
for _,obj in ipairs(all_objects) do
if obj:is_player() == false then
obj:remove()
end
end
end,
})

14
init.lua Normal file
View File

@ -0,0 +1,14 @@
dofile(minetest.get_modpath("myregenchest").."/food_chest.lua")
dofile(minetest.get_modpath("myregenchest").."/tools_chest.lua")
dofile(minetest.get_modpath("myregenchest").."/weapons_chest.lua")
if minetest.get_modpath("3d_armor") then
dofile(minetest.get_modpath("myregenchest").."/armor_chest.lua")
end
--priv to destroy chest
minetest.register_privilege("myregenchest", {
description = "Only people with priv can destroy chest",
give_to_singleplayer = false
})

13
licence.txt Normal file
View File

@ -0,0 +1,13 @@
DO WHAT YOU WANT TO PUBLIC LICENSE
or abbreviated DWYWPL
December 2nd 2015
License Copyright (C) 2015 Michael Tomaino (PlatinumArts@gmail.com)
www.sandboxgamemaker.com/DWYWPL/
DO WHAT YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
1. You are allowed to do whatever you want to with what content is using this license.
2. This content is provided 'as-is', without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this content.

2
mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = myregenchest
tags = chest, surprise

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

130
tools_chest.lua Normal file
View File

@ -0,0 +1,130 @@
local time_between_regen = 120 --time in seconds between the time the chest is opened and when it closes to be used again
local items = { --the number is the chance of spawning. 1 means everytime. 3 means 1 in3 chance of spawning
{1, "default:axe_wood"},
{3, "default:pick_wood"},
{1, "default:sword_wood"},
{10, "default:shovel_wood"},
{100, "default:axe_steel"},
}
local item_spawn = function(pos, node)
for i in ipairs(items)do
local r = items[i][1]
local i = items[i][2]
local rand = math.random(r)
if rand == 1 then minetest.spawn_item({x=pos.x,y=pos.y+0.5,z=pos.z}, i) end
end
minetest.set_node(pos, {name="myregenchest:tools_chest_open", param2=node.param2})
local timer = minetest.get_node_timer(pos)
timer:start(time_between_regen)
minetest.swap_node(pos, {name="myregenchest:tools_chest_open", param2=node.param2})
end
local check_air = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if nodea.name ~= "air" then
minetest.chat_send_player( placer:get_player_name(), "Need room above chest" )
return
end
return minetest.item_place(itemstack, placer, pointed_thing)
end
local dig_it = function(pos, node, digger)
if minetest.get_player_privs(digger:get_player_name()).myregenchest ~= true then
minetest.chat_send_player( digger:get_player_name(), "You do not have the privelege to remove the chest" )
return
end
end
local closed_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.3125, 0.5, 0.3125, 0.375},
}
}
local open_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.3125, 0.5, -0.1875, 0.375},
{-0.5, -0.5, 0.3125, 0.5, 0.1875, 0.375},
{-0.5, -0.5, -0.3125, -0.4375, 0.1875, 0.375},
{0.4375, -0.5, -0.3125, 0.5, 0.1875, 0.375},
{-0.5, -0.5, -0.3125, 0.5, 0.1875, -0.25},
{-0.5, 0.1875, 0.4375, 0.5, 0.875, 0.5},
{-0.5, 0.1875, 0.375, 0.5, 0.25, 0.5},
{-0.5, 0.8125, 0.375, 0.5, 0.875, 0.5},
{-0.5, 0.1875, 0.375, -0.4375, 0.875, 0.5},
{0.4375, 0.1875, 0.375, 0.5, 0.875, 0.5},
}
}
minetest.register_node("myregenchest:tools_chest", {
description = "Tools Chest",
tiles = {
"myitemchest_chest_top.png",
"myitemchest_chest_top.png",
"myitemchest_chest_side.png^[transformFX",
"myitemchest_chest_side.png",
"myitemchest_chest_back.png",
"myitemchest_chest_front.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {choppy = 2},
sounds = default.node_sound_wood_defaults(),
node_box = closed_box,
selection_box = closed_box,
on_place = check_air,
on_rightclick = item_spawn,
on_dig = dig_it,
})
minetest.register_node("myregenchest:tools_chest_open", {
description = "Tools Chest Open",
tiles = {
"myitemchest_chest_open_top.png",
"myitemchest_chest_open_top.png",
"myitemchest_chest_side.png^[transformFx",
"myitemchest_chest_side.png",
"myitemchest_chest_back.png",
"myitemchest_chest_front_open.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
drop = "myregenchest:chest",
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
node_box = open_box,
selection_box = open_box,
on_timer = function(pos, elapsed)
local timer = minetest.get_node_timer(pos)
local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = "myregenchest:tools_chest", param2=node.param2})
local all_objects = minetest.get_objects_inside_radius(pos, 0.5)
local players = {}
local _,obj
for _,obj in ipairs(all_objects) do
if obj:is_player() == false then
obj:remove()
end
end
end,
})

129
weapons_chest.lua Normal file
View File

@ -0,0 +1,129 @@
local time_between_regen = 120 --time in seconds between the time the chest is opened and when it closes to be used again
local items = { --the number is the chance of spawning. 1 means everytime. 3 means 1 in3 chance of spawning
{1, "default:sword_wood"},
{10, "default:sword_steel"},
{10, "default:sword_bronze"},
{50, "default:sword_diamond"},
}
local item_spawn = function(pos, node)
for i in ipairs(items)do
local r = items[i][1]
local i = items[i][2]
local rand = math.random(r)
if rand == 1 then minetest.spawn_item({x=pos.x,y=pos.y+0.5,z=pos.z}, i) end
end
minetest.set_node(pos, {name="myregenchest:weapons_chest_open", param2=node.param2})
local timer = minetest.get_node_timer(pos)
timer:start(time_between_regen)
minetest.swap_node(pos, {name="myregenchest:weapons_chest_open", param2=node.param2})
end
local check_air = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if nodea.name ~= "air" then
minetest.chat_send_player( placer:get_player_name(), "Need room above chest" )
return
end
return minetest.item_place(itemstack, placer, pointed_thing)
end
local dig_it = function(pos, node, digger)
if minetest.get_player_privs(digger:get_player_name()).myregenchest ~= true then
minetest.chat_send_player( digger:get_player_name(), "You do not have the privelege to remove the chest" )
return
end
end
local closed_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.3125, 0.5, 0.3125, 0.375},
}
}
local open_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.3125, 0.5, -0.1875, 0.375},
{-0.5, -0.5, 0.3125, 0.5, 0.1875, 0.375},
{-0.5, -0.5, -0.3125, -0.4375, 0.1875, 0.375},
{0.4375, -0.5, -0.3125, 0.5, 0.1875, 0.375},
{-0.5, -0.5, -0.3125, 0.5, 0.1875, -0.25},
{-0.5, 0.1875, 0.4375, 0.5, 0.875, 0.5},
{-0.5, 0.1875, 0.375, 0.5, 0.25, 0.5},
{-0.5, 0.8125, 0.375, 0.5, 0.875, 0.5},
{-0.5, 0.1875, 0.375, -0.4375, 0.875, 0.5},
{0.4375, 0.1875, 0.375, 0.5, 0.875, 0.5},
}
}
minetest.register_node("myregenchest:weapons_chest", {
description = "Weapons Chest",
tiles = {
"myitemchest_chest_top.png",
"myitemchest_chest_top.png",
"myitemchest_chest_side.png^[transformFX",
"myitemchest_chest_side.png",
"myitemchest_chest_back.png",
"myitemchest_chest_front.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {choppy = 2},
sounds = default.node_sound_wood_defaults(),
node_box = closed_box,
selection_box = closed_box,
on_place = check_air,
on_rightclick = item_spawn,
on_dig = dig_it,
})
minetest.register_node("myregenchest:weapons_chest_open", {
description = "Weapons Chest Open",
tiles = {
"myitemchest_chest_open_top.png",
"myitemchest_chest_open_top.png",
"myitemchest_chest_side.png^[transformFx",
"myitemchest_chest_side.png",
"myitemchest_chest_back.png",
"myitemchest_chest_front_open.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
drop = "myregenchest:chest",
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
node_box = open_box,
selection_box = open_box,
on_timer = function(pos, elapsed)
local timer = minetest.get_node_timer(pos)
local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = "myregenchest:weapons_chest", param2=node.param2})
local all_objects = minetest.get_objects_inside_radius(pos, 0.5)
local players = {}
local _,obj
for _,obj in ipairs(all_objects) do
if obj:is_player() == false then
obj:remove()
end
end
end,
})