Struggling getting a recipe to display in game

Place to get help with not working mods / modding interface.
Post Reply
blavek
Inserter
Inserter
Posts: 20
Joined: Mon Jul 04, 2016 4:47 am
Contact:

Struggling getting a recipe to display in game

Post by blavek »

I have written a mod but to take it to the next step I need to get an entity in game that I can place and rotate. However, it seems like no matter what I do I cannot get the recipe to show. I started with "selection-tool" and that showed in the recipe list but, that doesn't allow for the rotation. I tried using a transport belt but that seemed to require much more than I need. It seems like simple-entity should be sort of a default entity to build from but as I have done more research that may not be the answer either. But what entity I clone is kind of not relevant at the moment since I cannot get the recipe to show. Any help would be appreciated. Below is my data.lua file.

Made a few updates and now it is showing so... I guess I should have waited a moment ;)

Code: Select all

local autoMiner = util.table.deepcopy(data.raw["simple-entity-with-force"])
autoMiner = {}
autoMiner.type = "simple-entity-with-force"
autoMiner.name = "autoMiner"
autoMiner.icon = "__AutoMine__/autoMineEast.png"
autoMiner.render_layer = "object"
autoMiner.flags = {
    "placeable-neutral",
    "placeable-player",
    "player-creation"
}

autoMiner.pictures = {
    filename = "__AutoMine__/autoMineNorth.png",
    width = 32,
    height = 32,
}

local autoMinerItem = table.deepcopy(data.raw.item["simple-entity-with-force"])
autoMinerItem.name="autoMiner"
autoMinerItem.place_result="autoMiner"
autoMinerItem.icon="__AutoMine__/autoMineEast.png"

local autoMinerRecipe = {
    type = "recipe",
    enabled = true,
    normal = {
        ingredients = {},
        result = "autoMiner",
    },

    name = "autoMiner",
}
    
data:extend({autoMiner, autoMinerRecipe, autoMinerItem})

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

Re: Struggling getting a recipe to display in game

Post by bobingabout »

your recipe is invalid.

autoMinerRecipe needs a name field. (EDIT: oh, it has one at the bottom)
also if "normal" is present, you NEED an expensive tag too. if you only want one recipe used for both settings, don't use the normal tag, just specify the tags within that table as part of the recipe table.

Code: Select all

local autoMinerRecipe = {
    type = "recipe",
    name = "autoMiner",
    enabled = true, --not really needed, it defaults to true.
    ingredients = {},
    result = "autoMiner",
}
Also, although your use of capital letters should work, it's none-standard for factorio, it would be more standard to use either "autominer" or "auto-miner".
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

ibeatbabybiters
Inserter
Inserter
Posts: 30
Joined: Sun Apr 30, 2017 7:14 pm
Contact:

Re: Struggling getting a recipe to display in game

Post by ibeatbabybiters »

I know nothing about recipes, but the first two lines don't make much sense:

Code: Select all

local autoMiner = util.table.deepcopy(data.raw["simple-entity-with-force"])
autoMiner = {}
You are overwriting the copy with a empty table. I have no idea if this solves your problem, though.
Usually I don't beat babies, but when I do I beat baby biters.

blavek
Inserter
Inserter
Posts: 20
Joined: Mon Jul 04, 2016 4:47 am
Contact:

Re: Struggling getting a recipe to display in game

Post by blavek »

ibeatbabybiters wrote:I know nothing about recipes, but the first two lines don't make much sense:

Code: Select all

local autoMiner = util.table.deepcopy(data.raw["simple-entity-with-force"])
autoMiner = {}
You are overwriting the copy with a empty table. I have no idea if this solves your problem, though.
That was an artifact from a previous attempt it has been corrected.

blavek
Inserter
Inserter
Posts: 20
Joined: Mon Jul 04, 2016 4:47 am
Contact:

Re: Struggling getting a recipe to display in game

Post by blavek »

bobingabout wrote:your recipe is invalid.

autoMinerRecipe needs a name field. (EDIT: oh, it has one at the bottom)
also if "normal" is present, you NEED an expensive tag too. if you only want one recipe used for both settings, don't use the normal tag, just specify the tags within that table as part of the recipe table.

Code: Select all

local autoMinerRecipe = {
    type = "recipe",
    name = "autoMiner",
    enabled = true, --not really needed, it defaults to true.
    ingredients = {},
    result = "autoMiner",
}
Also, although your use of capital letters should work, it's none-standard for factorio, it would be more standard to use either "autominer" or "auto-miner".
Initially, I did not have a normal tag however Factorio claimed it was required. The recipe will always cost nothing though because the intent is for the actual entity to denote a location and direction. Once the mod gets the info from the entity it will pick it up. Since the selection tool is non rotatable I need another solution. Also, blueprints don't seem to trigger the on_player_selected_area event. A mining-drill would seem to have all of the default functionality that I need but then at also has a lot of things related to mining that I don't need. I am sure that there are better ways, ultimately, to achieve what I am attempting.

As for the casing I personally find camel casing easier to read than hyphen separated things.

But anyhow I eventually got the recipe to show in the game and unfortunately i'm not quite sure what did it so, I am bound to have a similar problem in the future.

Post Reply

Return to “Modding help”