Merge branch 'master' into inventory
|
@ -1,23 +1,6 @@
|
|||
--{{{ Wear clothing (on_place)
|
||||
local function put_on(item, player)
|
||||
local wname = item:get_name()
|
||||
item = player:get_inventory():add_item("wear", item)
|
||||
minetest.log("action",
|
||||
player:get_player_name() ..
|
||||
" puts on a " ..
|
||||
wname
|
||||
)
|
||||
|
||||
default.player_set_textures(player, {generate_skin(player)})
|
||||
minetest.log("action",
|
||||
"update skin for player " ..
|
||||
player:get_player_name()
|
||||
)
|
||||
|
||||
return item
|
||||
end
|
||||
|
||||
function generate_skin(player)
|
||||
clothing = {}
|
||||
--{{{ Wear clothing
|
||||
clothing.update_skin = function(player)
|
||||
local weared = player:get_inventory():get_list("wear")
|
||||
local skin = default.player_get_animation(player).textures[1]
|
||||
for _,itemstack in ipairs(weared) do
|
||||
|
@ -25,19 +8,19 @@ function generate_skin(player)
|
|||
skin = skin .. "^" .. itemstack:get_definition().wear_image
|
||||
end
|
||||
end
|
||||
return skin
|
||||
default.player_set_textures(player, {skin})
|
||||
minetest.log("action",
|
||||
"update skin for player " ..
|
||||
player:get_player_name()
|
||||
)
|
||||
end
|
||||
--}}}
|
||||
|
||||
--{{{ Save data
|
||||
--{{{ Save and restore data
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
default.player_set_textures(player, {generate_skin(player)})
|
||||
clothing.update_skin(player)
|
||||
end)
|
||||
|
||||
--minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
-- print("DEBUG:", player, dump(formname), dump(fields))
|
||||
--end)
|
||||
|
||||
minetest.register_on_newplayer(function(player)
|
||||
-- Add inventory list for clothing
|
||||
player:get_inventory():set_list("wear", {})
|
||||
|
@ -48,14 +31,11 @@ end)
|
|||
--{{{ Cloth
|
||||
-- Required values is:
|
||||
-- "wear_image" (this image is adding on player skin)
|
||||
-- "on_place" (this is obvious)
|
||||
minetest.register_craftitem("clothing:test", {
|
||||
decription = "Test cloth",
|
||||
inventory_image = "clothing_test.png",
|
||||
wield_image = "clothing_test.png",
|
||||
wear_image = "clothing_test.png",
|
||||
stack_max = 1,
|
||||
|
||||
on_place = put_on
|
||||
})
|
||||
--}}}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
real_locks
|
|
@ -0,0 +1,440 @@
|
|||
-- TODO
|
||||
INVENTORY_W = 8
|
||||
INVENTORY_H = 4
|
||||
|
||||
containers = {
|
||||
["containers:chest"] = { w = 8, h = 4 },
|
||||
["containers:chest_locked"] = { w = 8, h = 4 },
|
||||
["containers:wood_bin"] = { w = 6, h = 3 },
|
||||
["containers:wood_bin_locked"] = { w = 6, h = 3 },
|
||||
["containers:wood_jbox"] = { w = 4, h = 2 },
|
||||
["containers:wood_jbox_locked"] = { w = 4, h = 2 },
|
||||
y_offset = 0.2,
|
||||
inventory_margin = 0.72,
|
||||
hotbar_margin = 0.23,
|
||||
}
|
||||
|
||||
--{{{ Functions
|
||||
|
||||
local function get_container_formspec(pos, name)
|
||||
-- Prepare coord of metadata
|
||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||
|
||||
-- Add aliases for container inventory width and height
|
||||
local w,h = containers[name].w, containers[name].h
|
||||
|
||||
-- Get label for container inventory
|
||||
local label = minetest.registered_nodes[name].description
|
||||
|
||||
-- Calculate formspec width and height
|
||||
local form_w = math.max(INVENTORY_W, w)
|
||||
local form_h = INVENTORY_H + h + 1
|
||||
|
||||
-- Calculate offset for container inventory
|
||||
local x_offset = (INVENTORY_W - w)/2
|
||||
local y_offset = containers.y_offset
|
||||
|
||||
-- Calculate player inventory position,
|
||||
-- player hotbar position and "Inventory" label position
|
||||
local inv_y = h + y_offset + containers.inventory_margin
|
||||
local label_y = inv_y - y_offset - 0.4
|
||||
local hb_y = inv_y + INVENTORY_H - 1 + containers.hotbar_margin
|
||||
|
||||
-- Construct formspec string
|
||||
local formspec =
|
||||
"size["..form_w..","..form_h.."]"..
|
||||
"label[0,-0.4;"..label.."]"..
|
||||
"label[0,"..label_y..";Inventory]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"list[nodemeta:"..spos..";main;"..
|
||||
x_offset..","..y_offset..";"..
|
||||
w..","..h..
|
||||
";]"..
|
||||
"list[current_player;main;"..
|
||||
"0,"..inv_y..";"..
|
||||
INVENTORY_W..","..(INVENTORY_H-1)..
|
||||
";]"..
|
||||
"list[current_player;main;"..
|
||||
"0,"..hb_y..";"..
|
||||
INVENTORY_W..",1;24]"..
|
||||
default.get_hotbar_bg(0,hb_y)
|
||||
return formspec
|
||||
end
|
||||
|
||||
local function construct_container(pos)
|
||||
-- Get node name
|
||||
local name = minetest.get_node(pos).name
|
||||
|
||||
-- Set node infotext equal to it's description (name)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", minetest.registered_nodes[name].description)
|
||||
|
||||
-- Set node inventory size
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", containers[name].w * containers[name].h)
|
||||
end
|
||||
|
||||
local function handle_unlocked_container(pos, node, clicker, wield_item)
|
||||
if wield_item:get_name() == "real_locks:lock" then
|
||||
-- Change unlocked container to locked,
|
||||
-- keeping all it's metadata (infotext, inventory etc.)
|
||||
node.name = node.name .. "_locked"
|
||||
minetest.swap_node(pos, node)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
-- Changing locked containter infotext
|
||||
-- back to it's normal value
|
||||
-- (not this one from unlocked container)
|
||||
meta:set_string("infotext", minetest.registered_nodes[node.name].description)
|
||||
|
||||
-- Now set's the password (lock)
|
||||
minetest.get_meta(pos):set_string("lock_pass", wield_item:get_metadata())
|
||||
|
||||
-- And take used lock
|
||||
wield_item:take_item()
|
||||
else
|
||||
-- Open container
|
||||
minetest.log("action",
|
||||
clicker:get_player_name()..
|
||||
" open "..
|
||||
node.name:sub(12,-1)..
|
||||
" at "..
|
||||
minetest.pos_to_string(pos))
|
||||
|
||||
minetest.show_formspec(
|
||||
clicker:get_player_name(),
|
||||
node.name,
|
||||
get_container_formspec(pos, node.name)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function handle_locked_container(pos, node, clicker, wield_item)
|
||||
-- If wield item is not a key, than character just cant open the container.
|
||||
if wield_item:get_name() == "real_locks:key" then
|
||||
-- Get lock metadata and key metadata
|
||||
local password = minetest.get_meta(pos):get_string("lock_pass")
|
||||
local meta = wield_item:get_metadata()
|
||||
|
||||
-- If lock metadata and key metadata is equal,
|
||||
-- than open the container
|
||||
if meta == password then
|
||||
minetest.show_formspec(
|
||||
clicker:get_player_name(),
|
||||
node.name,
|
||||
get_container_formspec(pos, node.name)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function dig_container(pos, oldnode, oldmeta, digger)
|
||||
-- Drop all what was inside the container
|
||||
for k, itemstack in ipairs(oldmeta.inventory.main) do
|
||||
if not itemstack:is_empty() then
|
||||
pos.y = pos.y + 0.5
|
||||
minetest.add_item(pos, itemstack)
|
||||
end
|
||||
end
|
||||
|
||||
-- If character dig the chest with bare hands,
|
||||
-- than he is just lift it (or something like that)
|
||||
if digger:get_wielded_item():get_name() == "" then
|
||||
|
||||
-- If this was a locked container,
|
||||
-- than we need to save lock password
|
||||
if oldmeta.fields.lock_pass ~= nil then
|
||||
local container = ItemStack({
|
||||
name = oldnode.name,
|
||||
count = 1,
|
||||
wear = 0,
|
||||
metadata = oldmeta.fields.lock_pass
|
||||
})
|
||||
digger:set_wielded_item(container)
|
||||
else
|
||||
digger:set_wielded_item(oldnode.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function place_locked_container(pos, placer, itemstack)
|
||||
-- When we place a locked container,
|
||||
-- we must restore it's lock password
|
||||
local meta = minetest.get_meta(pos)
|
||||
local password = itemstack:get_metadata()
|
||||
meta:set_string("lock_pass", password)
|
||||
end
|
||||
--}}}
|
||||
|
||||
--{{{ Chest
|
||||
|
||||
--{{{ unlocked
|
||||
minetest.register_node("containers:chest", {
|
||||
description = "Chest",
|
||||
tiles = {
|
||||
"default_chest_top.png", "default_chest_top.png",
|
||||
"default_chest_side.png", "default_chest_side.png",
|
||||
"default_chest_side.png", "default_chest_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "",
|
||||
|
||||
on_construct = construct_container,
|
||||
after_dig_node = dig_container,
|
||||
on_rightclick = handle_unlocked_container,
|
||||
--{{{ Logging
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
--}}}
|
||||
})
|
||||
--}}}
|
||||
|
||||
--{{{ locked
|
||||
minetest.register_node("containers:chest_locked", {
|
||||
description = "Locked chest",
|
||||
tiles = {
|
||||
"default_chest_top.png", "default_chest_top.png",
|
||||
"default_chest_side.png", "default_chest_side.png",
|
||||
"default_chest_side.png", "default_chest_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "",
|
||||
|
||||
on_construct = construct_container,
|
||||
after_place_node = place_locked_container,
|
||||
after_dig_node = dig_container,
|
||||
on_rightclick = handle_locked_container,
|
||||
--{{{ Logging
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
--}}}
|
||||
})
|
||||
--}}}
|
||||
|
||||
--}}}
|
||||
|
||||
--{{{ Wooden bin
|
||||
minetest.register_node("containers:wood_bin", {
|
||||
description = "Wooden bin",
|
||||
tiles = {"containers_wood_bin.png"},
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "",
|
||||
|
||||
on_construct = construct_container,
|
||||
after_dig_node = dig_container,
|
||||
on_rightclick = handle_unlocked_container,
|
||||
--{{{ Logging
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in bin at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to bin at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from bin at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
--}}}
|
||||
})
|
||||
|
||||
minetest.register_node("containers:wood_bin_locked", {
|
||||
description = "Locked wooden bin",
|
||||
tiles = {"containers_wood_bin.png"},
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "",
|
||||
|
||||
on_construct = construct_container,
|
||||
after_place_node = place_locked_container,
|
||||
after_dig_node = dig_container,
|
||||
on_rightclick = handle_locked_container,
|
||||
--{{{ Logging
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in bin at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to bin at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from bin at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
--}}}
|
||||
})
|
||||
--}}}
|
||||
|
||||
--{{{ Wooden jewelry box
|
||||
minetest.register_node("containers:wood_jbox", {
|
||||
description = "Wooden jewelry box",
|
||||
--{{{ Tiles
|
||||
tiles = {
|
||||
"default_wood.png^containers_wood_jbox_top.png",
|
||||
"default_wood.png^containers_wood_jbox_top.png",
|
||||
"default_wood.png^containers_wood_jbox_side2.png",
|
||||
"default_wood.png^containers_wood_jbox_side.png",
|
||||
"default_wood.png^containers_wood_jbox_back.png",
|
||||
"default_wood.png^containers_wood_jbox_front.png"
|
||||
},
|
||||
--}}}
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
--{{{ Node box
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-- "legs"
|
||||
{-6/16, -8/16, -1/16, -4/16, -7/16, -3/16},
|
||||
{-6/16, -8/16, 2/16, -4/16, -7/16, 4/16},
|
||||
{4/16, -8/16, -1/16, 6/16, -7/16, -3/16},
|
||||
{4/16, -8/16, 2/16, 6/16, -7/16, 4/16},
|
||||
-- Box
|
||||
{-5/16, -7/16, -2/16, 5/16, -3/16, 3/16},
|
||||
-- "head"
|
||||
{-4/16, -3/16, -1/16, 4/16, -2/16, 2/16},
|
||||
{-3/16, -2/16, 0, 3/16, -1/16, 1/16},
|
||||
-- "horns"
|
||||
{-4/16, -1/16, 0, -3/16, 0, 1/16},
|
||||
{-3/16, 0, 0, -2/16, 1/16, 1/16},
|
||||
{3/16, -1/16, 0, 4/16, 0, 1/16},
|
||||
{2/16, 0, 0, 3/16, 1/16, 1/16},
|
||||
}
|
||||
},
|
||||
--}}}
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "",
|
||||
|
||||
on_construct = construct_container,
|
||||
after_dig_node = dig_container,
|
||||
on_rightclick = handle_unlocked_container,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
-- If item is small, than you can put it in the small box
|
||||
if minetest.get_item_group(stack:get_name(), "small") > 0 then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
--{{{ Logging
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in jewelry box at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to jewelry box at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from jewelry box at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
--}}}
|
||||
})
|
||||
|
||||
minetest.register_node("containers:wood_jbox_locked", {
|
||||
description = "Locked wooden jewelry box",
|
||||
--{{{ Tiles
|
||||
tiles = {
|
||||
"default_wood.png^containers_wood_jbox_top.png",
|
||||
"default_wood.png^containers_wood_jbox_top.png",
|
||||
"default_wood.png^containers_wood_jbox_side2.png",
|
||||
"default_wood.png^containers_wood_jbox_side.png",
|
||||
"default_wood.png^containers_wood_jbox_back.png",
|
||||
"default_wood.png^containers_wood_jbox_front.png"
|
||||
},
|
||||
--}}}
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
--{{{ Node box
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-- "legs"
|
||||
{-6/16, -8/16, -1/16, -4/16, -7/16, -3/16},
|
||||
{-6/16, -8/16, 2/16, -4/16, -7/16, 4/16},
|
||||
{4/16, -8/16, -1/16, 6/16, -7/16, -3/16},
|
||||
{4/16, -8/16, 2/16, 6/16, -7/16, 4/16},
|
||||
-- Box
|
||||
{-5/16, -7/16, -2/16, 5/16, -3/16, 3/16},
|
||||
-- "head"
|
||||
{-4/16, -3/16, -1/16, 4/16, -2/16, 2/16},
|
||||
{-3/16, -2/16, 0, 3/16, -1/16, 1/16},
|
||||
-- "horns"
|
||||
{-4/16, -1/16, 0, -3/16, 0, 1/16},
|
||||
{-3/16, 0, 0, -2/16, 1/16, 1/16},
|
||||
{3/16, -1/16, 0, 4/16, 0, 1/16},
|
||||
{2/16, 0, 0, 3/16, 1/16, 1/16},
|
||||
}
|
||||
},
|
||||
--}}}
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "",
|
||||
|
||||
on_construct = construct_container,
|
||||
after_place_node = place_locked_container,
|
||||
after_dig_node = dig_container,
|
||||
on_rightclick = handle_locked_container,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
-- If item is small, than you can put it in the small box
|
||||
if minetest.get_item_group(stack:get_name(), "small") > 0 then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
--{{{ Logging
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in jewelry box at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to jewelry box at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from jewelry box at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
--}}}
|
||||
})
|
||||
--}}}
|
After Width: | Height: | Size: 765 B |
After Width: | Height: | Size: 345 B |
After Width: | Height: | Size: 363 B |
After Width: | Height: | Size: 290 B |
After Width: | Height: | Size: 290 B |
After Width: | Height: | Size: 314 B |
|
@ -19,6 +19,7 @@ minetest.register_craftitem("default:book", {
|
|||
minetest.register_craftitem("default:coal_lump", {
|
||||
description = "Coal Lump",
|
||||
inventory_image = "default_coal_lump.png",
|
||||
groups = {coal = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:iron_lump", {
|
||||
|
|
|
@ -40,9 +40,9 @@ end
|
|||
function default.node_sound_sand_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="default_sand_footstep", gain=0.5}
|
||||
{name="default_sand_footstep", gain=0.2}
|
||||
table.dug = table.dug or
|
||||
{name="default_sand_footstep", gain=1.0}
|
||||
{name="default_sand_footstep", gain=0.4}
|
||||
table.place = table.place or
|
||||
{name="default_place_node", gain=1.0}
|
||||
default.node_sound_defaults(table)
|
||||
|
@ -64,7 +64,7 @@ function default.node_sound_leaves_defaults(table)
|
|||
table.footstep = table.footstep or
|
||||
{name="default_grass_footstep", gain=0.35}
|
||||
table.dug = table.dug or
|
||||
{name="default_grass_footstep", gain=0.85}
|
||||
{name="default_grass_footstep", gain=0.7}
|
||||
table.dig = table.dig or
|
||||
{name="default_dig_crumbly", gain=0.4}
|
||||
table.place = table.place or
|
||||
|
@ -127,56 +127,6 @@ end
|
|||
minetest.register_on_punchnode(on_punchnode)
|
||||
|
||||
|
||||
--
|
||||
-- Grow trees
|
||||
--
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:sapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log("action", "A sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
default.grow_tree(data, a, pos, math.random(1, 4) == 1, math.random(1,100000))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:junglesapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log("action", "A jungle sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y-1, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
default.grow_jungletree(data, a, pos, math.random(1,100000))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
})
|
||||
|
||||
--
|
||||
-- Lavacooling
|
||||
--
|
||||
|
|
|
@ -731,141 +731,6 @@ minetest.register_node("default:sign_wall", {
|
|||
end,
|
||||
})
|
||||
|
||||
default.chest_formspec =
|
||||
"size[8,9]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"list[current_name;main;0,0.3;8,4;]"..
|
||||
"list[current_player;main;0,4.85;8,1;]"..
|
||||
"list[current_player;main;0,6.08;8,3;8]"..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
|
||||
function default.get_locked_chest_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"list[nodemeta:".. spos .. ";main;0,0.3;8,4;]"..
|
||||
"list[current_player;main;0,4.85;8,1;]"..
|
||||
"list[current_player;main;0,6.08;8,3;8]"..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
return formspec
|
||||
end
|
||||
|
||||
|
||||
minetest.register_node("default:chest", {
|
||||
description = "Chest",
|
||||
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
||||
"default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",default.chest_formspec)
|
||||
meta:set_string("infotext", "Chest")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
})
|
||||
|
||||
local function has_locked_chest_privilege(meta, player)
|
||||
if player:get_player_name() ~= meta:get_string("owner") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_node("default:chest_locked", {
|
||||
description = "Locked Chest",
|
||||
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
||||
"default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", "Locked Chest (owned by "..
|
||||
meta:get_string("owner")..")")
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Locked Chest")
|
||||
meta:set_string("owner", "")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to locked chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from locked chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if has_locked_chest_privilege(meta, clicker) then
|
||||
minetest.show_formspec(
|
||||
clicker:get_player_name(),
|
||||
"default:chest_locked",
|
||||
default.get_locked_chest_formspec(pos)
|
||||
)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
function default.furnace_active(pos, percent, item_percent)
|
||||
local formspec =
|
||||
"size[8,8.5]"..
|
||||
|
|
Before Width: | Height: | Size: 544 B |
Before Width: | Height: | Size: 252 B |
Before Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 596 B |
Before Width: | Height: | Size: 368 B |
Before Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 589 B |
Before Width: | Height: | Size: 546 B |
Before Width: | Height: | Size: 682 B |
Before Width: | Height: | Size: 780 B |
Before Width: | Height: | Size: 638 B |
Before Width: | Height: | Size: 627 B |
Before Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 323 B |
Before Width: | Height: | Size: 453 B |
Before Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 647 B |
Before Width: | Height: | Size: 280 B |
Before Width: | Height: | Size: 405 B |
Before Width: | Height: | Size: 397 B |
Before Width: | Height: | Size: 659 B |
Before Width: | Height: | Size: 835 B |
Before Width: | Height: | Size: 217 B |
Before Width: | Height: | Size: 602 B |
Before Width: | Height: | Size: 204 B |
Before Width: | Height: | Size: 719 B |
Before Width: | Height: | Size: 553 B |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 602 B |
Before Width: | Height: | Size: 602 B |
Before Width: | Height: | Size: 204 B |
Before Width: | Height: | Size: 693 B |
Before Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 657 B |
Before Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 252 B |
Before Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 771 B |