1
0
Fork 0

Allow creation of maps with or without X

This commit is contained in:
Nils Dagsson Moskopp 2022-05-20 18:40:02 +02:00
parent 1df6f7dca4
commit 9879745ca2
Signed by untrusted user who does not match committer: erle
GPG Key ID: A3BC671C35191080
1 changed files with 19 additions and 13 deletions

View File

@ -69,7 +69,7 @@ maps.get_map_filename = function(map_id)
return "maps_map_texture_" .. map_id .. ".tga" return "maps_map_texture_" .. map_id .. ".tga"
end end
maps.create_map = function(pos) maps.create_map_item = function(pos, draw_x)
local itemstack = ItemStack("maps:map") local itemstack = ItemStack("maps:map")
local meta = itemstack:get_meta() local meta = itemstack:get_meta()
@ -82,8 +82,10 @@ maps.create_map = function(pos)
local maxp = vector.add(minp, vector.new(size - 1, size - 1, size - 1)) local maxp = vector.add(minp, vector.new(size - 1, size - 1, size - 1))
meta:set_string("maps:maxp", minetest.pos_to_string(maxp)) meta:set_string("maps:maxp", minetest.pos_to_string(maxp))
if draw_x then
local xpos = vector.round(pos) local xpos = vector.round(pos)
meta:set_string("maps:xpos", minetest.pos_to_string(xpos)) meta:set_string("maps:xpos", minetest.pos_to_string(xpos))
end
local filename = maps.get_map_filename(map_id) local filename = maps.get_map_filename(map_id)
maps.work[map_id] = true maps.work[map_id] = true
@ -733,19 +735,23 @@ minetest.register_globalstep(
end end
) )
maps.create_map_item = function(itemstack, player, pointed_thing)
local pos = player:get_pos()
if pos then
local map = maps.create_map(pos)
return map
end
end
minetest.override_item( minetest.override_item(
"map:mapping_kit", "map:mapping_kit",
{ {
on_place = maps.create_map_item, on_place = function(itemstack, player, pointed_thing)
on_secondary_use = maps.create_map_item, local pos = pointed_thing.under
if pos then
local map = maps.create_map_item(pos, true)
return map
end
end,
on_secondary_use = function(itemstack, player, pointed_thing)
local pos = player:get_pos()
if pos then
local map = maps.create_map_item(pos, false)
return map
end
end,
} }
) )