npo6ka / FNEI

Factorio NEI
https://mods.factorio.com/mods/npo6ka/FNEI
36 stars 21 forks source link

Add a remote interface to open specific item/recipe #42

Closed ClaudeMetz closed 5 years ago

ClaudeMetz commented 5 years ago

Hi there, really enjoying your mod. I myself released a mod called Factory Planner yesterday, and it is similar in functionality to Helmod, with which you surely are familiar. It has a lot of references to items and recipes of course. I wondered if it was possible for you to add a remote interface that allows other mods to open your UI on specific items/recipes. So whenever someone is laying out a factory in my mod, he could very quickly reference the item/recipe in your mod, instead of having to search for it manually. It would make the two mods work really well together. If you don't have the time, I might be able to create a pull request myself for the feature, but I wanted to ask you here first. Cheers, Therenas.

npo6ka commented 5 years ago

I certainly have nothing against it. I have never tried to implement the interaction between the mods, so I don’t know how to do it yet. You can try to do this and report your results here.

As for my mod, you can try to use these 2 functions from my mod: Controller.get_cont("recipe").add_element_in_recipe_list(action_type, prot_type, prot_name, cur_page) Controller.open_event("recipe")

1) We get the controller for the recipe and add the recipe we want to see into it. 2) Opens the required controller (in this case the FNEI recipe gui)

The add_element_in_recipe_list function is implemented here: https://github.com/npo6ka/FNEI/blob/master/scripts/recipe/controller.lua#L132 Arguments: 1) action_type: can be "craft" or "usage" 2) prot_type: can be "item" or "fluid" 3) prot_name: the name of the prototype for which a list of recipes is shown 4) cur_page: the name of the recipe you want to see

ClaudeMetz commented 5 years ago

It should be pretty easy to add a remote interface, the possiblities are very limited. I'll see what I can do. Thanks for the list of what to use, that will save me a lot of looking through your code. I'll report back when I got something.

ClaudeMetz commented 5 years ago

So I got it working mostly. One question I have though, is it possible to let FNEI only show one specific recipe, without other similar ones? Like in a list that shows 1/1. I'm asking because it would be nice to be able to show a recipe without having to specify which item it relates to, as you can't always easily determine the main product of a recipe.

npo6ka commented 5 years ago

Unfortunately, initially this option was not considered, so now it will not work. I need to add additional functionality for this. P.S. I will try to add this feature later.

ClaudeMetz commented 5 years ago

Okay great, thanks. I will wait with my pull request then, and should you add that functionality, I will incorporate it. It would make the remote call better/easier to use.

ClaudeMetz commented 5 years ago

So how is it looking? Did you make any progress adding this feature? If not, it's not a big deal, I can create a pull request with the functionality that is already available, and it will cover most of the use cases. So tell me whether I should just wait for you to add it or if I should make a pull request now.

npo6ka commented 5 years ago

Unfortunately, I am very busy right now and have not yet had the opportunity to develop a mod. If you want you can offer your pull request to me.

ClaudeMetz commented 5 years ago

Sure no problem, the interface will still be very useful without that functionality. I'll put together a pull request soon.