mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-25 18:30:38 +01:00
Support for plantlike in isometric map preview
This commit is contained in:
parent
eaf7c486b8
commit
b92857b42a
1
init.lua
1
init.lua
@ -43,6 +43,7 @@ i3 = {
|
||||
usages_cache = {},
|
||||
recipes_cache = {},
|
||||
cubes = {},
|
||||
plants = {},
|
||||
|
||||
tabs = {},
|
||||
craft_types = {},
|
||||
|
@ -316,11 +316,16 @@ end
|
||||
|
||||
local function init_cubes()
|
||||
for name, def in pairs(reg_nodes) do
|
||||
if def and def.drawtype == "normal" or def.drawtype == "liquid" or
|
||||
sub(def.drawtype, 1, 9) == "glasslike" or
|
||||
sub(def.drawtype, 1, 8) == "allfaces" then
|
||||
if def then
|
||||
local id = core.get_content_id(name)
|
||||
i3.cubes[id] = get_cube(def.tiles)
|
||||
|
||||
if def.drawtype == "normal" or def.drawtype == "liquid" or
|
||||
sub(def.drawtype, 1, 9) == "glasslike" or
|
||||
sub(def.drawtype, 1, 8) == "allfaces" then
|
||||
i3.cubes[id] = get_cube(def.tiles)
|
||||
elseif sub(def.drawtype, 1, 9) == "plantlike" or sub(def.drawtype, 1, 8) == "firelike" then
|
||||
i3.plants[id] = def.inventory_image .. "^\\[resize:16x16"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
11
src/gui.lua
11
src/gui.lua
@ -243,14 +243,21 @@ local function get_isometric_view(fs, pos, X, Y)
|
||||
|
||||
for idx in area:iterp(pos1, pos2) do
|
||||
local cube = i3.cubes[data[idx]]
|
||||
local plant = i3.plants[data[idx]]
|
||||
|
||||
if cube then
|
||||
if cube or plant then
|
||||
local p = area:position(idx)
|
||||
p = vec_sub(p, pos)
|
||||
|
||||
local x = 2 + (size / 2 * (p.z - p.x))
|
||||
local y = 1.15 + (size / 4 * (p.x + p.z - 2 * p.y))
|
||||
local elem = fmt("image[%f,%f;%.1f,%.1f;%s]", x + X, y + Y, size, size, cube)
|
||||
local elem
|
||||
|
||||
if cube then
|
||||
elem = fmt("image[%f,%f;%.1f,%.1f;%s]", x + X, y + Y, size, size, cube)
|
||||
else
|
||||
elem = fmt("image[%f,%f;%.1f,%.1f;%s]", x + X, y + Y, size - 0.05, size - 0.05, plant)
|
||||
end
|
||||
|
||||
insert(fs, elem)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user