From a2ecc51fbc75dd0411c6bbe096f8c39b3a6abc6c Mon Sep 17 00:00:00 2001 From: Rui914 Date: Fri, 18 Mar 2016 16:33:14 +0900 Subject: [PATCH 01/17] Create API for registration of fence gate. --- game_api.txt | 14 +++++ mods/doors/init.lua | 138 +++++++++++++++++++++++++++++--------------- 2 files changed, 104 insertions(+), 48 deletions(-) diff --git a/game_api.txt b/game_api.txt index a32f8d5c..d3330e5f 100644 --- a/game_api.txt +++ b/game_api.txt @@ -78,6 +78,12 @@ The doors mod allows modders to register custom doors and trapdoors. * `name` Name for trapdoor * `def` See [#Trapdoor definition] +`doors.register_fencegate(name, def)` + + * Registers new fence gate + * `name` Name for fence gate + * `def` See [#Fence gate definition] + `doors.get(pos)` * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}` @@ -119,6 +125,14 @@ The doors mod allows modders to register custom doors and trapdoors. sound_close = sound play for close door, -- optional protected = false, -- If true, only placer can open the door (locked for others) +###Fence gate definition + + description = "Wooden Fence Gate", + texture = "default_wood.png", + material = "default:wood", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + sounds = default.node_sound_wood_defaults(), -- optional + Fence API --------- Allows creation of new fences with "fencelike" drawtype. diff --git a/mods/doors/init.lua b/mods/doors/init.lua index dd7ab726..6e624e9e 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -658,59 +658,101 @@ minetest.register_craft({ ----fence gate---- -local fence = { - description = "Fence Gate", - drawtype = "mesh", - tiles = {"default_wood.png"}, - paramtype = "light", - paramtype2 = "facedir", - sunlight_propagates = true, - is_ground_content = false, - drop = "doors:gate_closed", - connect_sides = { "left", "right" }, - groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, - flammable = 2, fence = 1}, - on_rightclick = function(pos, clicker) - local node = minetest.get_node(pos) - local def = minetest.registered_nodes[node.name] - minetest.swap_node(pos, {name = def.gate, param2 = node.param2}) - minetest.sound_play(def.sound, {pos = pos, gain = 0.3, - max_hear_distance = 8}) - end, - selection_box = { +function doors.register_fencegate(name, def) + local fence = { + description = def.description, + drawtype = "mesh", + tiles = { def.texture }, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + is_ground_content = false, + drop = name .. "_closed", + connect_sides = { "left", "right" }, + groups = def.groups, + sounds = def.sounds, + on_rightclick = function(pos, clicker) + local node = minetest.get_node(pos) + local node_def = minetest.registered_nodes[node.name] + minetest.swap_node(pos, {name = node_def.gate, param2 = node.param2}) + minetest.sound_play(node_def.sound, {pos = pos, gain = 0.3, + max_hear_distance = 8}) + end, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}, + }, + } + + if not fence.sounds then + fence.sounds = default.node_sound_wood_defaults() + end + + fence.groups.fence = 1 + + local fence_closed = table.copy(fence) + fence_closed.mesh = "doors_fencegate_closed.obj" + fence_closed.gate = name .. "_open" + fence_closed.sound = "doors_fencegate_open" + fence_closed.collision_box = { type = "fixed", fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}, - }, -} + } -local fence_closed = table.copy(fence) -fence_closed.mesh = "doors_fencegate_closed.obj" -fence_closed.gate = "doors:gate_open" -fence_closed.sound = "doors_fencegate_open" -fence_closed.collision_box = { - type = "fixed", - fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}, -} + local fence_open = table.copy(fence) + fence_open.mesh = "doors_fencegate_open.obj" + fence_open.gate = name .. "_closed" + fence_open.sound = "doors_fencegate_close" + fence_open.groups.not_in_creative_inventory = 1 + fence_open.collision_box = { + type = "fixed", + fixed = {{-1/2, -1/2, -1/4, -3/8, 1/2, 1/4}, + {-5/8, -3/8, -14/16, -3/8, 3/8, 0}}, + } -local fence_open = table.copy(fence) -fence_open.mesh = "doors_fencegate_open.obj" -fence_open.gate = "doors:gate_closed" -fence_open.sound = "doors_fencegate_close" -fence_open.groups.not_in_creative_inventory = 1 -fence_open.collision_box = { - type = "fixed", - fixed = {{-1/2, -1/2, -1/4, -3/8, 1/2, 1/4}, - {-5/8, -3/8, -14/16, -3/8, 3/8, 0}}, -} + minetest.register_node(":" .. name .. "_closed", fence_closed) + minetest.register_node(":" .. name .. "_open", fence_open) -minetest.register_node("doors:gate_closed", fence_closed) -minetest.register_node("doors:gate_open", fence_open) + minetest.register_craft({ + output = name .. "_closed", + recipe = { + {"default:stick", def.material, "default:stick"}, + {"default:stick", def.material, "default:stick"} + } + }) +end -minetest.register_craft({ - output = "doors:gate_closed", - recipe = { - {"default:stick", "group:wood", "default:stick"}, - {"default:stick", "group:wood", "default:stick"}, - }, +doors.register_fencegate("doors:gate_wood", { + description = "Wooden Fence Gate", + texture = "default_wood.png", + material = "default:wood", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2} }) +doors.register_fencegate("doors:gate_acacia_wood", { + description = "Acacia Fence Gate", + texture = "default_acacia_wood.png", + material = "default:acacia_wood", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2} +}) + +doors.register_fencegate("doors:gate_junglewood", { + description = "Junglewood Fence Gate", + texture = "default_junglewood.png", + material = "default:junglewood", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2} +}) + +doors.register_fencegate("doors:gate_pine_wood", { + description = "Pine Fence Gate", + texture = "default_pine_wood.png", + material = "default:pine_wood", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2} +}) + +doors.register_fencegate("doors:gate_aspen_wood", { + description = "Aspen Fence Gate", + texture = "default_aspen_wood.png", + material = "default:aspen_wood", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2} +}) From 9de43cdf7d7391a929ec8e89ba615c01355926b3 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Mon, 14 Mar 2016 21:27:32 -0700 Subject: [PATCH 02/17] Doors: Allow falling nodes to fall onto doors. We were cleverly attempting to use an airlike node as the top half of the doors, but as airlike nodes are not walkable, falling nodes would not stop falling and thus remain an entity stuck on top of a door. After inspecting the builtin/game/falling.lua code, I considered the remaining options: (a) revert doors such that the top part is actually the door, (b) play with nodedef fields and see if other flags may work, or (c) modify the hidden door part to another drawtype that properly prevents this issue. (a) seemed way over the top for now, although it would solve the issue, it would cause a rewrite of most of the code including the old-door-conversion. (b) turned up nothing. (c) turned out to be relatively simple. So, here's the implementation where I turn the hidden door top into a tiny, non-targetable but walkable nodebox that is entirely inside the door hinge. It's entirely transparent, so you still can't see it, can't hit it, nor can you place anything in it or make liquids flow through it. The top part is placed in the right position on placement and not touched further. Falling nodes will properly stop on top of these doors. I've adjusted the door conversion code to properly account for the issue as well, so the only thing remaining is people who have been running a git branch - those can upgrade by re-placing the door. --- mods/doors/init.lua | 44 +++++++++++++++++++++++----- mods/doors/textures/doors_blank.png | Bin 0 -> 95 bytes 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 mods/doors/textures/doors_blank.png diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 6e624e9e..bd3e6998 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -74,17 +74,32 @@ end -- nodes from being placed in the top half of the door. minetest.register_node("doors:hidden", { description = "Hidden Door Segment", - drawtype = "airlike", + -- can't use airlike otherwise falling nodes will turn to entities + -- and will be forever stuck until door is removed. + drawtype = "nodebox", paramtype = "light", + paramtype2 = "facedir", sunlight_propagates = true, - walkable = false, + -- has to be walkable for falling nodes to stop falling. + walkable = true, pointable = false, diggable = false, buildable_to = false, floodable = false, drop = "", - groups = { not_in_creative_inventory = 1 }, - on_blast = function() end + groups = {not_in_creative_inventory = 1}, + on_blast = function() end, + tiles = {"doors_blank.png"}, + -- 1px transparent block inside door hinge near node top. + nodebox = { + type = "fixed", + fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32}, + }, + -- collision_box needed otherise selection box would be full node size + collision_box = { + type = "fixed", + fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32}, + }, }) -- table used to aid door opening/closing @@ -196,8 +211,21 @@ function doors.register(name, def) -- retain infotext and doors_owner fields minetest.swap_node(pos, {name = name .. "_" .. new.type, param2 = p2}) meta:set_int("state", new.state) + -- properly place doors:hidden at the right spot + local p3 = p2 + if new.state >= 2 then + p3 = (p3 + 3) % 4 + end + if new.state % 2 == 1 then + if new.state >= 2 then + p3 = (p3 + 1) % 4 + else + p3 = (p3 + 3) % 4 + end + end -- wipe meta on top node as it's unused - minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, { name = "doors:hidden" }) + minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, + {name = "doors:hidden", param2 = p3}) end }) @@ -259,10 +287,11 @@ function doors.register(name, def) if minetest.get_item_group(minetest.get_node(aside).name, "door") == 1 then state = state + 2 minetest.set_node(pos, {name = name .. "_b", param2 = dir}) + minetest.set_node(above, {name = "doors:hidden", param2 = (dir + 3) % 4}) else minetest.set_node(pos, {name = name .. "_a", param2 = dir}) + minetest.set_node(above, {name = "doors:hidden", param2 = dir}) end - minetest.set_node(above, { name = "doors:hidden" }) local meta = minetest.get_meta(pos) meta:set_int("state", state) @@ -322,7 +351,8 @@ function doors.register(name, def) _doors.door_toggle(pos, clicker) end def.after_dig_node = function(pos, node, meta, digger) - minetest.remove_node({ x = pos.x, y = pos.y + 1, z = pos.z}) + minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + nodeupdate({x = pos.x, y = pos.y + 1, z = pos.z}) end def.can_dig = function(pos, player) return can_dig(pos, player) diff --git a/mods/doors/textures/doors_blank.png b/mods/doors/textures/doors_blank.png new file mode 100644 index 0000000000000000000000000000000000000000..1914264c08781d1f30ee0b8482bccf44586f2dc1 GIT binary patch literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?ju0VQumF+E%TuG2$FoVOh l8)-lem#2$k2*>s01R$Gz9%CSj!PC{xWt~$(697H@6ZHT9 literal 0 HcmV?d00001 From 8fdcfea9f9a7efa753787b83967b921ac595cc9b Mon Sep 17 00:00:00 2001 From: Rui Date: Wed, 16 Mar 2016 20:10:25 +0900 Subject: [PATCH 03/17] Allow for shift+clicking inventory from bones --- mods/bones/init.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mods/bones/init.lua b/mods/bones/init.lua index 39502f1d..afa56eca 100644 --- a/mods/bones/init.lua +++ b/mods/bones/init.lua @@ -12,17 +12,19 @@ local function is_owner(pos, name) end bones.bones_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]".. + "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]" .. + "listring[current_name;main]" .. + "listring[current_player;main]" .. default.get_hotbar_bg(0,4.85) -local share_bones_time = tonumber(minetest.setting_get("share_bones_time") or 1200) -local share_bones_time_early = tonumber(minetest.setting_get("share_bones_time_early") or (share_bones_time/4)) +local share_bones_time = tonumber(minetest.setting_get("share_bones_time")) or 1200 +local share_bones_time_early = tonumber(minetest.setting_get("share_bones_time_early")) or share_bones_time / 4 minetest.register_node("bones:bones", { description = "Bones", From b57dd0f9b2ae22ce4198b9e30531cf9323969e41 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Wed, 16 Mar 2016 22:01:14 +0100 Subject: [PATCH 04/17] Books: Add support for multiple pages --- mods/default/craftitems.lua | 109 ++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 35 deletions(-) diff --git a/mods/default/craftitems.lua b/mods/default/craftitems.lua index 31d85c9b..fc52bc42 100644 --- a/mods/default/craftitems.lua +++ b/mods/default/craftitems.lua @@ -11,14 +11,22 @@ minetest.register_craftitem("default:paper", { inventory_image = "default_paper.png", }) -local function book_on_use(itemstack, user, pointed_thing) +local function book_on_use(itemstack, user) local player_name = user:get_player_name() local data = minetest.deserialize(itemstack:get_metadata()) - local title, text, owner = "", "", player_name + local formspec, title, text, text_len, page, page_max, cpp, owner = + "", "", "", 1, 1, 1, 1, player_name + if data then - title, text, owner = data.title, data.text, data.owner + title = data.title + text = data.text + owner = data.owner + text_len = data.text_len + page = data.page + page_max = data.page_max + cpp = data.chars_per_page end - local formspec + if owner == player_name then formspec = "size[8,8]" .. default.gui_bg .. default.gui_bg_img .. @@ -31,48 +39,79 @@ local function book_on_use(itemstack, user, pointed_thing) formspec = "size[8,8]" .. default.gui_bg .. default.gui_bg_img .. "label[0.5,0.5;by " .. owner .. "]" .. - "label[0.5,0;" .. minetest.formspec_escape(title) .. "]" .. - "textarea[0.5,1.5;7.5,7;text;;" .. - minetest.formspec_escape(text) .. "]" + "tablecolumns[color;text]" .. + "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. + "table[0.4,0;4,0.5;title;#FFFF00," .. minetest.formspec_escape(title) .. "]".. + "textarea[0.5,1.5;7.5,7;;".. minetest.formspec_escape(text:sub( + (cpp * page) - cpp, cpp * page)) .. ";]" .. + "button[4.6,0.2;0.8,0.8;book_prev;<]" .. + "label[5.35,0.3;Page " .. page .. " of " .. page_max .. "]".. + "button[7,0.2;0.8,0.8;book_next;>]" end - minetest.show_formspec(user:get_player_name(), "default:book", formspec) + + minetest.show_formspec(player_name, "default:book", formspec) end -minetest.register_on_player_receive_fields(function(player, form_name, fields) - if form_name ~= "default:book" or not fields.save or - fields.title == "" or fields.text == "" then - return - end +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() - 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") + + if fields.save 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 - stack:set_count(count - 1) - new_stack = ItemStack("default:book_written") + data = minetest.deserialize(stack:get_metadata()) end - else - data = minetest.deserialize(stack:get_metadata()) - end - if not data then data = {} end - data.title = fields.title - data.text = fields.text - data.owner = player:get_player_name() - local data_str = minetest.serialize(data) - if new_stack then - new_stack:set_metadata(data_str) - if inv:room_for_item("main", new_stack) then - inv:add_item("main", new_stack) + + if not data then data = {} end + data.title = fields.title + data.text = fields.text + data.text_len = fields.text:len() + data.page = 1 + data.chars_per_page = 650 + data.page_max = math.ceil(data.text_len / data.chars_per_page) + data.owner = player:get_player_name() + local data_str = minetest.serialize(data) + + if new_stack then + new_stack:set_metadata(data_str) + if inv:room_for_item("main", new_stack) then + inv:add_item("main", new_stack) + else + minetest.add_item(player:getpos(), new_stack) + end else - minetest.add_item(player:getpos(), new_stack) + stack:set_metadata(data_str) end - else + + player:set_wielded_item(stack) + + elseif fields.book_next or fields.book_prev then + local data = minetest.deserialize(stack:get_metadata()) + 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 + + local data_str = minetest.serialize(data) stack:set_metadata(data_str) + book_on_use(stack, player) end - player:set_wielded_item(stack) end) minetest.register_craftitem("default:book", { From da0cc7f6f62c149363c319a7743a00a505da06d2 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 18 Mar 2016 18:55:56 -0700 Subject: [PATCH 05/17] Beds: priv/griefing fixes. - disallow placing beds in protected areas - fix rotation of beds(broken after 41c2b2ae) - allow using others' beds, but don't change spawn location Fixes #953. #943 isn't something I think was ever implemented, and this does a fair job of addressing the main concern (spawning in others' houses) --- mods/beds/api.lua | 56 ++++++++++++++++++++++++++++++-------------- mods/beds/spawns.lua | 9 ++++--- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/mods/beds/api.lua b/mods/beds/api.lua index be3cb97e..e2dd7edf 100644 --- a/mods/beds/api.lua +++ b/mods/beds/api.lua @@ -44,23 +44,42 @@ function beds.register_bed(name, def) fixed = def.selectionbox, }, - after_place_node = function(pos, placer, itemstack) - local n = minetest.get_node_or_nil(pos) - if not n or not n.param2 then - minetest.remove_node(pos) - return true + on_place = function(itemstack, placer, pointed_thing) + local under = pointed_thing.under + local pos + if minetest.registered_items[minetest.get_node(under).name].buildable_to then + pos = under + else + pos = pointed_thing.above end - local dir = minetest.facedir_to_dir(n.param2) - local p = vector.add(pos, dir) - local n2 = minetest.get_node_or_nil(p) - local def = n2 and minetest.registered_items[n2.name] - if not def or not def.buildable_to then - minetest.remove_node(pos) - return true + + if minetest.is_protected(pos, placer:get_player_name()) and + not minetest.check_player_privs(placer, "protection_bypass") then + minetest.record_protection_violation(pos, placer:get_player_name()) + return itemstack end - minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2}) - return false - end, + + local dir = minetest.dir_to_facedir(placer:get_look_dir()) + local botpos = vector.add(pos, minetest.facedir_to_dir(dir)) + + if minetest.is_protected(botpos, placer:get_player_name()) and + not minetest.check_player_privs(placer, "protection_bypass") then + minetest.record_protection_violation(botpos, placer:get_player_name()) + return itemstack + end + + if not minetest.registered_nodes[minetest.get_node(botpos).name].buildable_to then + return itemstack + end + + minetest.set_node(pos, {name = name .. "_bottom", param2 = dir}) + minetest.set_node(botpos, {name = name .. "_top", param2 = dir}) + + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + return itemstack + end, on_destruct = function(pos) destruct_bed(pos, 1) @@ -96,9 +115,10 @@ function beds.register_bed(name, def) return false end node.param2 = new_param2 - minetest.swap_node(pos, node) - minetest.remove_node(p) - minetest.set_node(newp, {name = node.name:gsub("%_bottom", "_top"), param2 = new_param2}) + -- do not remove_node here - it will trigger destroy_bed() + minetest.set_node(p, {name = "air"}) + minetest.set_node(pos, node) + minetest.set_node(newp, {name = name .. "_top", param2 = new_param2}) return true end, }) diff --git a/mods/beds/spawns.lua b/mods/beds/spawns.lua index 14ec75bf..f3980a7a 100644 --- a/mods/beds/spawns.lua +++ b/mods/beds/spawns.lua @@ -18,8 +18,8 @@ function beds.read_spawns() repeat local x = input:read("*n") if x == nil then - break - end + break + end local y = input:read("*n") local z = input:read("*n") local name = input:read("*l") @@ -52,7 +52,10 @@ function beds.set_spawns() for name,_ in pairs(beds.player) do local player = minetest.get_player_by_name(name) local p = player:getpos() - beds.spawn[name] = p + -- but don't change spawn location if borrowing a bed + if not minetest.is_protected(p, name) then + beds.spawn[name] = p + end end beds.save_spawns() end From 537f94c28e28670a65d84b9e23a7a84aeaabb10d Mon Sep 17 00:00:00 2001 From: paramat Date: Sat, 19 Mar 2016 20:49:29 +0000 Subject: [PATCH 06/17] Fire: Speed up fire spread and burn out --- mods/fire/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/fire/init.lua b/mods/fire/init.lua index 1fc942b8..c32b5110 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -231,7 +231,7 @@ else nodenames = {"group:flammable"}, neighbors = {"group:igniter"}, interval = 7, - chance = 16, + chance = 12, catch_up = false, action = function(p0, node, _, _) -- If there is water or stuff like that around node, don't ignite @@ -250,7 +250,7 @@ else minetest.register_abm({ nodenames = {"fire:basic_flame"}, interval = 5, - chance = 16, + chance = 6, catch_up = false, action = function(p0, node, _, _) -- If there are no flammable nodes around flame, remove flame From 51891122f2403abb102d149b79bdeeea5a66aa44 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Thu, 3 Mar 2016 10:18:41 +0000 Subject: [PATCH 07/17] Changes to Screwdriver to add new drivers. A few screwdriver changes so that mod makers can add new screwdrivers with different wear levels. Tried and tested with new diamond screwdriver :) --- mods/screwdriver/init.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mods/screwdriver/init.lua b/mods/screwdriver/init.lua index 6b82d042..5e6df62f 100644 --- a/mods/screwdriver/init.lua +++ b/mods/screwdriver/init.lua @@ -18,10 +18,9 @@ screwdriver.rotate_simple = function(pos, node, user, mode, new_param2) return false end end -local USES = 200 -- Handles rotation -local function screwdriver_handler(itemstack, user, pointed_thing, mode) +screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses) if pointed_thing.type ~= "node" then return end @@ -82,7 +81,7 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode) end if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535 / (USES - 1)) + itemstack:add_wear(65535 / ((uses or 200) - 1)) end return itemstack @@ -93,11 +92,11 @@ minetest.register_tool("screwdriver:screwdriver", { description = "Screwdriver (left-click rotates face, right-click rotates axis)", inventory_image = "screwdriver.png", on_use = function(itemstack, user, pointed_thing) - screwdriver_handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE) + screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, 200) return itemstack end, on_place = function(itemstack, user, pointed_thing) - screwdriver_handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS) + screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS, 200) return itemstack end, }) From 1a5f89e75027e07d8c63b9de745abb4b44c1002d Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Thu, 17 Mar 2016 00:11:44 +0100 Subject: [PATCH 08/17] Creative: Code cleaning + Fix items moving in virtual inventory --- mods/creative/init.lua | 122 +++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/mods/creative/init.lua b/mods/creative/init.lua index 01163707..c842efd3 100644 --- a/mods/creative/init.lua +++ b/mods/creative/init.lua @@ -6,15 +6,15 @@ local player_inventory = {} -- Create detached creative inventory after loading all mods creative.init_creative_inventory = function(player) local player_name = player:get_player_name() - player_inventory[player_name] = {} player_inventory[player_name].size = 0 - player_inventory[player_name].filter = nil + player_inventory[player_name].filter = "" player_inventory[player_name].start_i = 1 + player_inventory[player_name].tab_id = 2 - local inv = minetest.create_detached_inventory("creative_" .. player_name, { + minetest.create_detached_inventory("creative_" .. player_name, { allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) - if minetest.setting_getbool("creative_mode") then + if minetest.setting_getbool("creative_mode") and not to_list == "main" then return count else return 0 @@ -35,16 +35,17 @@ creative.init_creative_inventory = function(player) on_put = function(inv, listname, index, stack, player) end, on_take = function(inv, listname, index, stack, player) - --print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack)) + local player_name, stack_name = player:get_player_name(), stack:get_name() + --print(player_name .. " takes item from creative inventory; listname = " .. listname .. ", index = " .. index .. ", stack = " .. dump(stack:to_table())) if stack then - minetest.log("action", player:get_player_name().." takes "..dump(stack:get_name()).." from creative inventory") - --print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count())) + minetest.log("action", player_name .. " takes " .. stack_name .. " from creative inventory") + --print("Stack name: " .. stack_name .. ", Stack count: " .. stack:get_count()) end end, }) - creative.update_creative_inventory(player_name, nil, 2) - --print("creative inventory size: "..dump(player_inventory[player_name].size)) + creative.update_creative_inventory(player_name) + --print("creative inventory size: " .. player_inventory[player_name].size) end local function tab_category(tab_id) @@ -60,23 +61,24 @@ local function tab_category(tab_id) return id_category[tab_id] or id_category[2] end -function creative.update_creative_inventory(player_name, filter, tab_id) +function creative.update_creative_inventory(player_name) local creative_list = {} - local inv = minetest.get_inventory({type = "detached", name = "creative_" .. player_name}) + local player_inv = minetest.get_inventory({type = "detached", name = "creative_" .. player_name}) + local inv = player_inventory[player_name] - for name, def in pairs(tab_category(tab_id)) do + for name, def in pairs(tab_category(inv.tab_id)) do if not (def.groups.not_in_creative_inventory == 1) and def.description and def.description ~= "" and - (not filter or def.name:find(filter, 1, true) or - def.description:lower():find(filter, 1, true)) then + (def.name:find(inv.filter, 1, true) or + def.description:lower():find(inv.filter, 1, true)) then creative_list[#creative_list+1] = name end end table.sort(creative_list) - inv:set_size("main", #creative_list) - inv:set_list("main", creative_list) - player_inventory[player_name].size = #creative_list + player_inv:set_size("main", #creative_list) + player_inv:set_list("main", creative_list) + inv.size = #creative_list end -- Create the trash field @@ -90,18 +92,17 @@ local trash = minetest.create_detached_inventory("creative_trash", { return 0 end end, - on_put = function(inv, listname, index, stack, player) - inv:set_stack(listname, index, "") + on_put = function(inv, listname) + inv:set_list(listname, {}) end, }) trash:set_size("main", 1) -creative.set_creative_formspec = function(player, start_i, pagenum, tab_id) +creative.set_creative_formspec = function(player, start_i) local player_name = player:get_player_name() - local filter = player_inventory[player_name].filter or "" - pagenum = math.floor(pagenum) - local pagemax = math.floor((player_inventory[player_name].size - 1) / (3*8) + 1) - tab_id = tab_id or 2 + local inv = player_inventory[player_name] + local pagenum = math.floor(start_i / (3*8) + 1) + local pagemax = math.ceil(inv.size / (3*8)) player:set_inventory_formspec([[ size[8,8.6] @@ -109,6 +110,7 @@ creative.set_creative_formspec = function(player, start_i, pagenum, tab_id) list[current_player;main;0,4.7;8,1;] list[current_player;main;0,5.85;8,3;8] list[detached:creative_trash;main;4,3.3;1,1;] + listring[] tablecolumns[color;text;color;text] tableoptions[background=#00000000;highlight=#00000000;border=false] button[5.4,3.2;0.8,0.9;creative_prev;<] @@ -119,12 +121,12 @@ creative.set_creative_formspec = function(player, start_i, pagenum, tab_id) tooltip[creative_clear;Reset] listring[current_player;main] ]] .. - "field[0.3,3.5;2.2,1;creative_filter;;".. filter .."]".. - "listring[detached:creative_".. player_name ..";main]".. - "tabheader[0,0;creative_tabs;Crafting,All,Nodes,Tools,Items;".. tostring(tab_id) ..";true;false]".. - "list[detached:creative_".. player_name ..";main;0,0;8,3;".. tostring(start_i) .."]".. - "table[6.05,3.35;1.15,0.5;pagenum;#FFFF00,".. tostring(pagenum) ..",#FFFFFF,/ ".. tostring(pagemax) .."]".. - default.get_hotbar_bg(0,4.7).. + "field[0.3,3.5;2.2,1;creative_filter;;" .. inv.filter .. "]" .. + "listring[detached:creative_" .. player_name .. ";main]" .. + "tabheader[0,0;creative_tabs;Crafting,All,Nodes,Tools,Items;" .. tostring(inv.tab_id) .. ";true;false]" .. + "list[detached:creative_" .. player_name .. ";main;0,0;8,3;" .. tostring(start_i) .. "]" .. + "table[6.05,3.35;1.15,0.5;pagenum;#FFFF00," .. tostring(pagenum) .. ",#FFFFFF,/ " .. tostring(pagemax) .. "]" .. + default.get_hotbar_bg(0,4.7) .. default.gui_bg .. default.gui_bg_img .. default.gui_slots ) end @@ -143,7 +145,7 @@ creative.set_crafting_formspec = function(player) listring[current_player;main] listring[current_player;craft] ]] .. - default.get_hotbar_bg(0,4.7).. + default.get_hotbar_bg(0,4.7) .. default.gui_bg .. default.gui_bg_img .. default.gui_slots ) end @@ -154,7 +156,7 @@ minetest.register_on_joinplayer(function(player) return end creative.init_creative_inventory(player) - creative.set_creative_formspec(player, 0, 1, 2) + creative.set_creative_formspec(player, 0) end) minetest.register_on_player_receive_fields(function(player, formname, fields) @@ -163,70 +165,72 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end local player_name = player:get_player_name() - local formspec = player:get_inventory_formspec() - local filter = formspec:match("creative_filter;;([%w_:]+)") or "" - local start_i = formspec:match("list%[.-".. player_name ..";.-;(%d+)%]") - local tab_id = tonumber(formspec:match("tabheader%[.-;(%d+)%;")) - local inv_size = player_inventory[player_name].size - start_i = tonumber(start_i) or 0 + local inv = player_inventory[player_name] if fields.quit then - if tab_id == 1 then + if inv.tab_id == 1 then creative.set_crafting_formspec(player) end elseif fields.creative_tabs then local tab = tonumber(fields.creative_tabs) + inv.tab_id = tab + if tab == 1 then creative.set_crafting_formspec(player) else - creative.update_creative_inventory(player_name, filter, tab) - creative.set_creative_formspec(player, 0, 1, tab) + creative.update_creative_inventory(player_name) + creative.set_creative_formspec(player, 0) end elseif fields.creative_clear then - player_inventory[player_name].filter = "" - creative.update_creative_inventory(player_name, nil, tab_id) - creative.set_creative_formspec(player, 0, 1, tab_id) + inv.filter = "" + creative.update_creative_inventory(player_name) + creative.set_creative_formspec(player, 0) elseif fields.creative_search then - local lowstr = fields.creative_filter:lower() - player_inventory[player_name].filter = lowstr - creative.update_creative_inventory(player_name, lowstr, tab_id) - creative.set_creative_formspec(player, 0, 1, tab_id) + inv.filter = fields.creative_filter:lower() + creative.update_creative_inventory(player_name) + creative.set_creative_formspec(player, 0) else + local formspec = player:get_inventory_formspec() + local start_i = formspec:match("list%[.-" .. player_name .. ";.-;(%d+)%]") + start_i = tonumber(start_i) or 0 + if fields.creative_prev then start_i = start_i - 3*8 if start_i < 0 then - start_i = inv_size - (inv_size % (3*8)) - if inv_size == start_i then - start_i = math.max(0, inv_size - (3*8)) + start_i = inv.size - (inv.size % (3*8)) + if inv.size == start_i then + start_i = math.max(0, inv.size - (3*8)) end end elseif fields.creative_next then start_i = start_i + 3*8 - if start_i >= inv_size then + if start_i >= inv.size then start_i = 0 end end - creative.set_creative_formspec(player, start_i, start_i / (3*8) + 1, tab_id) + creative.set_creative_formspec(player, start_i) end end) if minetest.setting_getbool("creative_mode") then local digtime = 0.5 + local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 3} + minetest.register_item(":", { type = "none", wield_image = "wieldhand.png", - wield_scale = {x=1, y=1, z=2.5}, + wield_scale = {x = 1, y = 1, z = 2.5}, range = 10, tool_capabilities = { full_punch_interval = 0.5, max_drop_level = 3, groupcaps = { - crumbly = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, - cracky = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, - snappy = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, - choppy = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, - oddly_breakable_by_hand = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, + crumbly = caps, + cracky = caps, + snappy = caps, + choppy = caps, + oddly_breakable_by_hand = caps, }, damage_groups = {fleshy = 10}, } From ffba9d978e2b1414c7c80ddf8c1615cbd839c993 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Sun, 20 Mar 2016 23:48:16 -0700 Subject: [PATCH 09/17] Doors: Allow schematic placement of wooden doors. If LVM or some other nonmetadata method is used to place a door, then metadata is missing that tells us whether the door is left or right-hinged. However, we can detect that nodemeta is missing and see if the node name is _a or _b. In the case of _a, nothing needs to be done and we can just open the door. In the case of _b we assume the door is right hinged, and tune the state nodemeta value so that the door opens the right way. This all of course assumes that the schematic method places the doors *closed* by default, which is reasonable. --- mods/doors/init.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mods/doors/init.lua b/mods/doors/init.lua index bd3e6998..c0fd5bff 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -132,10 +132,19 @@ local transform = { function _doors.door_toggle(pos, clicker) local meta = minetest.get_meta(pos) - local state = meta:get_int("state") local def = minetest.registered_nodes[minetest.get_node(pos).name] local name = def.door.name + local state = meta:get_string("state") + if state == "" then + -- fix up lvm-placed right-hinged doors, default closed + if minetest.get_node(pos).name:sub(-2) == "_b" then + state = 2 + end + else + state = tonumber(state) + end + if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then local owner = meta:get_string("doors_owner") if owner ~= "" then From 0d3bca790cc0ac483c801e487bd2af3101241a4c Mon Sep 17 00:00:00 2001 From: paramat Date: Mon, 21 Mar 2016 08:03:52 +0000 Subject: [PATCH 10/17] Default: Fix rotation errors for mapgen aspen and sapling jungletree --- mods/default/mapgen.lua | 1 - mods/default/trees.lua | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/mods/default/mapgen.lua b/mods/default/mapgen.lua index 3424a557..4b61518e 100644 --- a/mods/default/mapgen.lua +++ b/mods/default/mapgen.lua @@ -1204,7 +1204,6 @@ function default.register_decorations() y_max = 31000, schematic = minetest.get_modpath("default").."/schematics/aspen_tree.mts", flags = "place_center_x, place_center_z", - rotation = "random", }) minetest.register_decoration({ diff --git a/mods/default/trees.lua b/mods/default/trees.lua index c93fdabc..de2452e4 100644 --- a/mods/default/trees.lua +++ b/mods/default/trees.lua @@ -403,7 +403,7 @@ function default.grow_new_jungle_tree(pos) local path = minetest.get_modpath("default") .. "/schematics/jungle_tree_from_sapling.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, - path, "0", nil, false) + path, "random", nil, false) end From 7d55320d5c51f47b2a7e27723ce1d5e02a2a23de Mon Sep 17 00:00:00 2001 From: paramat Date: Mon, 21 Mar 2016 09:23:12 +0000 Subject: [PATCH 11/17] Default: Make some plant nodes non-flammable --- mods/default/nodes.lua | 22 +++++++++++++--------- mods/flowers/init.lua | 5 ++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 47d344fd..bb90451e 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -14,7 +14,7 @@ language (for example pinewood and pine wood) the underscore form should be used Stone ----- -(1. Material 2. Cobble variant 3. Brick variant [4. Modified forms]) +(1. Material 2. Cobble variant 3. Brick variant 4. Modified forms) default:stone default:cobble @@ -33,7 +33,7 @@ default:obsidianbrick Soft / Non-Stone ---------------- -(1. Material [2. Modified forms]) +(1. Material 2. Modified forms) default:dirt default:dirt_with_grass @@ -55,7 +55,7 @@ default:ice Trees ----- -(1. Trunk 2. Fabricated trunk 3. Leaves 4. Sapling [5. Fruits]) +(1. Trunk 2. Fabricated trunk 3. Leaves 4. Sapling 5. Fruits) default:tree default:wood @@ -82,9 +82,10 @@ default:aspen_tree default:aspen_wood default:aspen_leaves default:aspen_sapling + Ores ---- -(1. In stone 2. Block) +(1. In stone 2. Blocks) default:stone_with_coal default:coalblock @@ -107,6 +108,7 @@ default:diamondblock Plantlife (non-cubic) --------------------- + default:cactus default:papyrus default:dry_shrub @@ -139,6 +141,7 @@ default:lava_flowing Tools / "Advanced" crafting / Non-"natural" ------------------------------------------- + default:torch default:chest @@ -169,6 +172,7 @@ default:meselamp Misc ---- + default:cloud default:nyancat default:nyancat_rainbow @@ -884,7 +888,7 @@ minetest.register_node("default:cactus", { tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"}, paramtype2 = "facedir", - groups = {snappy = 1, choppy = 3, flammable = 2}, + groups = {snappy = 1, choppy = 3}, sounds = default.node_sound_wood_defaults(), on_place = minetest.rotate_node, }) @@ -942,7 +946,7 @@ minetest.register_node("default:junglegrass", { sunlight_propagates = true, walkable = false, buildable_to = true, - groups = {snappy = 3, flammable = 2, flora = 1, attached_node = 1}, + groups = {snappy = 3, flora = 1, attached_node = 1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -963,7 +967,7 @@ minetest.register_node("default:grass_1", { sunlight_propagates = true, walkable = false, buildable_to = true, - groups = {snappy = 3, flammable = 3, flora = 1, attached_node = 1}, + groups = {snappy = 3, flora = 1, attached_node = 1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -992,8 +996,8 @@ for i = 2, 5 do walkable = false, buildable_to = true, drop = "default:grass_1", - groups = {snappy = 3, flammable = 3, flora = 1, - attached_node = 1, not_in_creative_inventory = 1}, + groups = {snappy = 3, flora = 1, attached_node = 1, + not_in_creative_inventory = 1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", diff --git a/mods/flowers/init.lua b/mods/flowers/init.lua index dd90f4c9..85fa36ef 100644 --- a/mods/flowers/init.lua +++ b/mods/flowers/init.lua @@ -31,7 +31,6 @@ minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_whi local function add_simple_flower(name, desc, box, f_groups) -- Common flowers' groups f_groups.snappy = 3 - f_groups.flammable = 2 f_groups.flower = 1 f_groups.flora = 1 f_groups.attached_node = 1 @@ -134,7 +133,7 @@ minetest.register_node("flowers:mushroom_red", { sunlight_propagates = true, walkable = false, buildable_to = true, - groups = {snappy = 3, flammable = 3, attached_node = 1}, + groups = {snappy = 3, attached_node = 1}, sounds = default.node_sound_leaves_defaults(), on_use = minetest.item_eat(-5), selection_box = { @@ -153,7 +152,7 @@ minetest.register_node("flowers:mushroom_brown", { sunlight_propagates = true, walkable = false, buildable_to = true, - groups = {snappy = 3, flammable = 3, attached_node = 1}, + groups = {snappy = 3, attached_node = 1}, sounds = default.node_sound_leaves_defaults(), on_use = minetest.item_eat(1), selection_box = { From c3d2bc383b172d87ca920522dab6b5de1e82a14d Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Mon, 21 Mar 2016 11:25:25 +0100 Subject: [PATCH 12/17] Wooden Sign: Add group oddly_breakable_by_hand --- mods/default/nodes.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index bb90451e..a4b42950 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -1671,7 +1671,7 @@ end register_sign("wood", "Wooden", { sounds = default.node_sound_wood_defaults(), - groups = {choppy = 2, attached_node = 1, flammable = 2} + groups = {choppy = 2, attached_node = 1, flammable = 2, oddly_breakable_by_hand = 3} }) register_sign("steel", "Steel", { From a71948c0074aeb2fe05471fd7c4c3be34fbf6eed Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Mon, 21 Mar 2016 20:37:35 +0100 Subject: [PATCH 13/17] Books: Move page buttons at the bottom --- mods/default/craftitems.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/default/craftitems.lua b/mods/default/craftitems.lua index fc52bc42..47283820 100644 --- a/mods/default/craftitems.lua +++ b/mods/default/craftitems.lua @@ -41,12 +41,12 @@ local function book_on_use(itemstack, user) "label[0.5,0.5;by " .. owner .. "]" .. "tablecolumns[color;text]" .. "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. - "table[0.4,0;4,0.5;title;#FFFF00," .. minetest.formspec_escape(title) .. "]".. + "table[0.4,0;7,0.5;title;#FFFF00," .. minetest.formspec_escape(title) .. "]".. "textarea[0.5,1.5;7.5,7;;".. minetest.formspec_escape(text:sub( (cpp * page) - cpp, cpp * page)) .. ";]" .. - "button[4.6,0.2;0.8,0.8;book_prev;<]" .. - "label[5.35,0.3;Page " .. page .. " of " .. page_max .. "]".. - "button[7,0.2;0.8,0.8;book_next;>]" + "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) From 7cba7af894d1d0811acac8f4b042eea1ac99b9e3 Mon Sep 17 00:00:00 2001 From: Rui Date: Tue, 22 Mar 2016 16:26:36 +0900 Subject: [PATCH 14/17] Rename Glass Door (the obisian one) to Obsidian Glass Door --- mods/doors/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/doors/init.lua b/mods/doors/init.lua index c0fd5bff..2b129aa2 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -504,7 +504,7 @@ doors.register("door_glass", { doors.register("door_obsidian_glass", { tiles = { "doors_door_obsidian_glass.png" }, - description = "Glass Door", + description = "Obsidian Glass Door", inventory_image = "doors_item_obsidian_glass.png", groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 }, sounds = default.node_sound_glass_defaults(), From 7a29d26e3e6cf91b041034d45356e41f199e3cf6 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Mon, 21 Mar 2016 16:16:29 +0100 Subject: [PATCH 15/17] Fire: Allow placing only above flammable blocks --- mods/fire/init.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mods/fire/init.lua b/mods/fire/init.lua index c32b5110..c6f3d479 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -78,15 +78,19 @@ minetest.register_tool("fire:flint_and_steel", { local pt = pointed_thing if pt.type == "node" and minetest.get_node(pt.above).name == "air" then - if not minetest.is_protected(pt.above, player_name) then - minetest.set_node(pt.above, {name="fire:basic_flame"}) - else - minetest.chat_send_player(player_name, "This area is protected") + itemstack:add_wear(1000) + local node_under = minetest.get_node(pt.under).name + + if minetest.get_node_group(node_under, "flammable") >= 1 then + if not minetest.is_protected(pt.above, player_name) then + minetest.set_node(pt.above, {name = "fire:basic_flame"}) + else + minetest.chat_send_player(player_name, "This area is protected") + end end end - + if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(1000) return itemstack end end From 6749da10708fb6caa4616713fbf673ee432518fc Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Wed, 23 Mar 2016 19:31:25 +0100 Subject: [PATCH 16/17] Books: Ensure backward compatibility for older written books --- mods/default/craftitems.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/mods/default/craftitems.lua b/mods/default/craftitems.lua index 47283820..8b8a6d35 100644 --- a/mods/default/craftitems.lua +++ b/mods/default/craftitems.lua @@ -14,17 +14,19 @@ minetest.register_craftitem("default:paper", { local function book_on_use(itemstack, user) local player_name = user:get_player_name() local data = minetest.deserialize(itemstack:get_metadata()) - local formspec, title, text, text_len, page, page_max, cpp, owner = - "", "", "", 1, 1, 1, 1, player_name + local formspec, title, text, owner = "", "", "", player_name + local page, page_max, cpp = 1, 1, 650 if data then title = data.title text = data.text owner = data.owner - text_len = data.text_len - page = data.page - page_max = data.page_max - cpp = data.chars_per_page + + if data.page then + page = data.page + page_max = data.page_max + cpp = data.chars_per_page + end end if owner == player_name then @@ -41,11 +43,11 @@ local function book_on_use(itemstack, user) "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(text:sub( + "table[0.4,0;7,0.5;title;#FFFF00," .. minetest.formspec_escape(title) .. "]" .. + "textarea[0.5,1.5;7.5,7;;" .. minetest.formspec_escape(text:sub( (cpp * page) - cpp, cpp * page)) .. ";]" .. "button[2.4,7.6;0.8,0.8;book_prev;<]" .. - "label[3.2,7.7;Page " .. page .. " of " .. page_max .. "]".. + "label[3.2,7.7;Page " .. page .. " of " .. page_max .. "]" .. "button[4.9,7.6;0.8,0.8;book_next;>]" end @@ -96,6 +98,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) elseif fields.book_next or fields.book_prev then local data = minetest.deserialize(stack:get_metadata()) + if not data.page then return end + if fields.book_next then data.page = data.page + 1 if data.page > data.page_max then From 14334a1d8996316e666addf814976f87124f21ad Mon Sep 17 00:00:00 2001 From: paramat Date: Thu, 24 Mar 2016 03:00:43 +0000 Subject: [PATCH 17/17] Default: Reduce sand footstep and dug sound gains --- mods/default/functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index a85009bf..dc46726a 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -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.2} + {name = "default_sand_footstep", gain = 0.12} table.dug = table.dug or - {name = "default_sand_footstep", gain = 0.4} + {name = "default_sand_footstep", gain = 0.24} table.place = table.place or {name = "default_place_node", gain = 1.0} default.node_sound_defaults(table)