Items not appearing

Place to get help with not working mods / modding interface.
Alex99
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Aug 26, 2017 2:51 am
Contact:

Items not appearing

Post by Alex99 »

I am new to modding and this is what I have so far:

Code: Select all


-- entity
local nuclearConstructionRobot = table.deepcopy(data.raw.item["construction-robot"])

nuclearConstructionRobot.name = "Nuclear-Construction-Robot";
nuclearConstructionRobot.icons = {
	{
		icon = nuclearConstructionRobot.icon,
		tint = {r = 0, g = 1, b = 0, a = 0.3}
	},
}

nuclearConstructionRobot.max_health = 300
nuclearConstructionRobot.max_payload_size = 10
nuclearConstructionRobot.speed = 0.1
nuclearConstructionRobot.max_energy = "0.1MJ"
nuclearConstructionRobot.energy_per_tick = "0MJ"


--recipe
local recipe = {
	type = "recipe",
	name = "Nuclear-Construction-Robot",
	result = "Nuclear-Construction-Robot",
	enabled = false,
	ingredients = {
		{"construction-robot", 1},
		{"uranium-235", 10}
	}
}}

data:extend({nuclearConstructionRobot, recipe})
The code 'works' however when I start a new game (sandbox) the item does not show up.
Thanks in advance :)
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Items not appearing

Post by daniel34 »

The code as you posted it gives an error when loading:

Code: Select all

Failed to load mods: /data.lua:29: unexpected symbol near '}'

because there are two curly brackets at the end of the recipe block instead of one.

After fixing that the game loads, but your item (recipe) isn't visible. You can do a test to check if an entity is loaded by calling

Code: Select all

/c game.player.insert("Nuclear-Construction-Robot")

which actually inserts a stack of your item into your inventory.

The reason it's not visible is because in the recipe enabled is set to false, if you set it to true then you can see it:
factorio-testmod-construction.png
factorio-testmod-construction.png (389.78 KiB) Viewed 998 times
Usually enabled is used to disable a recipe in the beginning, only after a technology is researched it is enabled. But if you don't have a technology yet or intend to have that item available from the start you should keep it enabled.
quick links: log file | graphical issues | wiki
Post Reply

Return to “Modding help”