Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Fixing some of the Factorio stdlib functions to work properly with all recipes
- function Recipe:clear_ingredients()
- if self:is_valid() then
- if self.normal then
- if self.normal.ingredients then
- self.normal.ingredients = {}
- end
- end
- if self.expensive then
- if self.expensive.ingredients then
- self.expensive.ingredients = {}
- end
- end
- if self.ingredients then
- self.ingredients = {}
- end
- end
- return self
- end
- function Recipe:set_enabled(enabled)
- if self:is_valid() then
- if self.normal then
- self.normal.enabled = enabled
- end
- if self.expensive then
- self.expensive.enabled = enabled
- end
- if self.enabled then
- self.enabled = enabled
- end
- end
- return self
- end
- function Data:copy(new_name, mining_result, opts)
- Is.Assert.String(new_name, 'New name is required')
- if self:is_valid() then
- mining_result = mining_result or new_name
- --local from = self.name
- local copy = table.deep_copy(rawget(self, '_raw'))
- copy.name = new_name
- -- For Entities
- -- Need to also check mining_results!!!!!!
- if mining_result then
- if copy.minable and copy.minable.result then
- copy.minable.result = mining_result
- end
- end
- -- For items
- if copy.place_result then
- copy.place_result = new_name
- end
- -- For recipes, should also to check results!!
- if copy.type == 'recipe' then
- if copy.normal and copy.normal.result then
- copy.normal.result = new_name
- end
- if copy.expensive and copy.expensive.result then
- copy.expensive.result = new_name
- end
- if copy.result then
- copy.result = new_name
- end
- end
- -- rail planners
- if copy.placeable_by and copy.placeable_by.item then
- copy.placeable_by.item = mining_result
- end
- return self(copy, nil, opts or self.options)
- else
- error('Cannot Copy, invalid prototype', 4)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement