Hello all! I'm a long time, professional programmer who has always wanted to get into game development of some sort, but rarely had the time or courage to jump into it. I've finally worked up the nerve and so I'm going to start my illustrious career with Factorio modding. Problem is... I'm already stuck.
What I want to try and do is create a mod that serves to make compacted versions of existing buildings that tend to get repeated a lot (labs, steam engines, solar panels, etc). The buildings would effectively be the exact same as having 2 or more of the same building, but taking up the same space as 1. I want to start trying this out with steam engines, but I simply can't find the lua code for one!
I'm using Windows 7 and the Steam release of Factorio. I'm looking all over my files under C:\Program Files (x86)\Steam\steamapps\common\Factorio\data\, tried opening various item/entity files, tried the built-in Windows Explorer search for 'steam-engine', but nothing. The strange thing is that I don't think the Steam Engine is the only item/entity that's oddly missing. Am I missing something, or are Steam Engines and other items just not moddable in the same way?
First time modder here! Running into a roadblock.
-
- Manual Inserter
- Posts: 2
- Joined: Thu Apr 21, 2016 3:13 am
- Contact:
Re: First time modder here! Running into a roadblock.
I recommend Notepad++, its file search is far superior to Windows.
Anyway, the file you're looking for is demo-entities.lua.
Anyway, the file you're looking for is demo-entities.lua.
-
- Filter Inserter
- Posts: 478
- Joined: Sat Aug 23, 2014 11:43 pm
- Contact:
Re: First time modder here! Running into a roadblock.
The entity prototypes are all located here. "C:\Program Files (x86)\Steam\steamapps\common\Factorio\data\base\prototypes\entity".
Here is the steam engine prototype definition.
To change the size of the steam engine you have to change the collision_box, selection_box and fluid_box so they all match up(if you make the engine half the size(collision_box) then the cursor selection area(selection_box) should also be half the area). You will also have to edit the animation so the steam engine is drawn smaller on the screen. If you as an example want to make it half the size then you have to add a scale to the animation.
To do these changes as a mod you have to edit the prototype after it's loaded. These changes has to be inside a data.lua, data-updates.lua or a data-final-fixes.lua file inside your mod for the changes to take effect(you can read more about what the different file names do here). Here is an example of what a data.lua file could contain to decrease the size of the steam engine(not tested).
Here is the steam engine prototype definition.
Code: Select all
{
type = "generator",
name = "steam-engine",
icon = "__base__/graphics/icons/steam-engine.png",
flags = {"placeable-neutral","player-creation"},
minable = {mining_time = 1, result = "steam-engine"},
max_health = 300,
corpse = "big-remnants",
dying_explosion = "medium-explosion",
effectivity = 1,
fluid_usage_per_tick = 0.1,
resistances =
{
{
type = "fire",
percent = 70
}
},
collision_box = {{-1.35, -2.35}, {1.35, 2.35}},
selection_box = {{-1.5, -2.5}, {1.5, 2.5}},
fluid_box =
{
base_area = 1,
pipe_covers = pipecoverspictures(),
pipe_connections =
{
{ position = {0, 3} },
{ position = {0, -3} },
},
},
energy_source =
{
type = "electric",
usage_priority = "secondary-output"
},
horizontal_animation =
{
filename = "__base__/graphics/entity/steam-engine/steam-engine-horizontal.png",
width = 246,
height = 137,
frame_count = 32,
line_length = 8,
shift = {1.34, -0.06}
},
vertical_animation =
{
filename = "__base__/graphics/entity/steam-engine/steam-engine-vertical.png",
width = 155,
height = 186,
frame_count = 32,
line_length = 8,
shift = {0.812, 0.031}
},
smoke =
{
{
name = "light-smoke",
north_position = {0.9, 0.0},
east_position = {-2.0, -2.0},
frequency = 10 / 32,
starting_vertical_speed = 0.08,
slow_down_factor = 1,
starting_frame_deviation = 60
}
},
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
working_sound =
{
sound =
{
filename = "__base__/sound/steam-engine-90bpm.ogg",
volume = 0.6
},
match_speed_to_activity = true,
},
min_perceived_performance = 0.25,
performance_to_sound_speedup = 0.5
}
Code: Select all
horizontal_animation =
{
filename = "__base__/graphics/entity/steam-engine/steam-engine-horizontal.png",
width = 246,
height = 137,
frame_count = 32,
line_length = 8,
scale = 0.5,
shift = {1.34, -0.06}
},
vertical_animation =
{
filename = "__base__/graphics/entity/steam-engine/steam-engine-vertical.png",
width = 155,
height = 186,
frame_count = 32,
line_length = 8,
scale = 0.5,
shift = {0.812, 0.031}
}
Code: Select all
data.raw["generator"]["steam-engine"].collision_box = {{-1.35 / 2, -2.35 / 2}, {1.35 / 2, 2.35 / 2}}
data.raw["generator"]["steam-engine"].selection_box = {{-1.5 / 2, -2.5 / 2}, {1.5 / 2, 2.5 / 2}}
data.raw["generator"]["steam-engine"].fluid_box.pipe_connections[1].position = {0, 3 / 2}
data.raw["generator"]["steam-engine"].fluid_box.pipe_connections[2].position = {0, -3/ 2}
data.raw["generator"]["steam-engine"].horizontal_animation.scale = 0.5
data.raw["generator"]["steam-engine"].vertical_animation.scale = 0.5
Waste of bytes : P
-
- Manual Inserter
- Posts: 2
- Joined: Thu Apr 21, 2016 3:13 am
- Contact:
Re: First time modder here! Running into a roadblock.
Thanks for the help! I was able to find the steam engine prototype and with it I successfully made new steam engines that behave exactly like the existing ones, except requiring 2x or 4x the fuel (while producing 2x or 4x the power), but otherwise looking exactly like the original steam engine. It was actually fairly simple to do. I also made matching research for them.
The one thing I was not able to figure out how to do was how to speed up the animation of the engines running. I added a variable 'animation_speed' to both my 2x and 4x engines, but neither seem to actually appear as if they are running faster. Here's my entity.lua code.
The one thing I was not able to figure out how to do was how to speed up the animation of the engines running. I added a variable 'animation_speed' to both my 2x and 4x engines, but neither seem to actually appear as if they are running faster. Here's my entity.lua code.
Code: Select all
data:extend({
{
type = "generator",
name = "compact-steam-engine-double",
icon = "__base__/graphics/icons/steam-engine.png",
flags = {"placeable-neutral","player-creation"},
minable = {mining_time = 1.5, result = "compact-steam-engine-double"},
max_health = 450,
corpse = "big-remnants",
dying_explosion = "medium-explosion",
effectivity = 1,
fluid_usage_per_tick = 0.2,
resistances =
{
{
type = "fire",
percent = 70
}
},
collision_box = {{-1.35, -2.35}, {1.35, 2.35}},
selection_box = {{-1.5, -2.5}, {1.5, 2.5}},
fluid_box =
{
base_area = 1,
pipe_covers = pipecoverspictures(),
pipe_connections =
{
{ position = {0, 3} },
{ position = {0, -3} },
},
},
energy_source =
{
type = "electric",
usage_priority = "secondary-output"
},
horizontal_animation =
{
filename = "__base__/graphics/entity/steam-engine/steam-engine-horizontal.png",
width = 246,
height = 137,
frame_count = 32,
line_length = 8,
shift = {1.34, -0.06}
},
vertical_animation =
{
filename = "__base__/graphics/entity/steam-engine/steam-engine-vertical.png",
width = 155,
height = 186,
frame_count = 32,
line_length = 8,
shift = {0.812, 0.03125}
},
smoke =
{
{
name = "light-smoke",
north_position = {0.9, 0.0},
east_position = {-2.0, -2.0},
frequency = 10 / 32,
starting_vertical_speed = 0.08,
slow_down_factor = 1,
starting_frame_deviation = 60
}
},
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
working_sound =
{
sound =
{
filename = "__base__/sound/steam-engine-90bpm.ogg",
volume = 0.6
},
match_speed_to_activity = true,
},
min_perceived_performance = 0.25,
performance_to_sound_speedup = 0.5,
animation_speed = 2
},
{
type = "generator",
name = "compact-steam-engine-quadruple",
icon = "__base__/graphics/icons/steam-engine.png",
flags = {"placeable-neutral","player-creation"},
minable = {mining_time = 1.5, result = "compact-steam-engine-quadruple"},
max_health = 600,
corpse = "big-remnants",
dying_explosion = "medium-explosion",
effectivity = 1,
fluid_usage_per_tick = 0.4,
resistances =
{
{
type = "fire",
percent = 70
}
},
collision_box = {{-1.35, -2.35}, {1.35, 2.35}},
selection_box = {{-1.5, -2.5}, {1.5, 2.5}},
fluid_box =
{
base_area = 1,
pipe_covers = pipecoverspictures(),
pipe_connections =
{
{ position = {0, 3} },
{ position = {0, -3} },
},
},
energy_source =
{
type = "electric",
usage_priority = "secondary-output"
},
horizontal_animation =
{
filename = "__base__/graphics/entity/steam-engine/steam-engine-horizontal.png",
width = 246,
height = 137,
frame_count = 32,
line_length = 8,
shift = {1.34, -0.06}
},
vertical_animation =
{
filename = "__base__/graphics/entity/steam-engine/steam-engine-vertical.png",
width = 155,
height = 186,
frame_count = 32,
line_length = 8,
shift = {0.812, 0.03125}
},
smoke =
{
{
name = "light-smoke",
north_position = {0.9, 0.0},
east_position = {-2.0, -2.0},
frequency = 10 / 32,
starting_vertical_speed = 0.08,
slow_down_factor = 1,
starting_frame_deviation = 60
}
},
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
working_sound =
{
sound =
{
filename = "__base__/sound/steam-engine-90bpm.ogg",
volume = 0.6
},
match_speed_to_activity = true,
},
min_perceived_performance = 0.25,
performance_to_sound_speedup = 0.5,
animation_speed = 4
}
})
Re: First time modder here! Running into a roadblock.
animation_speed needs to go inside the specific animation you want to apply it to, i.e. inside the brackets where the image filename also is. I think you have it in the outer bracket where it will be ignored.
Re: First time modder here! Running into a roadblock.
Thank you for the great answers. I think I learned a dozen things reading the answers. 
