Page 2 of 3
Re: [0.12.x][0.12.3]Bob's Library mod
Posted: Sun May 22, 2016 9:59 am
by Blu3wolf
It was here:
viewtopic.php?t=25418&p=160227#p160463
Im certainly no expert, but I recall reading somewhere that Factorio's implementation of pairs is more specific than the lua spec, as the order of iteration is deterministic (necessary for lockstep multiplayer). Seems like that sorts out the difference between pairs and ipairs, doesnt it?
Re: [0.12.x][0.12.3]Bob's Library mod
Posted: Mon May 23, 2016 6:30 am
by bobingabout
the main difference is what it returns as the index.
There obviously is a difference as in some cases, one will cause the game to crash, where the other will not, but the need to use one over the other is actually far more flexible than I Thought.
Re: [0.12.x][0.12.4]Bob's Library mod
Posted: Sat May 28, 2016 5:30 pm
by bobingabout
Library 0.12.4:
* Added abillity to specify autoplace control seperate for ore creation.
* fixed abillity to set infinite
* Fixed an issue with add_technology_prerequisite function
* Added table_merge function
* Added add_recipe_result function
* Added result_check function, used by add_recipe_result and add_item_to_resource to change a result item into a results item.
* Added remove_recipe_result and remove_item_from_resource
* Added add_item, add_new_item and remove_item to be used by the recipe item, recipe result, and resource item functions that perform this action.
* Added combine_items to perform some better amount/amount_min/amount_max/probability calculations on add_item functions.
* bobmods.lib.replace_recipe_item_crude will change type if needed.
Re: [0.12.x][0.12.4]Bob's Library mod
Posted: Thu Jun 02, 2016 3:14 am
by TheSAguy
Hey Bob,
How do I add a fluid to a recipe?
So below I'm removing the artifact and want to replace it with a fluid:
Code: Select all
bobmods.lib.remove_recipe_item ("Biological-bullet-magazine", "alien-artifact") -- <-- works
bobmods.lib.add_new_recipe_item ("Biological-bullet-magazine", {type="fluid", name="NE_alien_toxin", amount=10})
EDIT: I think I had to add to the recipe:
and/or a recipe with two fluid results needs an Icon defined.
So above works now.
Thanks.
Re: [0.12.x][0.12.4]Bob's Library mod
Posted: Thu Jun 02, 2016 8:33 am
by bobingabout
Yeah, you did it right, and as you discovered, the category isn't changed, so you'd need to change that manually if the change in recipe would require it.
Perhaps I need a library function to do that.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Wed Jun 29, 2016 1:30 pm
by TheSAguy
Hey Bob,
I'm having a little trouble with removing or adding a fluid from a recipe.
On remove I use (legacy):
Code: Select all
bobmods.lib.recipe.remove_result ("NE_alien-revitalization", "NE_alien_toxin")
or add is use:
Code: Select all
bobmods.lib.add_recipe_result ("NE_alien-revitalization", {type="fluid", name="NE_alien_toxin", amount=5})
For both, I get an error with the check (Line 110 of recipe-functions.lua)
Code: Select all
bobmods.lib.result_check(data.raw.recipe[recipe])
If I comment that line out, they both work.

Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Wed Jun 29, 2016 5:59 pm
by bobingabout
Actually, what is, and is not legacy, you have reversed there.
bobmods.lib.recipe. are the ones you're supposed to be using.
Well, the function result_check does have an error in it, but basically, this should only trigger an error if you have a result= tag on your recipe.
I'll fix the result_check recipe, and update, let me know what happens.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Tue Jul 05, 2016 10:25 pm
by Mkal09
When I go to use 0.12.5 I get this when trying to load the game:

- Error
- Capture.PNG (169.36 KiB) Viewed 8029 times
and then it stops loading.
And for reference, these are the only mods i have in:

