Skip to content

Commit

Permalink
Small bugfix, changed some behaviour
Browse files Browse the repository at this point in the history
* The mod should not crashed when `worldedit_shortcommands` is not enabled now.
* The alias `//ws` is only registered if `worldedit_shortcommands` is enabled (some server owner don't want short commands).
* Poster from `display_modpack` now takes first line as the title of poster (instead of merging everything into the title).
* Poster from `display_modpack` will save "Press the Edit button." in the poster content if only one line is given, that one line itself will be saved as the title.
  • Loading branch information
mnh48 authored Aug 27, 2018
1 parent b8789af commit 3963233
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

-- Load stuffs needed by the mod
local safe_region = dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua")
local alias_chatcommand = dofile(minetest.get_modpath("worldedit_shortcommands") .. "/init.lua")

-- List of supported signs
local sign_list = {
Expand Down Expand Up @@ -94,8 +93,14 @@ function worldedit.set_sign_text(pos1, pos2, sign_text)
-- If display_api is enabled but not signs_lib
elseif minetest.get_modpath("display_api") and not minetest.get_modpath("signs_lib") then
if node.name == "signs:paper_poster" then
meta:set_string("text", sign_text)
local sign_text = sign_text:gsub("\n", " ")
local entr = sign_text:find('\n')
if entr ~= nil then
meta:set_string("text", sign_text)
sign_text = sign_text:sub(1,entr-1)
else
meta:set_string("text", "Press the Edit button.")
sign_text = sign_text
end
meta:set_string("display_text", sign_text)
meta:set_string("infotext", "\""..sign_text.."\"\n".."(right-click to read more text)")
display_api.update_entities(pos)
Expand All @@ -114,8 +119,14 @@ function worldedit.set_sign_text(pos1, pos2, sign_text)
-- If both display api and signs_lib are enabled
elseif minetest.get_modpath("display_api") and minetest.get_modpath("signs_lib") then
if node.name == "signs:paper_poster" then
meta:set_string("text", sign_text)
local sign_text = sign_text:gsub("\n", " ")
local entr = sign_text:find('\n')
if entr ~= nil then
meta:set_string("text", sign_text)
sign_text = sign_text:sub(1,entr-1)
else
meta:set_string("text", "Press the Edit button.")
sign_text = sign_text
end
meta:set_string("display_text", sign_text)
meta:set_string("infotext", "\""..sign_text.."\"\n".."(right-click to read more text)")
display_api.update_entities(pos)
Expand Down Expand Up @@ -190,4 +201,7 @@ minetest.register_chatcommand("/writesign", {
})

-- Register alias for /writesign
worldedit.alias_chatcommand("/ws", "/writesign")
if minetest.get_modpath("worldedit_shortcommands") then
local alias_chatcommand = dofile(minetest.get_modpath("worldedit_shortcommands") .. "/init.lua")
worldedit.alias_chatcommand("/ws", "/writesign")
end

0 comments on commit 3963233

Please sign in to comment.