Page 1 of 1

rail_pictures()

Posted: Sat Jun 15, 2019 4:32 pm
by SPolygon
Hello. I want to add a new rail type via a mod. I thought I could just copy the code and graphics of the vanilla rail and edit them to my liking, but I don't really understand how I can replace the sprites of the new straight rail and curved rail entities I'm adding.
I was expecting the graphics definition to be included in the entity entry of the rails, but instead there is just a single line saying

Code: Select all

pictures = rail_pictures()
Where can I find the original definition of rail_pictures() and how can I create my own?

Re: rail_pictures()

Posted: Sat Jun 15, 2019 4:50 pm
by eduran
At the beginning of entities.lua you can find:

Code: Select all

rail_pictures = function()
  return rail_pictures_internal({
   {"metals", "metals", mipmap = true},
   {"backplates", "backplates", mipmap = true},
   {"ties", "ties", variations = 3},
   {"stone_path", "stone-path", variations = 3},
   {"stone_path_background", "stone-path-background", variations = 3},
   {"segment_visualisation_middle", "segment-visualisation-middle"},
   {"segment_visualisation_ending_front", "segment-visualisation-ending-1"},
   {"segment_visualisation_ending_back", "segment-visualisation-ending-2"},
   {"segment_visualisation_continuing_front", "segment-visualisation-continuing-1"},
   {"segment_visualisation_continuing_back", "segment-visualisation-continuing-2"}
  })
end
and demo-rail-pictures.lua has the definition of rail_pictures_internal(). The wiki entry about the rail prototype could also be helpful.