- Mods.PNG (35.34 KiB) Viewed 8029 times
Any ideas?
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Tue Jul 05, 2016 11:19 pm
by bobingabout
The "Latest version" for 0.12 was actually a little rushed, there are some errors in the code.
This specific error is caused by the mining mod. It seems you don't have the latest ores mod, which is the one that adds the category used in the latest mining mod.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Wed Jul 06, 2016 12:12 am
by Mkal09
Thanks, I'll give that a try.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Thu Oct 06, 2016 12:17 am
by clampi
Hello Bob,
There is an error in bobmods.lib.recipe.replace_ingredient_crude(). It doesn't work as intended, meaning that the recipe won't have the ingredient replaced although the function returns true. This happens because
statement doesn't work as expected, probably ingredient loop-local variable is a copy, not a reference to the actual list item from ingredients.
Changing the above statement to
Code: Select all
data.raw.recipe[recipe].ingredients[i] = item
seems to do the trick.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Thu Oct 06, 2016 10:57 am
by bobingabout
clampi wrote:Hello Bob,
There is an error in bobmods.lib.recipe.replace_ingredient_crude(). It doesn't work as intended, meaning that the recipe won't have the ingredient replaced although the function returns true. This happens because
statement doesn't work as expected, probably ingredient loop-local variable is a copy, not a reference to the actual list item from ingredients.
Changing the above statement to
Code: Select all
data.raw.recipe[recipe].ingredients[i] = item
seems to do the trick.
Ah, right. I probably missed fixing this one because I don't personally use the crude version.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Sat Apr 29, 2017 9:02 am
by clampi
Hello Bob,
It seems that simply migrating the library was not quite that simple as you thought. In case you didn't see my message from the mod portal, here is the update.
In the 0.15 release, the recipe prototype was changed extensively, such that the recipe functions do not work properly for certain recipes. The prototype was modified in such a way that keeping the current functions prototype (signature) is very hard IMHO. See the prototype of data.raw.recipe["pipe"] for an extremely unpleasant surprise. Given that the library is the core for your (and others) mods, it would be nice if you could address it.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Sat Apr 29, 2017 12:09 pm
by bobingabout
I bet it's that "normal" and "expensive" thing.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Sat Apr 29, 2017 3:16 pm
by clampi
After some investigation in the base mod recipes, it seems that there are two, mutually exclusive ways to specify a recipe:
1) The old, .14 way, with ingredients, result+result_count/results
2) The new, .15 way, with those normal and expensive options wrapping both the ingredients and results.
Both ways are used in the base mod recipe and is not clear at a first glance why some recipes vary the "expensiveness option" and other don't, except hand picking by factorio devs. However, what a good implementation of your functions would be is also unclear. How to manage both at the same time without causing an unnecessary split (not intended by the factorio devs) in the recipe? I guess you will address the requirements of your mods 1st, then, maybe, at specific request, add additional functionality for other moders.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Sat Apr 29, 2017 3:49 pm
by bobingabout
clampi wrote:After some investigation in the base mod recipes, it seems that there are two, mutually exclusive ways to specify a recipe:
1) The old, .14 way, with ingredients, result+result_count/results
2) The new, .15 way, with those normal and expensive options wrapping both the ingredients and results.
Both ways are used in the base mod recipe and is not clear at a first glance why some recipes vary the "expensiveness option" and other don't, except hand picking by factorio devs. However, what a good implementation of your functions would be is also unclear. How to manage both at the same time without causing an unnecessary split (not intended by the factorio devs) in the recipe? I guess you will address the requirements of your mods 1st, then, maybe, at specific request, add additional functionality for other moders.
I'm already working on the solution.
The simple answer is: Check if ingredients exists, normal if exists (use normal.ingredients) and if expensive exists (use expensive.ingredients). Do all 3 checks and run the function for each. Therefore, if any exist, the function runs on that version.
Re: [0.12.x][0.12.1]Bob's Library mod
Posted: Sun Apr 30, 2017 6:53 pm
by moon69
bobingabout wrote:Degraine wrote:Ho are these functions accessed by other mods? Do we have to require() them into data.lua?
They are available for other mods to use, yes. I recomend you make this mod a dependacy in info.json, and the functions will all be available without the need for a require.
I can't figure this out
Factorio 0.15.5
boblibrary 0.15.1 correctly identified as dependency of my mod as shown in Factorio -> Mods
in-game my mod calls
Code: Select all
local ironbru = bobmods.lib.get_type("iron-ore")
but gives error:
Code: Select all
Error while running event 666BeastMod::666BeastMod-ResearchQueue-Toggle (ID 75)
__666BeastMod__/control.lua:18: attempt to index global 'bobmods' (a nil value)
Can someone please nudge me in the right direction?
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Sun Apr 30, 2017 7:31 pm
by bobingabout
The error looks like you're trying to use my function call in the Control (scripting) phase of the game.
The library is intended to be used during the Data (loading) phase of the game only.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Mon May 01, 2017 11:39 am
by moon69
<<reads up on control.lua vs data*.lua>>
I understand now thanks Bob

Will instead use custom events.
Re: [0.12.x][0.12.5]Bob's Library mod
Posted: Sat Jun 24, 2017 4:03 am
by martingolding96