[Solved] Would it be possible to use a for loop here?
Posted: Sat Mar 26, 2016 10:07 pm
Hello, my current recipe.lua looks like this:
My entity.lua and technology.lua looks similar as well. I was wondering for the future if it would have been possible to use a for loop to simplify all this repetition? Something like:
If so could you guys point me to the exact syntax for it? I'm not really a programmer and I'm not quite sure if this is possible. Any help is appreciated.
Code: Select all
data:extend({
--Tree 02C
{
type = "recipe",
name = "facdeco-tree-02-c-pink",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-pink"
},
{
type = "recipe",
name = "facdeco-tree-02-c-red",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-red"
},
{
type = "recipe",
name = "facdeco-tree-02-c-orange",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-orange"
},
{
type = "recipe",
name = "facdeco-tree-02-c-yellow",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-yellow"
},
{
type = "recipe",
name = "facdeco-tree-02-c-green",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-green"
},
{
type = "recipe",
name = "facdeco-tree-02-c-lime",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-lime"
},
{
type = "recipe",
name = "facdeco-tree-02-c-pine",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-pine"
},
{
type = "recipe",
name = "facdeco-tree-02-c-purple",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-purple"
},
})
Code: Select all
for VAR = pink, red, orange, yellow, green, lime, pine, purple; do
{
type = "recipe",
name = "facdeco-tree-02-c-[VAR]",
enabled = "false",
ingredients = { {"iron-plate", 5}, {"plastic-bar", 5} },
result = "facdeco-tree-02-c-[VAR]"
},
end for