Skip to content

Commit

Permalink
Library changes for 2.0 #208
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiHawk committed Nov 13, 2024
1 parent 38019bc commit e554c3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 75 deletions.
5 changes: 4 additions & 1 deletion boblibrary/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
Version: 1.3.0
Date: ???
Changes:
- Update for Factorio 2.0 #189
- Update for Factorio 2.0 #189, #208
- Removed difficulty functions
- Removed bobmods.lib.module
- Added function bobmods.lib.recipe.allow_productivity
- Added function bobmods.lib.recipe.disallow_productivity
---------------------------------------------------------------------------------------------------
Version: 1.2.0
Date: 22. 12. 2023
Expand Down
1 change: 1 addition & 0 deletions boblibrary/error-functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function bobmods.lib.error.result(result, name)
end
if result == nil then
log(name .. " variable not passed")
return
elseif not (type(result == "table")) then
log(name .. " variable not a table")
elseif not (type(result.name) == "string") then
Expand Down
13 changes: 9 additions & 4 deletions boblibrary/item-functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function bobmods.lib.item.get_type(name) --returns actual item type
end
end
if data.raw.fluid and data.raw.fluid[name] then
item_type = type_name
item_type = "fluid"
end
else
log("Item name is not a string")
Expand Down Expand Up @@ -93,9 +93,11 @@ function bobmods.lib.item.ingredient(inputs) --returns a valid ingredient only i
if item then
return item
else
log(item.name)
if inputs and inputs.name then
log(inputs.name)
end
log(debug.traceback())
bobmods.lib.error.ingredient(item)
bobmods.lib.error.ingredient(inputs)
return nil
end
end
Expand Down Expand Up @@ -189,8 +191,11 @@ function bobmods.lib.item.result(inputs) --returns a valid result only if the it
if item then
return item
else
if inputs and inputs.name then
log(inputs.name)
end
log(debug.traceback())
bobmods.lib.error.result(item)
bobmods.lib.error.result(inputs)
return nil
end
end
Expand Down
70 changes: 0 additions & 70 deletions boblibrary/module-functions.lua
Original file line number Diff line number Diff line change
@@ -1,70 +0,0 @@
if not bobmods.lib.module then
bobmods.lib.module = {}
bobmods.lib.module.excluded_prod_modules = {}
end

function bobmods.lib.module.exclude_productivity_module(module_name)
if type(module_name) == "string" then
if data.raw.module[module_name] then
bobmods.lib.module.excluded_prod_modules[module_name] = true
end
else
log(debug.traceback())
end
end

function bobmods.lib.module.add_productivity_limitation(recipe)
if type(recipe) == "string" and data.raw.recipe[recipe] then
for i, module in pairs(data.raw.module) do
if
not bobmods.lib.module.excluded_prod_modules[module.name]
and module.limitation
and module.effect.productivity
then
table.insert(module.limitation, recipe)
end
end
else
log(debug.traceback())
bobmods.lib.error.recipe(recipe)
end
end

function bobmods.lib.module.add_productivity_limitations(recipes)
if type(recipes) == "table" then
for j, recipe in pairs(recipes) do
bobmods.lib.module.add_productivity_limitation(recipe)
end
else
log(debug.traceback())
log("Expected table.")
end
end

function bobmods.lib.module.remove_productivity_limitation(recipe)
if type(recipe) == "string" and data.raw.recipe[recipe] then
for i, module in pairs(data.raw.module) do
if module.limitation and module.effect.productivity then
for limitationIndex, limitationRecipeName in pairs(module.limitation) do
if recipe == limitationRecipeName then
table.remove(module.limitation, limitationIndex)
end
end
end
end
else
log(debug.traceback())
bobmods.lib.error.recipe(recipe)
end
end

function bobmods.lib.module.remove_productivity_limitations(recipes)
if type(recipes) == "table" then
for j, recipe in pairs(recipes) do
bobmods.lib.module.remove_productivity_limitation(recipe)
end
else
log(debug.traceback())
log("Expected table.")
end
end

0 comments on commit e554c3a

Please sign in to comment.