[0.12.x][0.12.5]Bob's Library mod
Moderator: bobingabout
Re: [0.12.x][0.12.3]Bob's Library mod
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?
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?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.3]Bob's Library mod
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.
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.4]Bob's Library mod
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.
* 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
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:
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.
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:
Code: Select all
category = "crafting-with-fluid",
So above works now.
Thanks.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.4]Bob's Library mod
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.
Perhaps I need a library function to do that.
Re: [0.12.x][0.12.5]Bob's Library mod
Hey Bob,
I'm having a little trouble with removing or adding a fluid from a recipe.
On remove I use (legacy):
or add is use:
For both, I get an error with the check (Line 110 of recipe-functions.lua)
If I comment that line out, they both work.
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")
Code: Select all
bobmods.lib.add_recipe_result ("NE_alien-revitalization", {type="fluid", name="NE_alien_toxin", amount=5})
Code: Select all
bobmods.lib.result_check(data.raw.recipe[recipe])
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.5]Bob's Library mod
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.
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
When I go to use 0.12.5 I get this when trying to load the game:
and then it stops loading.
And for reference, these are the only mods i have in:
Any ideas?
and then it stops loading.
And for reference, these are the only mods i have in:
Any ideas?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.5]Bob's Library mod
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.
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
Thanks, I'll give that a try.
Re: [0.12.x][0.12.5]Bob's Library mod
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
seems to do the trick.
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
Code: Select all
ingredient = item
Changing the above statement to
Code: Select all
data.raw.recipe[recipe].ingredients[i] = item
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.5]Bob's Library mod
Ah, right. I probably missed fixing this one because I don't personally use the crude version.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 becausestatement doesn't work as expected, probably ingredient loop-local variable is a copy, not a reference to the actual list item from ingredients.Code: Select all
ingredient = item
Changing the above statement toseems to do the trick.Code: Select all
data.raw.recipe[recipe].ingredients[i] = item
Re: [0.12.x][0.12.5]Bob's Library mod
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.
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.5]Bob's Library mod
I bet it's that "normal" and "expensive" thing.
Re: [0.12.x][0.12.5]Bob's Library mod
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.
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.5]Bob's Library mod
I'm already working on the solution.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.
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
I can't figure this outbobingabout wrote: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.Degraine wrote:Ho are these functions accessed by other mods? Do we have to require() them into data.lua?
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")
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?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.12.x][0.12.5]Bob's Library mod
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.
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
<<reads up on control.lua vs data*.lua>>
I understand now thanks Bob Will instead use custom events.
I understand now thanks Bob Will instead use custom events.
-
- Burner Inserter
- Posts: 10
- Joined: Fri Jun 03, 2016 2:27 pm
- Contact:
Re: [0.12.x][0.12.5]Bob's Library mod
Im getting this error http://prntscr.com/fnj3f8
And theese are the mods im using
http://prntscr.com/fnj3nm
http://prntscr.com/fnj3te
And theese are the mods im using
http://prntscr.com/fnj3nm
http://prntscr.com/fnj3te