From 11ef1a37dd3e62cbde5f5c88e19f7b5307f82b67 Mon Sep 17 00:00:00 2001 From: AndrolGenhald Date: Sun, 28 Aug 2016 16:05:14 -0500 Subject: [PATCH] Fixed crash when subgroup isn't defined --- info.json | 2 +- prototypes/item/groups.lua | 82 +++++++++++++++++++------------------- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/info.json b/info.json index cbd50ae..751c3f9 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "boxing-2", - "version": "2.0.1", + "version": "2.0.2", "title": "Boxing 2", "author": "AndrolGenhald", "description": "Pack items into boxes to store more of them.", diff --git a/prototypes/item/groups.lua b/prototypes/item/groups.lua index 9f4dd7c..3400f2d 100644 --- a/prototypes/item/groups.lua +++ b/prototypes/item/groups.lua @@ -60,55 +60,57 @@ end --]] for subgroupName,t in pairs(boxing.subgroups) do - local groupName = data.raw["item-subgroup"][subgroupName].group; - local groupOrder = data.raw["item-group"][groupName].order; - local subgroupOrder = data.raw["item-subgroup"][subgroupName].order; - data:extend({ - { - type = "item-subgroup", - name = "boxing-wooden-" .. subgroupName, - --group = "box-wooden", - group = "boxing", - order = "b[boxing]-a[wooden]" .. groupOrder .. subgroupOrder, - }, - { - type = "item-subgroup", - name = "unboxing-wooden-" .. subgroupName, - --group = "unbox-wooden", - group = "boxing", - order = "c[unboxing]-a[wooden]" .. groupOrder .. subgroupOrder, - }, - { - type = "item-subgroup", - name = "boxing-steel-" .. subgroupName, - --group = "box-steel", - group = "boxing", - order = "b[boxing]-b[steel]" .. groupOrder .. subgroupOrder, - }, - { - type = "item-subgroup", - name = "unboxing-steel-" .. subgroupName, - --group = "unbox-steel", - group = "boxing", - order = "c[unboxing]-b[steel]" .. groupOrder .. subgroupOrder, - }, - }); - if boxing.tungsten then + if data.raw["item-subgroup"][subgroupName] then + local groupName = data.raw["item-subgroup"][subgroupName].group; + local groupOrder = data.raw["item-group"][groupName].order; + local subgroupOrder = data.raw["item-subgroup"][subgroupName].order; data:extend({ { type = "item-subgroup", - name = "boxing-tungsten-" .. subgroupName, - --group = "box-tungsten", + name = "boxing-wooden-" .. subgroupName, + --group = "box-wooden", + group = "boxing", + order = "b[boxing]-a[wooden]" .. groupOrder .. subgroupOrder, + }, + { + type = "item-subgroup", + name = "unboxing-wooden-" .. subgroupName, + --group = "unbox-wooden", + group = "boxing", + order = "c[unboxing]-a[wooden]" .. groupOrder .. subgroupOrder, + }, + { + type = "item-subgroup", + name = "boxing-steel-" .. subgroupName, + --group = "box-steel", group = "boxing", - order = "b[boxing]-c[tungsten]" .. groupOrder .. subgroupOrder, + order = "b[boxing]-b[steel]" .. groupOrder .. subgroupOrder, }, { type = "item-subgroup", - name = "unboxing-tungsten-" .. subgroupName, - --group = "unbox-tungsten", + name = "unboxing-steel-" .. subgroupName, + --group = "unbox-steel", group = "boxing", - order = "c[unboxing]-c[tungsten]" .. groupOrder .. subgroupOrder, + order = "c[unboxing]-b[steel]" .. groupOrder .. subgroupOrder, }, }); + if boxing.tungsten then + data:extend({ + { + type = "item-subgroup", + name = "boxing-tungsten-" .. subgroupName, + --group = "box-tungsten", + group = "boxing", + order = "b[boxing]-c[tungsten]" .. groupOrder .. subgroupOrder, + }, + { + type = "item-subgroup", + name = "unboxing-tungsten-" .. subgroupName, + --group = "unbox-tungsten", + group = "boxing", + order = "c[unboxing]-c[tungsten]" .. groupOrder .. subgroupOrder, + }, + }); + end end end