Page 1 of 1

Items not appearing

Posted: Sat Aug 26, 2017 2:56 am
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 :)

Re: Items not appearing

Posted: Sat Aug 26, 2017 11:03 am
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 1121 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.