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 = {},
|
usages_cache = {},
|
||||||
recipes_cache = {},
|
recipes_cache = {},
|
||||||
cubes = {},
|
cubes = {},
|
||||||
|
plants = {},
|
||||||
|
|
||||||
tabs = {},
|
tabs = {},
|
||||||
craft_types = {},
|
craft_types = {},
|
||||||
|
|
|
@ -316,11 +316,16 @@ end
|
||||||
|
|
||||||
local function init_cubes()
|
local function init_cubes()
|
||||||
for name, def in pairs(reg_nodes) do
|
for name, def in pairs(reg_nodes) do
|
||||||
if def and def.drawtype == "normal" or def.drawtype == "liquid" or
|
if def then
|
||||||
sub(def.drawtype, 1, 9) == "glasslike" or
|
|
||||||
sub(def.drawtype, 1, 8) == "allfaces" then
|
|
||||||
local id = core.get_content_id(name)
|
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
|
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
|
for idx in area:iterp(pos1, pos2) do
|
||||||
local cube = i3.cubes[data[idx]]
|
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)
|
local p = area:position(idx)
|
||||||
p = vec_sub(p, pos)
|
p = vec_sub(p, pos)
|
||||||
|
|
||||||
local x = 2 + (size / 2 * (p.z - p.x))
|
local x = 2 + (size / 2 * (p.z - p.x))
|
||||||
local y = 1.15 + (size / 4 * (p.x + p.z - 2 * p.y))
|
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)
|
insert(fs, elem)
|
||||||
end
|
end
|
||||||
|
|
Ŝarĝante…
Reference in New Issue