diff --git a/settlements/admin_tools.lua b/settlements/admin_tools.lua index 214c0ce..926e1b3 100644 --- a/settlements/admin_tools.lua +++ b/settlements/admin_tools.lua @@ -102,3 +102,61 @@ minetest.register_craftitem("settlements:single_building_tool", { end end, }) + +minetest.register_craftitem("settlements:mark_location_tool", { + description = S("Settlements tool for marking: @1", S("Unset")), + inventory_image = "settlements_location_marker.png", + stack_max = 1, + + on_place = function(itemstack, placer, pointed_thing) + local meta = itemstack:get_meta() + local settlement_type = meta:get_string("type") + + if settlement_type == "" then + settlement_type = next(settlements.registered_settlements) + else + settlement_type = next(settlements.registered_settlements, settlement_type) + if not settlement_type then + settlement_type = next(settlements.registered_settlements) + end + end + + meta:set_string("type", settlement_type) + local desc_string = S("Settlements tool for marking: @1", settlement_type) + meta:set_string("description", desc_string) + minetest.chat_send_player(placer:get_player_name(), desc_string) + return itemstack + end, + + -- Mark a settlement here, regardless of environment + on_use = function(itemstack, placer, pointed_thing) + if not minetest.check_player_privs(placer, "server") then + minetest.chat_send_player(placer:get_player_name(), S("You need the server privilege to use this tool.")) + return + end + + local meta = itemstack:get_meta() + local settlement_type = meta:get_string("type") + local settlement_def = settlements.registered_settlements[settlement_type] + if not settlement_def then + return + end + + local center_surface = pointed_thing.under + if center_surface then + local existing_area = settlements.settlements_in_world:get_areas_for_pos(center_surface, true, true) + if next(existing_area) then + minetest.chat_send_player(placer:get_player_name(), S("There's already a settlement at @1", minetest.pos_to_string(center_surface))) + return + end + + local name = settlement_def.generate_name(center_surface) + minetest.chat_send_player(placer:get_player_name(), S("Marked settlement @1 at @2", name, minetest.pos_to_string(center_surface))) + -- add settlement to list + settlements.settlements_in_world:insert_area(center_surface, center_surface, + minetest.serialize({name=name, discovered_by = {}, settlement_type = settlement_type})) + -- save list to file + settlements.settlements_save() + end + end, +}) diff --git a/settlements/bookgen.lua b/settlements/bookgen.lua index 98a3a07..9bd58c5 100644 --- a/settlements/bookgen.lua +++ b/settlements/bookgen.lua @@ -40,9 +40,9 @@ local half_map_chunk_size = settlements.half_map_chunk_size minetest.register_abm({ label = "Settlement book authoring", nodenames = {"default:bookshelf"}, - interval = 86400, -- daily + interval = 86400/2, -- twice daily -- Operation interval in seconds - chance = 2, + chance = 1, -- Chance of triggering `action` per-node per-interval is 1.0 / this value catch_up = true, -- If true, catch-up behaviour is enabled: The `chance` value is diff --git a/settlements/textures/license.txt b/settlements/textures/license.txt index b1961cd..27e2317 100644 --- a/settlements/textures/license.txt +++ b/settlements/textures/license.txt @@ -1,2 +1,3 @@ settlements_settlement_marker.png - from https://commons.wikimedia.org/wiki/File:Map_marker_icon_%E2%80%93_Nicolas_Mollet_%E2%80%93_Small_City_%E2%80%93_Tourism_%E2%80%93_Classic.png by Nicolas Mollet under the CC-BY-SA 3.0 -settlements_building_marker.png - the preceeding file, mixed with https://commons.wikimedia.org/wiki/File:Village_image_icon.svg by Sławek Borewicz under the CC-BY-SA 3.0 license \ No newline at end of file +settlements_building_marker.png - the preceding file, mixed with https://commons.wikimedia.org/wiki/File:Village_image_icon.svg by Sławek Borewicz under the CC-BY-SA 3.0 license +settlements_location_marker.png - the preceding file, mixed with https://commons.wikimedia.org/wiki/File:Map_icons_by_Scott_de_Jonge_-_embassy.svg by Scott de Jonge under the CC-BY-SA 3.0 license \ No newline at end of file diff --git a/settlements/textures/settlements_location_marker.png b/settlements/textures/settlements_location_marker.png new file mode 100644 index 0000000..73942f2 Binary files /dev/null and b/settlements/textures/settlements_location_marker.png differ