Improve mapgen, add grass, and include the fill tool.

This commit is contained in:
Signal 2026-01-15 18:54:28 -05:00
parent 1e897665bb
commit 4659a008ac
86 changed files with 1098 additions and 293 deletions

View file

@ -0,0 +1,158 @@
minetest.register_entity(":red_glazed_terracotta:fill_tool_display", {
initial_properties = {
static_save = false,
visual = "cube",
textures = {"rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png"},
glow = 15,
visual_size = vector.new(1, 1, 1) *1.1,
pointable = false
}
})
--minetest.register_entity(":travelers_notebook:fill_tool_range_display", {
-- initial_properties = {
-- static_save = false,
-- textures = {"blank.png"},
-- glow = 15,
-- visual_size = vector.new(1, 1, 1) *0.6,
-- pointable = false
-- }
--})
local function get_shape_fill_display_pos(m)
local pos = m.pos
local dir = m.object:get_look_dir()
local node = minetest.raycast(pos, pos +(dir *(m.shape_fill_range or 5)), false):next()
if node and node.under then
pos = node.under
else
pos = (pos +(dir *(m.shape_fill_range or 5))):round()
end
return pos
end
rgt.register_item("fill_tool", {
stack_max = 1,
inventory_image = "rgt_shape_fill_tool.png",
range = 0,
touch_interaction = "short_dig_long_place",
on_use = function(s, p)
local m = rgt.players[p:get_player_name()]
if m.node_picker then
local pos = m.pos
local dir = m.object:get_look_dir()
-- local obj = minetest.raycast(pos +dir, pos +(dir *15), true, false, {nodes = {}}):next()
if m.pointed_obj or obj and obj.type == "object" then
local e = m.pointed_obj
if e.node then
local sm = s:get_meta()
if e.node == "air" then
sm:set_string("inventory_image", "")
else
local def = minetest.registered_nodes[e.node]
if def._rgt_tileset_master then e.node = def._rgt_tileset_master end
local tx = rgt.get_node_texture(e.node)
sm:set_string("inventory_image", "[combine:16x16:3,3="..tx.."\\^[resize\\:10x10:0,0=rgt_shape_fill_tool.png")
end
sm:set_string("node", e.node)
rgt.close_node_picker(m)
end
end
else
local pos = get_shape_fill_display_pos(rgt.players[p:get_player_name()])
if not pos then return end
local m = s:get_meta()
local node = minetest.get_node(pos).name
if node == "air" then
m:set_string("inventory_image", "")
else
local def = minetest.registered_nodes[node]
if def._rgt_tileset_master then node = def._rgt_tileset_master end
local tx = rgt.get_node_texture(node)
m:set_string("inventory_image", "[combine:16x16:3,3="..tx.."\\^[resize\\:10x10:0,0=rgt_shape_fill_tool.png")
end
m:set_string("node", node)
end
return s
end,
on_wield = function(m)
local pos = get_shape_fill_display_pos(m)
m.shape_fill_display_start = minetest.add_entity(pos, "red_glazed_terracotta:fill_tool_display")
m.shape_fill_display_start:set_observers{[m.name] = true}
m.shape_fill_range = m.shape_fill_range or 5
m.shape_fill_last_range = m.shape_fill_range
end,
while_wielded = function(m, s)
local pos = get_shape_fill_display_pos(m)
if not m.shape_fill_display_start and not m.node_picker then
m.shape_fill_display_start = minetest.add_entity(pos, "red_glazed_terracotta:fill_tool_display")
m.shape_fill_display_start:set_observers{[m.name] = true}
end
if m.shape_fill_display_start and m.node_picker then
m.shape_fill_display_start:remove()
m.shape_fill_display_start = nil
end
if m.shape_fill_display_end then
m.shape_fill_display_end:set_pos(pos)
elseif m.shape_fill_display_start then
m.shape_fill_display_start:set_pos(pos)
end
-- if m.shape_fill_zoom_view then
-- local pitch = m.object:get_look_vertical()
-- if math.abs(pitch) > math.rad(15) then
-- m.shape_fill_range = math.max(5, m.shape_fill_range -(0.2 *pitch))
-- if math.abs(m.shape_fill_range -(m.shape_fill_last_range or 5)) > 1 then
-- m.shape_fill_zoom_view:set_properties{
-- textures = {libarchive.rasterize(tostring(math.round(m.shape_fill_range or 5)), 40, 40, 0, 0)}
-- }
-- m.shape_fill_last_range = range
-- end
-- end
-- end
--
-- if m.ctl.zoom and not m.shape_fill_zoom_view then
-- m.shape_fill_zoom_view = minetest.add_entity(pos, "red_glazed_terracotta:fill_tool_range_display")
-- m.shape_fill_zoom_view:set_properties{
-- textures = {libarchive.rasterize(tostring(math.round(m.shape_fill_range) or 5), 40, 40, 0, 0)}
-- }
-- m.shape_fill_zoom_view:set_attach(m.object, "", vector.new(0, 20, 20), nil, true)
-- elseif not m.ctl.zoom and m.shape_fill_zoom_view then
-- m.shape_fill_zoom_view:remove()
-- m.shape_fill_zoom_view = nil
-- end
if m.shape_fill_display_end and not m.ctl.place then
local node = s:get_meta():get("node") or "air"
rgt.fill_area(m.shape_fill_start, m.shape_fill_display_end:get_pos():round(), node)
m.shape_fill_display_end:remove()
m.shape_fill_display_end = nil
elseif m.shape_fill_display_start and not m.shape_fill_display_end and m.ctl.place then
m.shape_fill_start = m.shape_fill_display_start:get_pos():round()
m.shape_fill_display_end = minetest.add_entity(get_shape_fill_display_pos(m), "red_glazed_terracotta:fill_tool_display")
m.shape_fill_display_end:set_properties{
textures = {"rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png"},
}
m.shape_fill_display_end:set_observers{[m.name] = true}
end
end,
on_unwield = function(m)
if m.shape_fill_display_start then
m.shape_fill_display_start:remove()
m.shape_fill_display_start = nil
end
if m.shape_fill_display_end then
m.shape_fill_display_end:remove()
m.shape_fill_display_end = nil
end
if m.shape_fill_zoom_view then
m.shape_fill_zoom_view:remove()
m.shape_fill_zoom_view = nil
end
m.shape_fill_start = nil
end
})

View file

@ -0,0 +1,2 @@
name = rgt_fill_tool
depends = rgt_player

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B