Compare commits

...

2 Commits

Author SHA1 Message Date
Pascal Abresch 604250ff8b add new trees 2023-03-31 14:58:51 +02:00
Pascal Abresch a48eeb1e24 Try making half slabs nicer 2023-03-31 14:57:34 +02:00
17 changed files with 82 additions and 28 deletions

View File

@ -1,3 +1,5 @@
local orion_api_enable_half_slabs = minetest.settings:get_bool("orion_api_enable_half_slabs")
function shallow_copy(table)
local newTable = {}
for key, value in pairs(table) do
@ -22,7 +24,15 @@ local placeCombinedNode = function(position, secondNode)
end
local onPlace = function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" then return minetest.item_place(itemstack, player, pointed_thing) end
if pointed_thing.type == "node" and orion_api_enable_half_slabs then
return on_place_half_slabs(itemstack, placer, pointed_thing)
else
return minetest.item_place(itemstack, player, pointed_thing)
end
end
local on_place_half_slabs = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under
local above = pointed_thing.above
if above.y == under.y +1 then -- looking from above
@ -132,10 +142,28 @@ end
orion.register_slab_node = function(name, definition)
minetest.register_node(name, definition)
if not orion_api_enable_half_slabs then
minetest.register_node(name, definition)
return
end
local normalDef = shallow_copy(definition)
local normalDefTiles = shallow_copy(definition.tiles)
if #normalDef.tiles == 1 then
normalDef["tiles"][2] = normalDefTiles[1]
normalDef["tiles"][3] = normalDefTiles[1]
normalDef["tiles"][4] = normalDefTiles[1]
normalDef["tiles"][5] = normalDefTiles[1] .. "^[transformR180"
normalDef["tiles"][6] = normalDefTiles[1]
end
minetest.register_node(name, normalDef)
local lowerDef = shallow_copy(definition)
local upperDef = shallow_copy(definition)
local lowerDefTiles = shallow_copy(lowerDef.tiles)
lowerDef["paramtype"] = "light"
lowerDef["description"] = lowerDef["description"] or "" .. " (lower)"
lowerDef["drawtype"] = "nodebox"
@ -143,6 +171,14 @@ orion.register_slab_node = function(name, definition)
type = "fixed",
fixed = {-0.50, -0.50, -0.50, 0.50, 0.00, 0.50} }
lowerDef["on_place"] = onPlace
lowerDef["tiles"][1] = "[combine:128x128:0,-64=".. lowerDefTiles[1] .. "\\^[resize\\:128x128:0,64=".. lowerDefTiles[1] .. "\\^[resize\\:128x128"
if #lowerDefTiles == 1 then
lowerDef["tiles"][2] = lowerDefTiles[1]
lowerDef["tiles"][3] = lowerDefTiles[1]
lowerDef["tiles"][4] = lowerDefTiles[1]
lowerDef["tiles"][5] = lowerDefTiles[1] .. "^[transformR180"
lowerDef["tiles"][6] = lowerDefTiles[1]
end
local lowerGroups = shallow_copy(definition["groups"])
lowerDef.node_placement_prediction = "air"
lowerGroups.orion_slabtype = SLAB_LOWER
@ -194,18 +230,18 @@ orion.register_slab_node = function(name, definition)
secondLower["tiles"] = {
firstTiles[1],
secondTiles[2],
firstTiles[3] .. "^[lowpart:50:" .. secondTiles[3],
firstTiles[4] .. "^[lowpart:50:" .. secondTiles[4],
firstTiles[5] .. "^[lowpart:50:" .. secondTiles[5],
firstTiles[6] .. "^[lowpart:50:" .. secondTiles[6],
firstTiles[3] .. "^[resize:128x128^[lowpart:50:" .. secondTiles[3] .. "\\^[resize\\:128x128",
firstTiles[4] .. "^[resize:128x128^[lowpart:50:" .. secondTiles[4] .. "\\^[resize\\:128x128",
firstTiles[5] .. "^[resize:128x128^[lowpart:50:" .. secondTiles[5] .. "\\^[resize\\:128x128",
firstTiles[6] .. "^[resize:128x128^[lowpart:50:" .. secondTiles[6] .. "\\^[resize\\:128x128",
}
secondUpper["tiles"] = {
secondTiles[1],
firstTiles[2],
secondTiles[3] .. "^[lowpart:50:" .. firstTiles[3],
secondTiles[4] .. "^[lowpart:50:" .. firstTiles[4],
secondTiles[5] .. "^[lowpart:50:" .. firstTiles[5],
secondTiles[6] .. "^[lowpart:50:" .. firstTiles[6],
secondTiles[3] .. "^[resize:128x128^[lowpart:50:" .. firstTiles[3] .. "\\^[resize\\:128x128",
secondTiles[4] .. "^[resize:128x128^[lowpart:50:" .. firstTiles[4] .. "\\^[resize\\:128x128",
secondTiles[5] .. "^[resize:128x128^[lowpart:50:" .. firstTiles[5] .. "\\^[resize\\:128x128",
secondTiles[6] .. "^[resize:128x128^[lowpart:50:" .. firstTiles[6] .. "\\^[resize\\:128x128",
}
local groups = shallow_copy(definition["groups"])
local secondGroup = shallow_copy(definition["groups"])

View File

@ -46,24 +46,25 @@ local treedef = { -- Yes, i will use L-trees, when i can send meshes over the ne
}
orion.make_tree = function(x, y, z)
orion.make_tree = function(x, y, z, variant)
for i = 1, #treedef do
local node
if treedef[i]["leaf"] == 1 then
node = NAME .. ":leaf"
else
node = NAME .. ":trunk"
node = NAME .. ":trunk_" .. variant
end
minetest.set_node({ x=x + treedef[i]["x"], y =y + treedef[i]["y"], z = z + treedef[i]["z"]}, { name = node})
end
end
local make_trees = function(min_pos, max_pos, _)
local random = PcgRandom(min_pos.x + min_pos.y * 2^16 + min_pos.z * 2^17 )
local notification = minetest.get_mapgen_object("gennotify")
local saplings = notification["decoration#" .. sap_id]
if saplings == nil then return end
for i = 1, #saplings do
orion.make_tree(saplings[i]["x"], saplings[i]["y"], saplings[i]["z"])
orion.make_tree(saplings[i]["x"], saplings[i]["y"], saplings[i]["z"], "c0" .. random:next(1,6))
end
end

View File

@ -1,19 +1,35 @@
NAME = minetest.get_current_modname()
local variants = 6
orion.register_slab_node(NAME .. ":trunk", {
description = "Tree trunk",
groups = { flora = 3 },
node_dig_prediction = "air",
tiles = {
NAME .. "_trunk_core.png",
NAME .. "_trunk_core.png",
NAME .. "_trunk_bark.png",
NAME .. "_trunk_bark.png",
NAME .. "_trunk_bark.png",
NAME .. "_trunk_bark.png"
},
walkable = true,
})
for variant = 1, variants do
orion.register_slab_node(NAME .. ":trunk_c0" .. variant, {
description = "Tree trunk",
groups = { flora = 3, colorVariant = variant},
node_dig_prediction = "air",
tiles = {
NAME .. "_trunk_core.png",
NAME .. "_trunk_core.png",
"tree_c0" .. variant .. "_bark.png",
"tree_c0" .. variant .. "_bark.png",
"tree_c0" .. variant .. "_bark.png",
"tree_c0" .. variant .. "_bark.png"
},
walkable = true,
})
orion.register_slab_node(NAME .. ":plank_c0" .. variant, {
description = "Tree trunk",
groups = { flora = 3, colorVariant = variant},
node_dig_prediction = "air",
tiles = {
"wood_c0" .. variant .. "_plank.png",
"wood_c0" .. variant .. "_plank.png",
"wood_c0" .. variant .. "_plank.png",
"wood_c0" .. variant .. "_plank.png",
"wood_c0" .. variant .. "_plank.png",
"wood_c0" .. variant .. "_plank.png",
},
walkable = true,
})
end
orion.craft.register_fuel(NAME .. ":trunk", 60, 10)

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -6,3 +6,4 @@ spark_log (Enable console log) bool true
spark_quick_put_enabled (Left click items into inventories) bool true
spark_debug_enable ([WARNING: ARBITRARY LUA CODE [very bad!]] enable sparkdebug) bool false
orion_world_gen_decoslabs (Enabled decoration slabs worldgen) bool false
orion_api_enable_half_slabs (Enable half slabs [experimental]) bool false

BIN
textures/tree.kra Normal file

Binary file not shown.