Why isn't this a string?
Posted: Fri Jul 28, 2017 8:54 pm
This is more about me not understanding Lua data structures I think, but If I serpent_block dump a recipe in the data stage I get something like this:
In an event handler in control.lua I have some code like this:
In the console (but not the log) this gives an error like:
1. Why is the subgroup property a table and not just a string?
2. How can I get the value of the string from the table that the console says that subgroup is in?
Code: Select all
{
category = "recycling-1",
enabled = false,
energy_required = 1,
group = "dry411srev-combat",
hidden = false,
icon = "__base__/graphics/icons/firearm-magazine.png",
ingredients = {
{
"firearm-magazine",
1
}
},
name = "dry411srev-firearm-magazine",
order = "a[basic-clips]-a[firearm-magazine]",
results = {
{
"iron-plate",
4
}
},
subgroup = "dry411srev-ammo",
type = "recipe"
},
Code: Select all
local setting = string.gsub(force.recipes["dry411srev-firearm-magazine"].subgroup,rec_prefix,"ZRecycling")
Code: Select all
bad argument #1 to 'gsub' (string expected, got table) ....
2. How can I get the value of the string from the table that the console says that subgroup is in?