Skip to content

Commit

Permalink
add admin tool to force mark a settlement without building anything
Browse files Browse the repository at this point in the history
  • Loading branch information
FaceDeer committed Jan 24, 2020
1 parent 237f922 commit 8b9749a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
58 changes: 58 additions & 0 deletions settlements/admin_tools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
4 changes: 2 additions & 2 deletions settlements/bookgen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion settlements/textures/license.txt
Original file line number Diff line number Diff line change
@@ -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
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
Binary file added settlements/textures/settlements_location_marker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8b9749a

Please sign in to comment.