What is it really used for?


A tool to help you find out where items and fluids come from and where they are used. This is a fork of the original 'What is it used for?' by Mr Doomah, updated for newer Factorio versions and with additional features. Russian translation by Schmarotzer. Japanese translation by shiru_tan.

Utilities
13 days ago
0.15 - 2.0
32.6K

i Interface that other mods can use

4 years ago

Hey there, I'm the developer of Factory Planner. It's basically an alternative to Helmod.

Now I have a functionality where users can alt-click on any recipe or item and open FNEI to that recipe/item. That is really cool, and I could do this because I cooperated with the dev of FNEI to add a remote interface. (Raiguards new mod also has such an interface).

I would like to ask if it's possible for you to also add a remote interface to your mod, so I can link to it from my mod. That would be really cool for the people that use Factory Planner and want to use WIIRUF with it. Would you be open to that? I can also look into adding the interface myself and sending you the code so you can incorporate it, but I'm not familiar with your code and don't want to step on any toes.

If you have any questions or want some specifics, I'm all ear. Let me know what you think!

4 years ago

That sounds reasonable. I see that RecipeBook also provides a reopen_source_event remote interface to allow its back button to work. How important is that feature to you? I'm not sure it really makes sense for my current GUI, so that would be trickier to implement.

4 years ago

I think for a minimal implementation this should be as simple as adding

remote.add_interface("wiiuf", {
open_item=function(player_index, item_name)
player = game.players[player_index]
identify_and_add_to_history(item_name, player, false, true)
end
})

to the end of control.lua. Let me know if that works for you, and/or whether any tweaks are necessary.

(Sorry, I know this is not a sensible place for code exchange, and I should have this up on GitHub, but I don't want to set that up right now)

4 years ago

Thanks for the quick response, glad to hear you're open to it! It doesn't matter at all if it's the same as the other implementations or not. I would suggest for you to implement it in a way that makes sense to you in the context of your mod. I'll try the snippet you posted soon and let you know if it'll work.

(No worries about Github, this is totally fine)

4 years ago

Here I was, adding the code you posted above to the version I downloaded when I noticed that you added it already! Nice lol. It works great the way you implemented it there.

Now there are 2 things I'd like to propose to you, if you're open to it. First, I'd prefer it if there was a way for me to check the version of your API programmatically. Just a remote function like version=function() return 1 end, where the number is increased every time the API is changed significantly. It's not super important, but would be nice to have to avoid a crash when something has changed.

Secondly, is there already a way for your mod to open on a specific recipe? By that I mean, open on a given item, and have one of it's recipes already pre-selected. If so, it would be cool to do that by API as well, so a user can click on a recipe in my mod, and see it already selected in WIIRUF. The remote interface would take the name of an item and a recipe (in addition to the player_index).

Now neither of these are super important, I'm very happy with the basic implementation already. It's just something for you to consider.

(Also, you probably don't have a distinction internally between items and fluids? Because I'm not sure what would happen if an item and a fluid had the same name. If you don't, it's no big deal, it's unlikely anyways. If you do, you could add a type-argument to the interface.)

4 years ago

It was actually an accident that I'd added it already; didn't intend to. But glad it worked.

API version is a great idea; will do.

Indeed there's no distinction between items and fluids. I think that will probably come back to bite me at some point, but it seems to have been OK so far.

Opening a recipe automatically is something I'd thought about. Let me see if it's easy to do.

4 years ago
(updated 4 years ago)

Try the version in 1.5.10; it should support both those requests.

Note that although you can now request a particular recipe be shown, you must also specify an item (as you suggested).

There's only one API still; you can pass a nil recipe_name to get just the item.

4 years ago

That is so great to hear, thanks for indulging me. It'll be a second before I can add the functionality to Factory Planner, as there is a bit of work surrounding it, but hopefully I can get to it soon. Thanks again.

New response