[0.12.x][0.12.5]Bob's Library mod

Some mods, made by Bob. Basically streaks every Factroio-area.

Moderator: bobingabout

User avatar
Blu3wolf
Fast Inserter
Fast Inserter
Posts: 202
Joined: Thu Apr 09, 2015 5:20 am
Contact:

Re: [0.12.x][0.12.3]Bob's Library mod

Post 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?

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.3]Bob's Library mod

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.4]Bob's Library mod

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: [0.12.x][0.12.4]Bob's Library mod

Post 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:

Code: Select all

category = "crafting-with-fluid",
and/or a recipe with two fluid results needs an Icon defined.

So above works now.
Thanks.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.4]Bob's Library mod

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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.

Image

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Mkal09
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Jul 05, 2016 10:16 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post by Mkal09 »

When I go to use 0.12.5 I get this when trying to load the game:
Error
Error
Capture.PNG (169.36 KiB) Viewed 6811 times
and then it stops loading.

And for reference, these are the only mods i have in:
Mods.PNG
Mods.PNG (35.34 KiB) Viewed 6811 times
Any ideas?

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Mkal09
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Jul 05, 2016 10:16 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post by Mkal09 »

Thanks, I'll give that a try.

clampi
Inserter
Inserter
Posts: 35
Joined: Tue Mar 08, 2016 11:28 am
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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

Code: Select all

ingredient = item
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.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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

Code: Select all

ingredient = item
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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

clampi
Inserter
Inserter
Posts: 35
Joined: Tue Mar 08, 2016 11:28 am
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post by bobingabout »

I bet it's that "normal" and "expensive" thing.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

clampi
Inserter
Inserter
Posts: 35
Joined: Tue Mar 08, 2016 11:28 am
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Re: [0.12.x][0.12.1]Bob's Library mod

Post 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?

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post by moon69 »

<<reads up on control.lua vs data*.lua>>

I understand now thanks Bob :) Will instead use custom events.

martingolding96
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Jun 03, 2016 2:27 pm
Contact:

Re: [0.12.x][0.12.5]Bob's Library mod

Post by martingolding96 »

Im getting this error http://prntscr.com/fnj3f8

And theese are the mods im using
http://prntscr.com/fnj3nm
http://prntscr.com/fnj3te

Post Reply

Return to “Bob's mods”