Update default (part 2 of ?) and fix deprecated
@ -27,20 +27,20 @@ local function get_chest_neighborpos(pos, param2, side)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function hacky_swap_node(pos,name, param2)
|
local function hacky_swap_node(pos,name, param2)
|
||||||
local node = minetest.env:get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
node.name = name
|
node.name = name
|
||||||
node.param2 = param2 or node.param2
|
node.param2 = param2 or node.param2
|
||||||
local meta0 = meta:to_table()
|
local meta0 = meta:to_table()
|
||||||
minetest.env:set_node(pos,node)
|
minetest.set_node(pos,node)
|
||||||
meta = minetest.env:get_meta(pos)
|
meta = minetest.get_meta(pos)
|
||||||
meta:from_table(meta0)
|
meta:from_table(meta0)
|
||||||
end
|
end
|
||||||
|
|
||||||
default.chest_formspec =
|
default.chest_formspec =
|
||||||
"size[9,9.75]"..
|
"size[9,9.75]"..
|
||||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||||
"background[-0.19,-0.25;9.41,10.48;formspec_chest.png]"..
|
"background[-0.19,-0.25;9.41,10.48;formspec_chest.png]"..
|
||||||
@ -62,7 +62,7 @@ function default.get_locked_chest_formspec(pos)
|
|||||||
meta:set_int("chest_inv_ver",chest_inv_vers)
|
meta:set_int("chest_inv_ver",chest_inv_vers)
|
||||||
end
|
end
|
||||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||||
local formspec =
|
local formspec =
|
||||||
"size[9,9.75]"..
|
"size[9,9.75]"..
|
||||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||||
"background[-0.19,-0.25;9.41,10.48;formspec_chest.png]"..
|
"background[-0.19,-0.25;9.41,10.48;formspec_chest.png]"..
|
||||||
@ -98,10 +98,10 @@ minetest.register_node("default:chest", {
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local param2 = minetest.env:get_node(pos).param2
|
local param2 = minetest.get_node(pos).param2
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if minetest.env:get_node(get_chest_neighborpos(pos, param2, "right")).name == "default:chest" then
|
if minetest.get_node(get_chest_neighborpos(pos, param2, "right")).name == "default:chest" then
|
||||||
minetest.env:set_node(pos, {name="default:chest_right",param2=param2})
|
minetest.set_node(pos, {name="default:chest_right",param2=param2})
|
||||||
local p = get_chest_neighborpos(pos, param2, "right")
|
local p = get_chest_neighborpos(pos, param2, "right")
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[9,11.5]"..
|
"size[9,11.5]"..
|
||||||
@ -112,7 +112,7 @@ minetest.register_node("default:chest", {
|
|||||||
"list[current_player;main;0,10.5;9,1;]")
|
"list[current_player;main;0,10.5;9,1;]")
|
||||||
meta:set_string("infotext", "Large Chest")
|
meta:set_string("infotext", "Large Chest")
|
||||||
hacky_swap_node(p, "default:chest_left", param2)
|
hacky_swap_node(p, "default:chest_left", param2)
|
||||||
local m = minetest.env:get_meta(p)
|
local m = minetest.get_meta(p)
|
||||||
m:set_string("formspec",
|
m:set_string("formspec",
|
||||||
"size[9,11.5]"..
|
"size[9,11.5]"..
|
||||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||||
@ -121,8 +121,8 @@ minetest.register_node("default:chest", {
|
|||||||
"list[current_player;main;0,7;9,3;9]"..
|
"list[current_player;main;0,7;9,3;9]"..
|
||||||
"list[current_player;main;0,10.5;9,1;]")
|
"list[current_player;main;0,10.5;9,1;]")
|
||||||
m:set_string("infotext", "Large Chest")
|
m:set_string("infotext", "Large Chest")
|
||||||
elseif minetest.env:get_node(get_chest_neighborpos(pos, param2, "left")).name == "default:chest" then
|
elseif minetest.get_node(get_chest_neighborpos(pos, param2, "left")).name == "default:chest" then
|
||||||
minetest.env:set_node(pos, {name="default:chest_left",param2=param2})
|
minetest.set_node(pos, {name="default:chest_left",param2=param2})
|
||||||
local p = get_chest_neighborpos(pos, param2, "left")
|
local p = get_chest_neighborpos(pos, param2, "left")
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[9,11.5]"..
|
"size[9,11.5]"..
|
||||||
@ -133,7 +133,7 @@ minetest.register_node("default:chest", {
|
|||||||
"list[current_player;main;0,10.5;9,1;]")
|
"list[current_player;main;0,10.5;9,1;]")
|
||||||
meta:set_string("infotext", "Large Chest")
|
meta:set_string("infotext", "Large Chest")
|
||||||
hacky_swap_node(p, "default:chest_right", param2)
|
hacky_swap_node(p, "default:chest_right", param2)
|
||||||
local m = minetest.env:get_meta(p)
|
local m = minetest.get_meta(p)
|
||||||
m:set_string("formspec",
|
m:set_string("formspec",
|
||||||
"size[9,11.5]"..
|
"size[9,11.5]"..
|
||||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||||
@ -155,7 +155,7 @@ minetest.register_node("default:chest", {
|
|||||||
inv:set_size("main", 9*3)
|
inv:set_size("main", 9*3)
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local meta2 = meta
|
local meta2 = meta
|
||||||
meta:from_table(oldmetadata)
|
meta:from_table(oldmetadata)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -163,7 +163,7 @@ minetest.register_node("default:chest", {
|
|||||||
local stack = inv:get_stack("main", i)
|
local stack = inv:get_stack("main", i)
|
||||||
if not stack:is_empty() then
|
if not stack:is_empty() then
|
||||||
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
|
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
|
||||||
minetest.env:add_item(p, stack)
|
minetest.add_item(p, stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
meta:from_table(meta2:to_table())
|
meta:from_table(meta2:to_table())
|
||||||
@ -197,16 +197,16 @@ minetest.register_node("default:chest_left", {
|
|||||||
drop = "default:chest",
|
drop = "default:chest",
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
local m = minetest.env:get_meta(pos)
|
local m = minetest.get_meta(pos)
|
||||||
if m:get_string("infotext") == "Chest" then
|
if m:get_string("infotext") == "Chest" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local param2 = minetest.env:get_node(pos).param2
|
local param2 = minetest.get_node(pos).param2
|
||||||
local p = get_chest_neighborpos(pos, param2, "left")
|
local p = get_chest_neighborpos(pos, param2, "left")
|
||||||
if not p or minetest.env:get_node(p).name ~= "default:chest_right" then
|
if not p or minetest.get_node(p).name ~= "default:chest_right" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local meta = minetest.env:get_meta(p)
|
local meta = minetest.get_meta(p)
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[9,8.5]"..
|
"size[9,8.5]"..
|
||||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||||
@ -217,7 +217,7 @@ minetest.register_node("default:chest_left", {
|
|||||||
hacky_swap_node(p, "default:chest")
|
hacky_swap_node(p, "default:chest")
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local meta2 = meta
|
local meta2 = meta
|
||||||
meta:from_table(oldmetadata)
|
meta:from_table(oldmetadata)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -225,7 +225,7 @@ minetest.register_node("default:chest_left", {
|
|||||||
local stack = inv:get_stack("main", i)
|
local stack = inv:get_stack("main", i)
|
||||||
if not stack:is_empty() then
|
if not stack:is_empty() then
|
||||||
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
|
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
|
||||||
minetest.env:add_item(p, stack)
|
minetest.add_item(p, stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
meta:from_table(meta2:to_table())
|
meta:from_table(meta2:to_table())
|
||||||
@ -252,16 +252,16 @@ minetest.register_node("default:chest_right", {
|
|||||||
drop = "default:chest",
|
drop = "default:chest",
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
local m = minetest.env:get_meta(pos)
|
local m = minetest.get_meta(pos)
|
||||||
if m:get_string("infotext") == "Chest" then
|
if m:get_string("infotext") == "Chest" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local param2 = minetest.env:get_node(pos).param2
|
local param2 = minetest.get_node(pos).param2
|
||||||
local p = get_chest_neighborpos(pos, param2, "right")
|
local p = get_chest_neighborpos(pos, param2, "right")
|
||||||
if not p or minetest.env:get_node(p).name ~= "default:chest_left" then
|
if not p or minetest.get_node(p).name ~= "default:chest_left" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local meta = minetest.env:get_meta(p)
|
local meta = minetest.get_meta(p)
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[9,8.5]"..
|
"size[9,8.5]"..
|
||||||
"image_button_exit[9,0;1,1;close.png;exit;;true;true;]"..
|
"image_button_exit[9,0;1,1;close.png;exit;;true;true;]"..
|
||||||
@ -272,7 +272,7 @@ minetest.register_node("default:chest_right", {
|
|||||||
hacky_swap_node(p, "default:chest")
|
hacky_swap_node(p, "default:chest")
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local meta2 = meta
|
local meta2 = meta
|
||||||
meta:from_table(oldmetadata)
|
meta:from_table(oldmetadata)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -280,7 +280,7 @@ minetest.register_node("default:chest_right", {
|
|||||||
local stack = inv:get_stack("main", i)
|
local stack = inv:get_stack("main", i)
|
||||||
if not stack:is_empty() then
|
if not stack:is_empty() then
|
||||||
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
|
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
|
||||||
minetest.env:add_item(p, stack)
|
minetest.add_item(p, stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
meta:from_table(meta2:to_table())
|
meta:from_table(meta2:to_table())
|
||||||
|
@ -17,10 +17,162 @@ minetest.register_craftitem("default:paper", {
|
|||||||
groups = {misc = 1},
|
groups = {misc = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local lpp = 14 -- Lines per book's page
|
||||||
|
local function book_on_use(itemstack, user)
|
||||||
|
local player_name = user:get_player_name()
|
||||||
|
local meta = itemstack:get_meta()
|
||||||
|
local title, text, owner = "", "", player_name
|
||||||
|
local page, page_max, lines, string = 1, 1, {}, ""
|
||||||
|
|
||||||
|
-- Backwards compatibility
|
||||||
|
local old_data = minetest.deserialize(itemstack:get_metadata())
|
||||||
|
if old_data then
|
||||||
|
meta:from_table({ fields = old_data })
|
||||||
|
end
|
||||||
|
|
||||||
|
local data = meta:to_table().fields
|
||||||
|
|
||||||
|
if data.owner then
|
||||||
|
title = data.title
|
||||||
|
text = data.text
|
||||||
|
owner = data.owner
|
||||||
|
|
||||||
|
for str in (text .. "\n"):gmatch("([^\n]*)[\n]") do
|
||||||
|
lines[#lines+1] = str
|
||||||
|
end
|
||||||
|
|
||||||
|
if data.page then
|
||||||
|
page = data.page
|
||||||
|
page_max = data.page_max
|
||||||
|
|
||||||
|
for i = ((lpp * page) - lpp) + 1, lpp * page do
|
||||||
|
if not lines[i] then break end
|
||||||
|
string = string .. lines[i] .. "\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local formspec
|
||||||
|
if owner == player_name then
|
||||||
|
formspec = "size[8,8]" ..
|
||||||
|
"field[0.5,1;7.5,0;title;Title:;" ..
|
||||||
|
minetest.formspec_escape(title) .. "]" ..
|
||||||
|
"textarea[0.5,1.5;7.5,7;text;Contents:;" ..
|
||||||
|
minetest.formspec_escape(text) .. "]" ..
|
||||||
|
"button_exit[2.5,7.5;3,1;save;Save]"
|
||||||
|
else
|
||||||
|
formspec = "size[8,8]" ..
|
||||||
|
"label[0.5,0.5;by " .. owner .. "]" ..
|
||||||
|
"tablecolumns[color;text]" ..
|
||||||
|
"tableoptions[background=#00000000;highlight=#00000000;border=false]" ..
|
||||||
|
"table[0.4,0;7,0.5;title;#FFFF00," .. minetest.formspec_escape(title) .. "]" ..
|
||||||
|
"textarea[0.5,1.5;7.5,7;;" ..
|
||||||
|
minetest.formspec_escape(string ~= "" and string or text) .. ";]" ..
|
||||||
|
"button[2.4,7.6;0.8,0.8;book_prev;<]" ..
|
||||||
|
"label[3.2,7.7;Page " .. page .. " of " .. page_max .. "]" ..
|
||||||
|
"button[4.9,7.6;0.8,0.8;book_next;>]"
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.show_formspec(player_name, "default:book", formspec)
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local max_text_size = 10000
|
||||||
|
local max_title_size = 80
|
||||||
|
local short_title_size = 35
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if formname ~= "default:book" then return end
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
local stack = player:get_wielded_item()
|
||||||
|
|
||||||
|
if fields.save and fields.title and fields.text
|
||||||
|
and fields.title ~= "" and fields.text ~= "" then
|
||||||
|
local new_stack, data
|
||||||
|
if stack:get_name() ~= "default:book_written" then
|
||||||
|
local count = stack:get_count()
|
||||||
|
if count == 1 then
|
||||||
|
stack:set_name("default:book_written")
|
||||||
|
else
|
||||||
|
stack:set_count(count - 1)
|
||||||
|
new_stack = ItemStack("default:book_written")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
data = stack:get_meta():to_table().fields
|
||||||
|
end
|
||||||
|
|
||||||
|
if data and data.owner and data.owner ~= player:get_player_name() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not data then data = {} end
|
||||||
|
data.title = fields.title:sub(1, max_title_size)
|
||||||
|
data.owner = player:get_player_name()
|
||||||
|
local short_title = data.title
|
||||||
|
-- Don't bother triming the title if the trailing dots would make it longer
|
||||||
|
if #short_title > short_title_size + 3 then
|
||||||
|
short_title = short_title:sub(1, short_title_size) .. "..."
|
||||||
|
end
|
||||||
|
data.description = "\""..short_title.."\" by "..data.owner
|
||||||
|
data.text = fields.text:sub(1, max_text_size)
|
||||||
|
data.text = data.text:gsub("\r\n", "\n"):gsub("\r", "\n")
|
||||||
|
data.page = 1
|
||||||
|
data.page_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp)
|
||||||
|
|
||||||
|
if new_stack then
|
||||||
|
new_stack:get_meta():from_table({ fields = data })
|
||||||
|
if inv:room_for_item("main", new_stack) then
|
||||||
|
inv:add_item("main", new_stack)
|
||||||
|
else
|
||||||
|
minetest.add_item(player:get_pos(), new_stack)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
stack:get_meta():from_table({ fields = data })
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif fields.book_next or fields.book_prev then
|
||||||
|
local data = stack:get_meta():to_table().fields
|
||||||
|
if not data or not data.page then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
data.page = tonumber(data.page)
|
||||||
|
data.page_max = tonumber(data.page_max)
|
||||||
|
|
||||||
|
if fields.book_next then
|
||||||
|
data.page = data.page + 1
|
||||||
|
if data.page > data.page_max then
|
||||||
|
data.page = 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
data.page = data.page - 1
|
||||||
|
if data.page == 0 then
|
||||||
|
data.page = data.page_max
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
stack:get_meta():from_table({fields = data})
|
||||||
|
stack = book_on_use(stack, player)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update stack
|
||||||
|
player:set_wielded_item(stack)
|
||||||
|
end)
|
||||||
|
|
||||||
minetest.register_craftitem("default:book", {
|
minetest.register_craftitem("default:book", {
|
||||||
description = "Book",
|
description = "Book",
|
||||||
inventory_image = "default_book.png",
|
inventory_image = "default_book.png",
|
||||||
groups = {misc = 1},
|
groups = {book = 1, flammable = 3, misc = 1},
|
||||||
|
on_use = book_on_use,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem("default:book_written", {
|
||||||
|
description = "Book With Text",
|
||||||
|
inventory_image = "default_book_written.png",
|
||||||
|
groups = {book = 1, not_in_creative_inventory = 1, flammable = 3},
|
||||||
|
stack_max = 1,
|
||||||
|
on_use = book_on_use,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("default:coal_lump", {
|
minetest.register_craftitem("default:coal_lump", {
|
||||||
|
@ -1047,7 +1047,7 @@ function default.register_decorations()
|
|||||||
-- Emergent jungle tree
|
-- Emergent jungle tree
|
||||||
-- Due to 32 node height, altitude is limited and prescence depends on chunksize
|
-- Due to 32 node height, altitude is limited and prescence depends on chunksize
|
||||||
|
|
||||||
local chunksize = tonumber(minetest.get_mapgen_setting("chunksize"))
|
--[[ local chunksize = tonumber(minetest.get_mapgen_setting("chunksize"))
|
||||||
if chunksize >= 5 then
|
if chunksize >= 5 then
|
||||||
minetest.register_decoration({
|
minetest.register_decoration({
|
||||||
name = "default:emergent_jungle_tree",
|
name = "default:emergent_jungle_tree",
|
||||||
@ -1072,7 +1072,7 @@ function default.register_decorations()
|
|||||||
rotation = "random",
|
rotation = "random",
|
||||||
place_offset_y = -4,
|
place_offset_y = -4,
|
||||||
})
|
})
|
||||||
end
|
end]]--
|
||||||
|
|
||||||
-- Jungle tree and log
|
-- Jungle tree and log
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 831 B |
BIN
files/default/textures/default_book_written.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 953 B After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 329 B After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 846 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 629 B After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 324 B After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 874 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 967 B |
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 813 B After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 296 B After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 226 B |
@ -73,18 +73,17 @@ function default.grow_sapling(pos)
|
|||||||
minetest.log("action", "An acacia sapling grows into a tree at "..
|
minetest.log("action", "An acacia sapling grows into a tree at "..
|
||||||
minetest.pos_to_string(pos))
|
minetest.pos_to_string(pos))
|
||||||
default.grow_new_acacia_tree(pos)
|
default.grow_new_acacia_tree(pos)
|
||||||
elseif node.name == "default:emergent_jungle_sapling" then
|
--[[ elseif node.name == "default:emergent_jungle_sapling" then
|
||||||
minetest.log("action", "An emergent jungle sapling grows into a tree at "..
|
minetest.log("action", "An emergent jungle sapling grows into a tree at "..
|
||||||
minetest.pos_to_string(pos))
|
minetest.pos_to_string(pos))
|
||||||
default.grow_new_emergent_jungle_tree(pos)
|
default.grow_new_emergent_jungle_tree(pos)]]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_lbm({
|
minetest.register_lbm({
|
||||||
name = "default:convert_saplings_to_node_timer",
|
name = "default:convert_saplings_to_node_timer",
|
||||||
nodenames = {"default:sapling", "default:junglesapling",
|
nodenames = {"default:sapling", "default:junglesapling",
|
||||||
"default:pine_sapling", "default:acacia_sapling",
|
"default:pine_sapling", "default:acacia_sapling"},
|
||||||
"default:aspen_sapling"},
|
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
minetest.get_node_timer(pos):start(math.random(300, 1500))
|
minetest.get_node_timer(pos):start(math.random(300, 1500))
|
||||||
end
|
end
|
||||||
@ -388,12 +387,12 @@ end
|
|||||||
|
|
||||||
-- New emergent jungle tree
|
-- New emergent jungle tree
|
||||||
|
|
||||||
function default.grow_new_emergent_jungle_tree(pos)
|
--[[function default.grow_new_emergent_jungle_tree(pos)
|
||||||
local path = minetest.get_modpath("default") ..
|
local path = minetest.get_modpath("default") ..
|
||||||
"/schematics/emergent_jungle_tree_from_sapling.mts"
|
"/schematics/emergent_jungle_tree_from_sapling.mts"
|
||||||
minetest.place_schematic({x = pos.x - 3, y = pos.y - 5, z = pos.z - 3},
|
minetest.place_schematic({x = pos.x - 3, y = pos.y - 5, z = pos.z - 3},
|
||||||
path, "random", nil, false)
|
path, "random", nil, false)
|
||||||
end
|
end]]
|
||||||
|
|
||||||
|
|
||||||
-- New pine tree
|
-- New pine tree
|
||||||
@ -455,3 +454,85 @@ function default.grow_large_cactus(pos)
|
|||||||
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
|
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
|
||||||
path, "random", nil, false)
|
path, "random", nil, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Sapling 'on place' function to check protection of node and resulting tree volume
|
||||||
|
--
|
||||||
|
|
||||||
|
function default.sapling_on_place(itemstack, placer, pointed_thing,
|
||||||
|
sapling_name, minp_relative, maxp_relative, interval)
|
||||||
|
-- Position of sapling
|
||||||
|
local pos = pointed_thing.under
|
||||||
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
local pdef = node and minetest.registered_nodes[node.name]
|
||||||
|
|
||||||
|
if pdef and pdef.on_rightclick and
|
||||||
|
not (placer and placer:is_player() and
|
||||||
|
placer:get_player_control().sneak) then
|
||||||
|
return pdef.on_rightclick(pos, node, placer, itemstack, pointed_thing)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not pdef or not pdef.buildable_to then
|
||||||
|
pos = pointed_thing.above
|
||||||
|
node = minetest.get_node_or_nil(pos)
|
||||||
|
pdef = node and minetest.registered_nodes[node.name]
|
||||||
|
if not pdef or not pdef.buildable_to then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local player_name = placer and placer:get_player_name() or ""
|
||||||
|
-- Check sapling position for protection
|
||||||
|
if minetest.is_protected(pos, player_name) then
|
||||||
|
minetest.record_protection_violation(pos, player_name)
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
-- Check tree volume for protection
|
||||||
|
if core.intersects_protection(
|
||||||
|
vector.add(pos, minp_relative),
|
||||||
|
vector.add(pos, maxp_relative),
|
||||||
|
player_name,
|
||||||
|
interval) then
|
||||||
|
minetest.record_protection_violation(pos, player_name)
|
||||||
|
-- Print extra information to explain
|
||||||
|
minetest.chat_send_player(player_name,
|
||||||
|
itemstack:get_definition().description .. " will intersect protection " ..
|
||||||
|
"on growth")
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.log("action", player_name .. " places node "
|
||||||
|
.. sapling_name .. " at " .. minetest.pos_to_string(pos))
|
||||||
|
|
||||||
|
local take_item = not (creative and creative.is_enabled_for
|
||||||
|
and creative.is_enabled_for(player_name))
|
||||||
|
local newnode = {name = sapling_name}
|
||||||
|
local ndef = minetest.registered_nodes[sapling_name]
|
||||||
|
minetest.set_node(pos, newnode)
|
||||||
|
|
||||||
|
-- Run callback
|
||||||
|
if ndef and ndef.after_place_node then
|
||||||
|
-- Deepcopy place_to and pointed_thing because callback can modify it
|
||||||
|
if ndef.after_place_node(table.copy(pos), placer,
|
||||||
|
itemstack, table.copy(pointed_thing)) then
|
||||||
|
take_item = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Run script hook
|
||||||
|
for _, callback in ipairs(minetest.registered_on_placenodes) do
|
||||||
|
-- Deepcopy pos, node and pointed_thing because callback can modify them
|
||||||
|
if callback(table.copy(pos), table.copy(newnode),
|
||||||
|
placer, table.copy(node or {}),
|
||||||
|
itemstack, table.copy(pointed_thing)) then
|
||||||
|
take_item = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if take_item then
|
||||||
|
itemstack:take_item()
|
||||||
|
end
|
||||||
|
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
@ -67,4 +67,5 @@ minetest.register_craftitem("potions:glass_bottle", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_alias("vessels:glass_bottle", "potions:glass_bottle")
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
MultiCraft mod: vessels
|
|
||||||
==========================
|
|
||||||
|
|
||||||
Crafts
|
|
||||||
-------
|
|
||||||
Glass bottle (yields 4)
|
|
||||||
|
|
||||||
G - G
|
|
||||||
- G -
|
|
||||||
|
|
||||||
License of source code:
|
|
||||||
-----------------------
|
|
||||||
Copyright (C) 2012 Vanessa Ezekowitz
|
|
||||||
Version 2012-09-02
|
|
||||||
Modifications by Perttu Ahola <celeron55@gmail.com>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
the Free Software Foundation; either version 3.0 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
http://www.gnu.org/licenses/lgpl-3.0.html
|
|
@ -1 +0,0 @@
|
|||||||
default
|
|
@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
-- MultiCraft mod: vessels
|
|
||||||
-- See README.txt for licensing and other information.
|
|
||||||
|
|
||||||
minetest.register_node("vessels:glass_bottle", {
|
|
||||||
description = "Glass Bottle (empty)",
|
|
||||||
drawtype = "plantlike",
|
|
||||||
tiles = {"vessels_glass_bottle.png"},
|
|
||||||
inventory_image = "vessels_glass_bottle_inv.png",
|
|
||||||
wield_image = "vessels_glass_bottle.png",
|
|
||||||
paramtype = "light",
|
|
||||||
walkable = false,
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
|
|
||||||
},
|
|
||||||
groups = {vessel=1,dig_immediate=3,attached_node=1,brewing = 1},
|
|
||||||
sounds = default.node_sound_glass_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft( {
|
|
||||||
output = "vessels:glass_bottle 4",
|
|
||||||
recipe = {
|
|
||||||
{ "default:glass", "", "default:glass" },
|
|
||||||
{ "", "default:glass", "" }
|
|
||||||
}
|
|
||||||
})
|
|
Before Width: | Height: | Size: 228 B |
Before Width: | Height: | Size: 228 B |