diff options
author | Wuzzy <almikes@aol.com> | 2016-08-17 00:41:42 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-08-17 00:41:42 +0200 |
commit | e59c589ff238a92531bb7a3fdfdda9d2f64d9d95 (patch) | |
tree | f83ac0a7361a429dc34a0a76d105d0eecc00616b | |
parent | 7b6c7bd734ca1dd50eea2958500842d9c97aab36 (diff) |
Don't show newlines from original descriptions
-rw-r--r-- | init.lua | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -50,6 +50,17 @@ local groups_to_string = function(grouptable, filter) end end +-- Replaces all newlines with spaces +local scrub_newlines = function(text) + local new, x = string.gsub(text, "\n", " ") + return new +end + +-- Make item description (core field) suitable for formspec +local description_for_formspec = function(description) + return minetest.formspec_escape(scrub_newlines(description)) +end + local group_to_string = function(groupname) if groupdefs[groupname] ~= nil then return groupdefs[groupname] @@ -157,7 +168,7 @@ local fuel_factoid = function(itemstring, ctype) formstring = formstring .. string.format(base, burntime_to_text(result.time)) local replaced = decremented.items[1]:get_name() if not decremented.items[1]:is_empty() and replaced ~= itemstring then - formstring = formstring .. " Using it as fuel turns it into: "..minetest.formspec_escape(minetest.registered_items[replaced].description).."." + formstring = formstring .. " Using it as fuel turns it into: "..description_for_formspec(minetest.registered_items[replaced].description).."." end formstring = formstring .. "\n" end @@ -290,7 +301,7 @@ doc.new_category("nodes", { nstring = nstring .. "Unknown Node" end end - nstring = minetest.formspec_escape(nstring) + nstring = description_for_formspec(nstring) if #nodes == 1 then formstring = formstring .. "This block connects to this block: "..nstring..".\n" elseif #nodes > 1 then @@ -475,9 +486,9 @@ doc.new_category("nodes", { local get_desc = function(stack) local desc = minetest.registered_items[stack:get_name()].description if desc == nil then - return stack:get_name() + return description_for_formspec(stack:get_name()) else - return desc + return description_for_formspec(desc) end end if data.def.drop == "" then @@ -797,6 +808,7 @@ local function gather_descs() end local hide = false local custom_image + name = scrub_newlines(name) local infotable = { name = name, hidden = hide, |