Weird variable bug
(Sorry for the bad topic name, I have no idea how to call this problem...)
I'm setting up an API for the StreetsMod to make it easier to register all the possible combinations of asphalt and marking nodes: There are two key-value-tables containing the data required for registering the nodes (see api.lua/api.lua#L20[/url]). Using minetest.after(0, ...), it loops over these two tables and registers the nodes in all possible combinations (see api_register_all.lua).
The problem is the automatic generation of a craft recipe. The recipe I pass to the API function contains placeholders ("?") that are replaced by the corresponding node names (see streets_roadmarkings/init.lua)(e.g. streets:asphalt for black asphalt with a line; streets:asphalt:red for red asphalt with a line etc.). This name is stored in a local variable called replacement (see api_register_all.lua).
This is the theory. In practice, this variable shows a behaviour I cannot understand. When I insert it into the craft recipe, the field is always "streets:asphalt", even if replacement has the value "streets:asphalt_red".
maybe this console screenshot can help ypu understand what I mean. I marked the content of replacement and the fields of the craft recipe replaced with this variable in yellow:

I tried to fix this multiple times by deleting the whole code and recreating it from scratch, but the bug keeps appearing. I have no idea how to fix this, so now I'm asking the community.
You can find the whole mod code here: Github
I'm setting up an API for the StreetsMod to make it easier to register all the possible combinations of asphalt and marking nodes: There are two key-value-tables containing the data required for registering the nodes (see api.lua/api.lua#L20[/url]). Using minetest.after(0, ...), it loops over these two tables and registers the nodes in all possible combinations (see api_register_all.lua).
The problem is the automatic generation of a craft recipe. The recipe I pass to the API function contains placeholders ("?") that are replaced by the corresponding node names (see streets_roadmarkings/init.lua)(e.g. streets:asphalt for black asphalt with a line; streets:asphalt:red for red asphalt with a line etc.). This name is stored in a local variable called replacement (see api_register_all.lua).
This is the theory. In practice, this variable shows a behaviour I cannot understand. When I insert it into the craft recipe, the field is always "streets:asphalt", even if replacement has the value "streets:asphalt_red".
maybe this console screenshot can help ypu understand what I mean. I marked the content of replacement and the fields of the craft recipe replaced with this variable in yellow:

I tried to fix this multiple times by deleting the whole code and recreating it from scratch, but the bug keeps appearing. I have no idea how to fix this, so now I'm asking the community.
You can find the whole mod code here: Github