defining items with a loop error

Place to get help with not working mods / modding interface.
Post Reply
ukezi
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Jul 02, 2016 11:02 pm
Contact:

defining items with a loop error

Post by ukezi »

I'm making multiple items with multiple tiers each. for that I have written an function
function ukezi_equipment_item(name,icon,row,category,collum,stack)
return
{
type = "item",
name = name,
icon = icon,
placed_as_equipment_result = name,
flags = {"goes-to-main-inventory"},
subgroup = "equipment",
order = row.."["..category.."]-" .. collum .. "[" .. name .. "]",
stack_size = stack
}
end
now when I use it like
data:extend({
ukezi_equipment_item(types[1] .. surfix[1],icon[1],"a","robotics","e",5),
ukezi_equipment_item(types[1] .. surfix[2],icon[2],"a","robotics","e",5),
})
it works fine.
It's already nice but I'd like to write it like
data:extend({
for i = 1 to 5 do
for j = 1 to 5 do
ukezi_equipment_item(types .. surfix[j],icon,"a","robotics","e",5),
end
end
})

I get unexpected symbol near for.
Is it simply impossible to do item defination in loops or did I miss something?

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 339
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: defining items with a loop error

Post by LuziferSenpai »

You cant make it so.

You need to make it so:

Code: Select all

for i = 1 to 5 do
for j = 1 to 5 do
data:extend({
ukezi_equipment_item(types[i] .. surfix[j],icon[i],"a","robotics","e",5),
})
end
end
Than it should work, because you cant make a for function in a data:extend ;)
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: defining items with a loop error

Post by prg »

Also the numerical for requires a comma instead of the "to" between the limits.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: defining items with a loop error

Post by aubergine18 »

Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Post Reply

Return to “Modding help”