basic mineclone2 compatibility
This commit is contained in:
parent
c18d68f26d
commit
0569927f33
50
init.lua
50
init.lua
@ -7,6 +7,7 @@ local default_modpath = minetest.get_modpath("default")
|
|||||||
local unified_inventory_modpath = minetest.get_modpath("unified_inventory")
|
local unified_inventory_modpath = minetest.get_modpath("unified_inventory")
|
||||||
local sfinv_buttons_modpath = minetest.get_modpath("sfinv_buttons")
|
local sfinv_buttons_modpath = minetest.get_modpath("sfinv_buttons")
|
||||||
local sfinv_modpath = minetest.get_modpath("sfinv")
|
local sfinv_modpath = minetest.get_modpath("sfinv")
|
||||||
|
local mcl_books_modpath = minetest.get_modpath("mcl_books")
|
||||||
|
|
||||||
local modstore = minetest.get_mod_storage()
|
local modstore = minetest.get_mod_storage()
|
||||||
|
|
||||||
@ -30,6 +31,24 @@ local GENERAL_CATEGORY = 3
|
|||||||
local ccompass_prefix = "ccompass:"
|
local ccompass_prefix = "ccompass:"
|
||||||
local ccompass_prefix_length = #ccompass_prefix
|
local ccompass_prefix_length = #ccompass_prefix
|
||||||
|
|
||||||
|
local book_unwritten
|
||||||
|
local book_written
|
||||||
|
local author_meta_field
|
||||||
|
if default_modpath then
|
||||||
|
book_unwritten = "default:book"
|
||||||
|
book_written = "default:book_written"
|
||||||
|
author_meta_field = "owner"
|
||||||
|
elseif mcl_books_modpath then
|
||||||
|
book_unwritten = "mcl_books:book"
|
||||||
|
book_written = "mcl_books:written_book"
|
||||||
|
author_meta_field = "author"
|
||||||
|
end
|
||||||
|
|
||||||
|
local mcl_formspec_itemslot
|
||||||
|
if mcl_formspec then
|
||||||
|
mcl_formspec_itemslot = mcl_formspec.get_itemslot_bg
|
||||||
|
end
|
||||||
|
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
-- Data store
|
-- Data store
|
||||||
|
|
||||||
@ -146,10 +165,10 @@ local function write_book(player_name)
|
|||||||
topic = topic .. ": " .. first_line(content)
|
topic = topic .. ": " .. first_line(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
local new_book = ItemStack("default:book_written")
|
local new_book = ItemStack(book_written)
|
||||||
local meta = new_book:get_meta()
|
local meta = new_book:get_meta()
|
||||||
|
|
||||||
meta:set_string("owner", player_name)
|
meta:set_string(author_meta_field, player_name)
|
||||||
meta:set_string("title", topic:sub(1, max_title_size))
|
meta:set_string("title", topic:sub(1, max_title_size))
|
||||||
meta:set_string("description", S("\"@1\" by @2", truncate_string(topic, short_title_size), player_name))
|
meta:set_string("description", S("\"@1\" by @2", truncate_string(topic, short_title_size), player_name))
|
||||||
meta:set_string("text", content:sub(1, max_text_size))
|
meta:set_string("text", content:sub(1, max_text_size))
|
||||||
@ -206,7 +225,7 @@ end
|
|||||||
|
|
||||||
local function write_item(player_name, itemstack)
|
local function write_item(player_name, itemstack)
|
||||||
local item_name = itemstack:get_name()
|
local item_name = itemstack:get_name()
|
||||||
if item_name == "default:book" then
|
if item_name == book_unwritten then
|
||||||
return write_book(player_name)
|
return write_book(player_name)
|
||||||
end
|
end
|
||||||
if item_name == "compassgps:cgpsmap" then
|
if item_name == "compassgps:cgpsmap" then
|
||||||
@ -276,7 +295,7 @@ end
|
|||||||
|
|
||||||
local function read_item(itemstack, player_name)
|
local function read_item(itemstack, player_name)
|
||||||
local item_name = itemstack:get_name()
|
local item_name = itemstack:get_name()
|
||||||
if item_name == "default:book_written" then
|
if item_name == book_written then
|
||||||
read_book(itemstack, player_name)
|
read_book(itemstack, player_name)
|
||||||
elseif item_name == "compassgps:cgpsmap_marked" then
|
elseif item_name == "compassgps:cgpsmap_marked" then
|
||||||
read_cgpsmap(itemstack, player_name)
|
read_cgpsmap(itemstack, player_name)
|
||||||
@ -295,7 +314,7 @@ local function ccompass_permitted_target(itemstack)
|
|||||||
-- setting compasses when node type restriction is enabled.
|
-- setting compasses when node type restriction is enabled.
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if not itemstack:get_name():sub(1,ccompass_prefix_length) == ccompass_prefix then
|
if not (itemstack:get_name():sub(1,ccompass_prefix_length) == ccompass_prefix) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local meta = itemstack:get_meta()
|
local meta = itemstack:get_meta()
|
||||||
@ -321,7 +340,7 @@ local detached_callbacks = {
|
|||||||
allow_put = function(inv, listname, index, stack, player)
|
allow_put = function(inv, listname, index, stack, player)
|
||||||
local stack_name = stack:get_name()
|
local stack_name = stack:get_name()
|
||||||
if listname == "export_item" then
|
if listname == "export_item" then
|
||||||
if stack_name == "default:book" then
|
if stack_name == book_unwritten then
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
@ -334,13 +353,14 @@ local detached_callbacks = {
|
|||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
elseif listname == "import_item" then
|
elseif listname == "import_item" then
|
||||||
if stack_name == "default:book_written" or
|
if stack_name == book_written or
|
||||||
stack_name == "compassgps:cgpsmap_marked" or
|
stack_name == "compassgps:cgpsmap_marked" or
|
||||||
ccompass_permitted_source(stack) then
|
ccompass_permitted_source(stack) then
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
return 0
|
||||||
end,
|
end,
|
||||||
on_put = function(inv, listname, index, stack, player)
|
on_put = function(inv, listname, index, stack, player)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
@ -356,7 +376,7 @@ local detached_callbacks = {
|
|||||||
|
|
||||||
local item_invs = {}
|
local item_invs = {}
|
||||||
local function ensure_detached_inventory(player_name)
|
local function ensure_detached_inventory(player_name)
|
||||||
if item_invs[player_name] or not(default_modpath or ccompass_modpath or compassgps_modpath) then
|
if item_invs[player_name] or not(default_modpath or mcl_books_modpath or ccompass_modpath or compassgps_modpath) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local inv = minetest.create_detached_inventory("personal_log_"..player_name, detached_callbacks)
|
local inv = minetest.create_detached_inventory("personal_log_"..player_name, detached_callbacks)
|
||||||
@ -387,7 +407,7 @@ end
|
|||||||
local import_mods = {}
|
local import_mods = {}
|
||||||
local export_generic_mods = {}
|
local export_generic_mods = {}
|
||||||
local export_location_mods = {}
|
local export_location_mods = {}
|
||||||
if default_modpath then
|
if default_modpath or mcl_books_modpath then
|
||||||
table.insert(import_mods, S("a book"))
|
table.insert(import_mods, S("a book"))
|
||||||
table.insert(export_generic_mods, S("a book"))
|
table.insert(export_generic_mods, S("a book"))
|
||||||
table.insert(export_location_mods, S("a book"))
|
table.insert(export_location_mods, S("a book"))
|
||||||
@ -437,6 +457,11 @@ local function item_formspec(player_name, category, listname, topic)
|
|||||||
.. "list[current_player;main;0,1.5;8,4;]"
|
.. "list[current_player;main;0,1.5;8,4;]"
|
||||||
.. "listring[]"
|
.. "listring[]"
|
||||||
.. "button[3.5,5.5;1,1;back;"..S("Back").."]"
|
.. "button[3.5,5.5;1,1;back;"..S("Back").."]"
|
||||||
|
|
||||||
|
if mcl_formspec_itemslot then
|
||||||
|
formspec = formspec .. mcl_formspec_itemslot(3.5, 0, 1, 1)
|
||||||
|
.. mcl_formspec_itemslot(0,1.5,8,4)
|
||||||
|
end
|
||||||
|
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
@ -507,7 +532,7 @@ local function make_personal_log_formspec(player)
|
|||||||
formspec[#formspec+1] = "button[7,0.75;2,0.5;teleport;"..S("Teleport") .."]"
|
formspec[#formspec+1] = "button[7,0.75;2,0.5;teleport;"..S("Teleport") .."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if default_modpath or ccompass_modpath or compassgps_modpath then
|
if default_modpath or mcl_books_modpath or ccompass_modpath or compassgps_modpath then
|
||||||
formspec[#formspec+1] = "button[0,0.75;2.0,0.5;copy_to;"..S("Export").."]"
|
formspec[#formspec+1] = "button[0,0.75;2.0,0.5;copy_to;"..S("Export").."]"
|
||||||
.."button[2,0.75;2.0,0.5;copy_from;"..S("Import").."]"
|
.."button[2,0.75;2.0,0.5;copy_from;"..S("Import").."]"
|
||||||
end
|
end
|
||||||
@ -710,8 +735,9 @@ end
|
|||||||
|
|
||||||
-----------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------
|
||||||
-- Craftable item
|
-- Craftable item
|
||||||
|
local craftable_setting = minetest.settings:get_bool("personal_log_craftable_item", false)
|
||||||
|
|
||||||
if minetest.settings:get_bool("personal_log_craftable_item", false) then
|
if craftable_setting or not (unified_inventory_modpath or sfinv_modpath or sfinv_buttons_modpath) then
|
||||||
|
|
||||||
minetest.register_craftitem("personal_log:book", {
|
minetest.register_craftitem("personal_log:book", {
|
||||||
description = S("Personal Log"),
|
description = S("Personal Log"),
|
||||||
@ -725,7 +751,7 @@ minetest.register_craftitem("personal_log:book", {
|
|||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "personal_log:book",
|
output = "personal_log:book",
|
||||||
recipe = {{"default:book", "default:book"}}
|
recipe = {{book_unwritten, book_unwritten}}
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
2
mod.conf
2
mod.conf
@ -1,3 +1,3 @@
|
|||||||
name = personal_log
|
name = personal_log
|
||||||
description = A personal log where players can track events and places
|
description = A personal log where players can track events and places
|
||||||
optional_depends = unified_inventory, sfinv_buttons, sfinv, ccompass, default, compassgps
|
optional_depends = unified_inventory, sfinv_buttons, sfinv, ccompass, default, compassgps, mcl_books, mcl_formspec
|
||||||
|
Loading…
x
Reference in New Issue
Block a user