forked from erle/xmaps
Allow creation of maps with or without X
This commit is contained in:
parent
1df6f7dca4
commit
9879745ca2
32
init.lua
32
init.lua
|
@ -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))
|
||||||
|
|
||||||
local xpos = vector.round(pos)
|
if draw_x then
|
||||||
meta:set_string("maps:xpos", minetest.pos_to_string(xpos))
|
local xpos = vector.round(pos)
|
||||||
|
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,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue