Skip to content

Commit

Permalink
Better Recipe Handling
Browse files Browse the repository at this point in the history
Former-commit-id: 6537aeb [formerly 4db285d]
Former-commit-id: 6537aeb
Former-commit-id: 3c740a4
  • Loading branch information
Nexela committed Jul 21, 2017
1 parent 802737c commit c51df8a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 59 deletions.
4 changes: 4 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PACKAGE_NAME := $(shell cat info.json|jq -r .name)
VERSION_STRING := $(shell cat info.json|jq -r .version)
TOKEN := $(shell cat .token)
OUTPUT_NAME := $(PACKAGE_NAME)_$(VERSION_STRING)
BUILD_DIR := .build
OUTPUT_DIR := $(BUILD_DIR)/$(OUTPUT_NAME)
Expand Down Expand Up @@ -33,6 +34,9 @@ git: tag
git push --all
git push --tags

github-release:
curl --data '{"tag_name": "v$(VERSION_STRING)","target_commitish": "master","name": "vv$(VERSION_STRING)","body": "Release of version $(VERSION_STRING)","draft": true,"prerelease": false}' https://api.github.com/repos/:owner/:repository/releases?access_token=:$TOKEN

package-copy: $(PKG_DIRS) $(PKG_FILES)
@mkdir -p $(OUTPUT_DIR)
ifneq ($(PKG_COPY),)
Expand Down
20 changes: 12 additions & 8 deletions prototypes/updates/bob-updates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ local add_result = bobmods.lib.recipe.add_result
local remove_result = bobmods.lib.recipe.remove_result
local add_prerequisite = bobmods.lib.tech.add_prerequisite

local change_value = function(recipe_str, field, val)
local recipe = data.raw.recipe[recipe_str]
if recipe then
recipe[field] = val
end
end

-------------------------------------------------------------------------------
--[[Entities]]--
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -229,14 +236,11 @@ foundry.crafting_categories[#foundry.crafting_categories+1] = "mixing-furnace"
-------------------------------------------------------------------------------
add_prerequisite("coal-processing-2", "electrolysis-1")


-------------------------------------------------------------------------------
--[[Categories]]--
-------------------------------------------------------------------------------

data.raw.recipe["bob-resin-wood"].energy_required = 10
data.raw.recipe["bob-resin-wood"].category = "wpu"
data.raw.recipe["polishing-wheel"].category = "wpu"
data.raw.recipe["wooden-board"].energy_required = 10
data.raw.recipe["phenolic-board"].category = "wpu"

change_value("bob-resin-wood", "energy_required", 10)
change_value("bob-resin-wood", "category", "wpu")
change_value("polishing-wheel", "category", "wpu")
change_value("wooden-board", "energy_required", 10)
change_value("phenolic-board", "category", "wpu")
112 changes: 61 additions & 51 deletions prototypes/updates/recipe-updates.lua
Original file line number Diff line number Diff line change
@@ -1,93 +1,103 @@
local PYC = require("config")

local function add_ing(str_recipe, normal, expensive)
expensive = expensive or normal
local recipe = data.raw.recipe[str_recipe]
if recipe then
if recipe.normal then
recipe.normal.ingredients[#recipe.normal.ingredients + 1] = normal
if recipe.expensive then
recipe.expensive.ingredients[#recipe.expensive.ingredients + 1] = expensive
end
else
recipe.ingredients[#recipe.ingredients + 1] = normal
end
end
end

local function rep_ings(str_recipe, normal, expensive)
expensive = expensive or normal
local recipe = data.raw.recipe[str_recipe]
if recipe then
if recipe.normal then
recipe.normal.ingredients = table.deepcopy(normal)
if recipe.expensive then
recipe.expensive.ingredients = table.deepcopy(expensive)
end
else
recipe.ingredients = normal
end
end
end

if PYC.USE_CREOSOTE_RECIPES then -- flag from config.lua
if PYC.USE_CREOSOTE_IN.rail then
if not data.raw.recipe["bi-rail-wood"] then
local newrail=data.raw.recipe["rail"]
newrail.ingredients = {
{"stone", 1},
{"iron-stick", 2},
{"treated-wood", 2}
}
rep_ings("rail", {
{"stone", 1},
{"iron-stick", 2},
{"treated-wood", 2}
}
)
end

--Bio Industries
if data.raw.recipe["bi-rail-wood"] then
local biwoodrail = data.raw.recipe["bi-rail-wood"]
biwoodrail.ingredients = {
rep_ings("bi-rail-wood", {
{"stone", 1},
{"iron-stick", 2},
{"treated-wood", 2}
}
end
)
end

if PYC.USE_CREOSOTE_IN.power_poles then
local newpole=table.deepcopy(data.raw.recipe["medium-electric-pole"])
local newpole = data.raw.recipe["medium-electric-pole"]
newpole.category = "crafting-with-fluid"
newpole.ingredients[#newpole.ingredients +1] = {
type="fluid", name="creosote", amount=10
}
data:extend({newpole})
add_ing("medium-electric-pole", {type="fluid", name="creosote", amount=10})

--Big Wooden Pole Mod
if data.raw.recipe["big-wooden-pole"] then
local bigpole = data.raw.recipe["big-wooden-pole"]
bigpole.ingredients = {
rep_ings("big-wooden-pole",
{
{"treated-wood", 5},
{"copper-cable", 8}
}
end

--Bio Industries
if data.raw.recipe["bi-big-wooden-pole"] then
local bibigpole = data.raw.recipe["bi-big-wooden-pole"]
bibigpole.ingredients = {
{"treated-wood", 5},
{"small-electric-pole", 2},
}
end
)
end

--Bio Industries
rep_ings("bi-big-wooden-pole",
{
{"treated-wood", 5},
{"small-electric-pole", 2},
}
)

--More Floors
if data.raw.recipe["wood-floor"] then
local woodfloor = data.raw.recipe["wood-floor"]
woodfloor.ingredients = {
{"treated-wood", 10},
rep_ings("wood-floor",
{
{"treated-wood", 10}
}
end
)

--Bio Industries
if data.raw.recipe["bi-wooden-fence"] then
local fence = data.raw.recipe["bi-wooden-fence"]
fence.ingredients =
rep_ings("bi-wooden-fence",
{
{"treated-wood", 2},
{"raw-wood", 2},
}
end
)
end

--ADDING NIOBIUM INTO LOW DENSITY STRUCTURE
do
local part
part = data.raw.recipe["low-density-structure"]
part.normal.ingredients[#part.normal.ingredients + 1] = {type = "item", name = "niobium-plate", amount = 5}
part = data.raw.recipe["low-density-structure"]
part.expensive.ingredients[#part.expensive.ingredients + 1] = {type = "item", name = "niobium-plate", amount = 10}
local normal = {type = "item", name = "niobium-plate", amount = 5}
local expensive = {type = "item", name = "niobium-plate", amount = 10}
add_ing("low-density-structure", normal, expensive)
end

--ADDING FUELROD INTO ROCKET-FUEL INTO ROCKET-FUEL
do
local part = data.raw.recipe["rocket-fuel"]
local normal = {type = "item", name = "fuelrod-mk01", amount = 2}
local expensive = {type = "item", name = "fuelrod-mk01", amount = 4}
if part.normal then
part.normal.ingredients[#part.normal.ingredients + 1] = normal
if part.expensive then
part.expensive.ingredients[#part.expensive.ingredients + 1] = expensive
end
else
part.ingredients[#part.ingredients + 1] = normal
end
add_ing("rocket-fuel", normal, expensive)
end

0 comments on commit c51df8a

Please sign in to comment.