Making a node grab the texture of a touching node?
Making a node grab the texture of a touching node?
Hey, new guy here, I was wondering if anyone could help me figure out how to make a node grab the texture from a touching node. It's hard to find any comprehensive guides to modding minetest. I'm trying to make my ore nodes use the base texture of the surrounding stone, and I have multiple types of stone. (like the Underground Challenge mod).
If anyone here could help me, I'd greatly appreciate it.
If anyone here could help me, I'd greatly appreciate it.
- Skamiz Kazzarch
- Member
- Posts: 613
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: Making a node grab the texture of a touching node?
Short answer: NO
Long answer: Minetest is rather obstuse in that every node gets one look and you can't change it at runtime.
There are several issues requesting the feature that you need on github, but no implementation as far as I know.
The closest you can get to it for now is something called Hardware coloring:
https://github.com/minetest/minetest/bl ... i.txt#L583
It allows you to uniformly tint a node with one collor.
If you further combine it with overlay_tiles
https://github.com/minetest/minetest/bl ... .txt#L6568
to make a part of the node texture not tinted, you could probably aproximate it to some extent.
But I haven't used either of these features yet myself, so this is mostly speculation.
And lastly, even if this all works as intended, it will be probably not be possible to color the ores at generation time.
But If you got this far you could probably use an LBM
https://github.com/minetest/minetest/bl ... .txt#L6330
to collor the nodes when the player get's cose to them.
It wouldn't be what you had in mind, but it would be closer than what I have seen so far in any other mod.
Long answer: Minetest is rather obstuse in that every node gets one look and you can't change it at runtime.
There are several issues requesting the feature that you need on github, but no implementation as far as I know.
The closest you can get to it for now is something called Hardware coloring:
https://github.com/minetest/minetest/bl ... i.txt#L583
It allows you to uniformly tint a node with one collor.
If you further combine it with overlay_tiles
https://github.com/minetest/minetest/bl ... .txt#L6568
to make a part of the node texture not tinted, you could probably aproximate it to some extent.
But I haven't used either of these features yet myself, so this is mostly speculation.
And lastly, even if this all works as intended, it will be probably not be possible to color the ores at generation time.
But If you got this far you could probably use an LBM
https://github.com/minetest/minetest/bl ... .txt#L6330
to collor the nodes when the player get's cose to them.
It wouldn't be what you had in mind, but it would be closer than what I have seen so far in any other mod.
Re: Making a node grab the texture of a touching node?
hmmm, thats unfortunate. it that something hardcoded into the irrlicht engine, or just minetest? i will try your way for now, but it unfortunately means i cant use my individual textures for different stone, if all i can do is recolor them
- Skamiz Kazzarch
- Member
- Posts: 613
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: Making a node grab the texture of a touching node?
For the answer to that you would need a core dev I fear.Winter94 wrote:hmmm, thats unfortunate. it that something hardcoded into the irrlicht engine, or just minetest?
For what it's worth I think it would be preferable to have unique stone textures and just accept that the ores won't blend in as well, rather then sacrifice texture diversity. I am all in favor for texture diversity.
Spoiler
Or you could just compleately forget about using hardware coloring and register a new node for every stone type in which the ore appears.
If you compare with, for example, the `moreblock`s circular saw which registers 45 new nodes for every basic building type of node (trees, wood, stone, bricks, glass, etc...). + usualy if it's on a server there will be several other mods whichs nodes get this treatment it quickly adds to the thousands. And it works just fine!
Aditionaly the ores won't even be nodeboxes and models like the shapes produced by the circular saw.(I presume.) So it has an even lower cost to include them!
If people are fine with many hundreds of nodes, most of which will never be used, they will be fine with the comperatively few nodes to make your ores blend in better.
- Attachments
-
- stones.png (919.68 KiB) Viewed 736 times
- TumeniNodes
- Member
- Posts: 2941
- Joined: Fri Feb 26, 2016 19:49
- GitHub: TumeniNodes
- IRC: tumeninodes
- In-game: TumeniNodes
- Location: in the dark recesses of the mind
- Contact:
Re: Making a node grab the texture of a touching node?
As a mod,
Just register your new "" stone with ore nodes like
https://github.com/minetest/minetest_ga ... .lua#L1168
and then be sure to add them into the mapgen code like
https://github.com/minetest/minetest_ga ... n.lua#L136
Just register your new "" stone with ore nodes like
https://github.com/minetest/minetest_ga ... .lua#L1168
and then be sure to add them into the mapgen code like
https://github.com/minetest/minetest_ga ... n.lua#L136
A Wonderful World
- Krock
- Developer
- Posts: 4649
- Joined: Thu Oct 03, 2013 07:48
- GitHub: SmallJoker
- Location: Switzerland
- Contact:
Re: Making a node grab the texture of a touching node?
Core dev answer here.
You would like to register nodes. This happens in server-side mods. IIRC - the server basically only needs the Irrlicht headers to compile. This means that the server has absolutely no clue how the world eventually looks like.
To create a seamless transition from one stone type to another consider bulk-registering them as different nodes (but with the same "drop" value in the definition).
As mentioned above, hardware-coloring can be used to only register one stone and one ore node (plus palette image). As a trade-off your code size will increase due to special node handling for param2 (keeps palette index).
You would like to register nodes. This happens in server-side mods. IIRC - the server basically only needs the Irrlicht headers to compile. This means that the server has absolutely no clue how the world eventually looks like.
To create a seamless transition from one stone type to another consider bulk-registering them as different nodes (but with the same "drop" value in the definition).
As mentioned above, hardware-coloring can be used to only register one stone and one ore node (plus palette image). As a trade-off your code size will increase due to special node handling for param2 (keeps palette index).
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
- Linuxdirk
- Member
- Posts: 3216
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Making a node grab the texture of a touching node?
So you need to register n^n nodes for having seamless transitions?Krock wrote:To create a seamless transition from one stone type to another consider bulk-registering them as different nodes (but with the same "drop" value in the definition).
Why is this so unnecessary complex and inconveniently complicated and inflexible in the first place? Why not simply have a node meta data "color" that can be set to any ColorSpec to colorize the node?Krock wrote:As a trade-off your code size will increase due to special node handling for param2 (keeps palette index).
Re: Making a node grab the texture of a touching node?
Ok, so after reading the replies to this post, i have been trying to register a separate node for each type of ore that can be set into each type of stone. Example: galena_in_gabbro, galena_in_phyllite, galena_in_granite, hematite_in_granite, hematite_in_gneiss, hematite_in_pegmatite, diamond_in_kimberlite, etc, etc.
Each one uses the texture for that type ore ore/mineral, and lays it over the texture for that type of stone. is this the best way to do this, or should I create a separate texture for each node so it doesnt have to pull from 2 images?
and i unfortunately cant register them en mass, i dont think, since each of them can only spawn in whatevver layer of stone. I'm using a modified version of the stone layers from underchallenge. I've been using code from underchallenge and real minerals in an attempt to create a more realistic mining/smithing experience. I have around 54 types of metals/alloys registered, and im going to start work on adding a bloomery, smelter, forge, and a few other things as soon as i get my world generating just right.My apologies for being a total noob [most of my experience coding was creating mods for Dwarf Fortress], but is there a way I can bulk register all of the ore/minerals that generate in the same stone layers, and still give each of them the various correct drops?
Each one uses the texture for that type ore ore/mineral, and lays it over the texture for that type of stone. is this the best way to do this, or should I create a separate texture for each node so it doesnt have to pull from 2 images?
and i unfortunately cant register them en mass, i dont think, since each of them can only spawn in whatevver layer of stone. I'm using a modified version of the stone layers from underchallenge. I've been using code from underchallenge and real minerals in an attempt to create a more realistic mining/smithing experience. I have around 54 types of metals/alloys registered, and im going to start work on adding a bloomery, smelter, forge, and a few other things as soon as i get my world generating just right.My apologies for being a total noob [most of my experience coding was creating mods for Dwarf Fortress], but is there a way I can bulk register all of the ore/minerals that generate in the same stone layers, and still give each of them the various correct drops?
- Nathan.S
- Member
- Posts: 1147
- Joined: Wed Sep 24, 2014 17:47
- GitHub: NathanSalapat
- IRC: NathanS21
- In-game: NathanS21
- Location: Bigsby Texas
- Contact:
Re: Making a node grab the texture of a touching node?
You can create a table with the bits of data that will be specific to each node, and then use a for loop to put that data into the node registration.
I have an older video on the topic here; https://www.nathansalapat.com/minetest/ ... s-minetest
I have an older video on the topic here; https://www.nathansalapat.com/minetest/ ... s-minetest
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course
Check out my website, and brand new Minetest Modding Course
- Linuxdirk
- Member
- Posts: 3216
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Making a node grab the texture of a touching node?
This actually would be a nice feature request.
Instead of registering ores for all various types of stones from default and other mods, maybe have a special node field allowing to define that the node should use the same textures as the majority of directly adjacent nodes plus a defined overlay texture. That would reduce the amount of registered nodes for ores 1 and would make it automatically compatible with all other mods.
Unfortunately this is impossible without a lot of engine work (i.e. not hardcoding textures on registration but dynamically set them via node meta data).
Instead of registering ores for all various types of stones from default and other mods, maybe have a special node field allowing to define that the node should use the same textures as the majority of directly adjacent nodes plus a defined overlay texture. That would reduce the amount of registered nodes for ores 1 and would make it automatically compatible with all other mods.
Unfortunately this is impossible without a lot of engine work (i.e. not hardcoding textures on registration but dynamically set them via node meta data).
- Krock
- Developer
- Posts: 4649
- Joined: Thu Oct 03, 2013 07:48
- GitHub: SmallJoker
- Location: Switzerland
- Contact:
Re: Making a node grab the texture of a touching node?
What's a seamless transition? Why "n^n"? Sorry, I don't get your question.Linuxdirk wrote:So you need to register n^n nodes for having seamless transitions?
Interestingly I had a tiring discussion only about a week ago.Linuxdirk wrote:Why not simply have a node meta data "color" that can be set to any ColorSpec to colorize the node?
Metadata needs to be looked up by string-indexing (already slow) and then the string value needs to be converted to a color (slow again) in order to cache a single node in the mapblock mesh generator.
Short: u8 param2 comparing is by far faster than using metadata.
Depending on what's easier for you. Combining only happens once and the resulting texture cached afterwards, so I'd use two textures where one can also be used for the raw stone definition.Winter94 wrote:or should I create a separate texture for each node so it doesnt have to pull from 2 images?
You could try to combine some information inside a table, such as ore names. For example:Winter94 wrote:but is there a way I can bulk register all of the ore/minerals that generate in the same stone layers, and still give each of them the various correct drops?
Code: Select all
local my_ore_names = { "silver", "gold", "zinc", "more...." }
local function register_ores(stone_name)
local stone = stone_name:split(":")[2]
for _, ore in pairs(my_ore_names) do
local ore_name = "mymod:" .. ore .. "_in_" .. stone
minetest.register_node(ore_name, {
...
drop = "mymod:" .. ore .. "_ingot",
...
})
-- If all ores should be the same:
minetest.register_ore({
ore = ore_name,
wherein = stone_name,
...
})
end
end
register_ores("default:stone")
register_ores("default:desertstone")
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
- Linuxdirk
- Member
- Posts: 3216
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Making a node grab the texture of a touching node?
Krock wrote:What's a seamless transition?
Code: Select all
_____ _____ _____
| | | |
| A | A/B | B |
| | | |
‾‾‾‾‾ ‾‾‾‾‾ ‾‾‾‾‾
Code: Select all
_____ _____
| | |
| A | B |
| | |
‾‾‾‾‾ ‾‾‾‾‾
Because you have n different node types and want to have transitions between all of them.Krock wrote:Why "n^n"?
But less flexible and straightforward. You can’t even have full rotation and full color palette because everything is crammed into param2.Krock wrote:[…]Linuxdirk wrote:Why not simply have a node meta data "color" that can be set to any ColorSpec to colorize the node?
Short: u8 param2 comparing is by far faster than using metadata.
And about what speeds are we talking here? Differences by a few milliseconds that are not noticeable in reality? Or 10+ seconds for each map block?
- Krock
- Developer
- Posts: 4649
- Joined: Thu Oct 03, 2013 07:48
- GitHub: SmallJoker
- Location: Switzerland
- Contact:
Re: Making a node grab the texture of a touching node?
Yes, currently it's not a great solution, but the fastest you can achieve.Linuxdirk wrote:But less flexible and straightforward. You can’t even have full rotation and full color palette because everything is crammed into param2.
And about what speeds are we talking here? Differences by a few milliseconds that are not noticeable in reality? Or 10+ seconds for each map block?
I'd prefer to not make up some very rough guessed numbers, but we both can agree that an additional map lookup (where key and value are both strings!) and type conversion here and here will slow down the mesh generator quite a bit.
This is used whenever the mesh outdates. That is: for every node that changes visually (dig, place, replace and animation probably too).
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
Re: Making a node grab the texture of a touching node?
ok, OP here, this is what I have so far, but I have some kind of syntax error with my table loop. can someone who knows more please tell me whats wrong?
Code: Select all
underforge.minerals = {}
local mineral_table = { --name, desc, strata, rarity
{"corundum", "Corundum", "gneiss", 10*10*10,},
{"corundum", "Corundum", "mica", 10*10*10,},
{"corundum", "Corundum", "schist", 10*10*10,},
{"corundum", "Corundum", "pegmatite", 10*10*10,},
{"tetrahedrite", "Tetrahedrite", "diorite", 10*10*10,},
{"tetrahedrite", "Tetrahedrite", "pegmatite", 10*10*10,},
{"tetrahedrite", "Tetrahedrite", "phyllite", 10*10*10,},
{"cassiterite", "Cassiterite", "andesite", 10*10*10,},
{"cassiterite", "Cassiterite", "basalt", 10*10*10,},
{"cassiterite", "Cassiterite", "gabbro", 10*10*10,},
{"sphalerite", "Sphalerite", "andesite", 10*10*10,},
{"sphalerite", "Sphalerite", "dolomite", 10*10*10,},
{"sphalerite", "Sphalerite", "gneiss", 10*10*10,},
{"bismuthinite", "Bismuthinite", "diorite", 10*10*10,},
{"bismuthinite", "Bismuthinite", "granite", 10*10*10,},
{"bismuthinite", "Bismuthinite", "pegmatite", 10*10*10,},
}
for i in ipairs (mineral_table) do
local name = mineral_table[i][1]
local desc = mineral_table[i][2]
local strata = mineral_table[i][3]
local rarity = mineral_table[i][4]
local register_node("underforge:"..name){
description = desc,
tiles = strata..".png"^"ore_"..name..".png",
groups = {cracky = 3, minerals = 1},
drop = "underforge:"..name.."_chunk",
sounds = default.node_sound_stone_defaults(),
end,
})
end
local register_ore("underforge:"..name){
ore_type = "scatter",
ore = "underforge:"..name.."_in_"..strata,
wherein = "underforge:"..strata,
clust_scarcity = {rarity},
clust_size = 5,
clust_num_ores = 10,
end,
})
end
local register_craftitem("underforge:"..name){
description = S("Chunk of" ..desc ),
groups = {rocks = 1, minerals = 2},
inventory_image = "chunk_"..name..".png",
end,
})
end
- Skamiz Kazzarch
- Member
- Posts: 613
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: Making a node grab the texture of a touching node?
I asume that by: 'local register_node()' you meant to call the registration function which would actualy be: ' minetest.register_node()'
Function calls can't be local, only ther declarations.
Another thing is that you have way to many end statements. Asuming that you don't mean to declare any new functions you only need on to close the for loop.
And lastly, you aren't passing the function arguments properly. From the api:
whereas what you are doing is:
Here it is ifxed as far as I can tell right now without actualy running the code:
Function calls can't be local, only ther declarations.
Another thing is that you have way to many end statements. Asuming that you don't mean to declare any new functions you only need on to close the for loop.
And lastly, you aren't passing the function arguments properly. From the api:
Code: Select all
minetest.register_node(name, node definition)
Code: Select all
minetest.register_node(name)node definition)
Code: Select all
underforge.minerals = {}
local mineral_table = { --name, desc, strata, rarity
{"corundum", "Corundum", "gneiss", 10*10*10,},
{"corundum", "Corundum", "mica", 10*10*10,},
{"corundum", "Corundum", "schist", 10*10*10,},
{"corundum", "Corundum", "pegmatite", 10*10*10,},
{"tetrahedrite", "Tetrahedrite", "diorite", 10*10*10,},
{"tetrahedrite", "Tetrahedrite", "pegmatite", 10*10*10,},
{"tetrahedrite", "Tetrahedrite", "phyllite", 10*10*10,},
{"cassiterite", "Cassiterite", "andesite", 10*10*10,},
{"cassiterite", "Cassiterite", "basalt", 10*10*10,},
{"cassiterite", "Cassiterite", "gabbro", 10*10*10,},
{"sphalerite", "Sphalerite", "andesite", 10*10*10,},
{"sphalerite", "Sphalerite", "dolomite", 10*10*10,},
{"sphalerite", "Sphalerite", "gneiss", 10*10*10,},
{"bismuthinite", "Bismuthinite", "diorite", 10*10*10,},
{"bismuthinite", "Bismuthinite", "granite", 10*10*10,},
{"bismuthinite", "Bismuthinite", "pegmatite", 10*10*10,},
}
for i in ipairs (mineral_table) do
local name = mineral_table[i][1]
local desc = mineral_table[i][2]
local strata = mineral_table[i][3]
local rarity = mineral_table[i][4]
minetest.register_node("underforge:"..name,{
description = desc,
tiles = strata..".png"^"ore_"..name..".png",
groups = {cracky = 3, minerals = 1},
drop = "underforge:"..name.."_chunk",
sounds = default.node_sound_stone_defaults(),
})
minetest.register_ore("underforge:"..name,{
ore_type = "scatter",
ore = "underforge:"..name.."_in_"..strata,
wherein = "underforge:"..strata,
clust_scarcity = {rarity},
clust_size = 5,
clust_num_ores = 10,
})
minetest.register_craftitem("underforge:"..name,{
description = S("Chunk of" ..desc ),
groups = {rocks = 1, minerals = 2},
inventory_image = "chunk_"..name..".png",
})
end
Who is online
Users browsing this forum: No registered users and 6 guests