Add custom Train driving animation
Add custom Train driving animation
So i want to make a mod that contains steam engins with animated siderods. i tried to make the train switch throgh several test animations, but everything i try just prevents the game from loading. i thoght about coding a custmo script that replaces renders an animation on top of the train, but i cant figure out how to get the orientation and speed of a lokomotive. I'm not the best with code so if some more expirienced coders could help me, i'd aprecieate it.
-
- Smart Inserter
- Posts: 2767
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Add custom Train driving animation
As far as I’m aware, they don’t support that type of animation:
https://wiki.factorio.com/Prototype/Locomotive
https://wiki.factorio.com/Prototype/Locomotive
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Add custom Train driving animation
But is there a way to create a script that gets the rotation and speed of the locomotive, and then places a animated image on top of the locomotive?
Re: Add custom Train driving animation
Yes:Cyberpro_ wrote: Mon Aug 15, 2022 6:24 am But is there a way to create a script that gets the rotation and speed of the locomotive, and then places a animated image on top of the locomotive?
https://lua-api.factorio.com/latest/Lua ... rientation
https://lua-api.factorio.com/latest/Lua ... tity.speed
I'd recommend joining #mod-making on the Factorio Discord for modding help

My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: Add custom Train driving animation
i tried making a simple scrip that should print directio but it only returns "unkonwn key 0"
. Is ther a problem with my code or where is the problem?
Code: Select all
script.on_event(defines.events.on_tick , function(event) game.print(defines.riding.direction) end)
Re: Add custom Train driving animation
defines.riding.direction is a list of constants. It is not a variable representing any state in the game.
What you want is to read the "game.players[1].riding_state.direction" (if you want player #1) and then use IF-ELSE to see if it is equal to either "defines.riding.direction.left", "defines.riding.direction.straight", or "defines.riding.direction.right". For each case you write a separate game.print statement with the matching direction being printed.
What you want is to read the "game.players[1].riding_state.direction" (if you want player #1) and then use IF-ELSE to see if it is equal to either "defines.riding.direction.left", "defines.riding.direction.straight", or "defines.riding.direction.right". For each case you write a separate game.print statement with the matching direction being printed.
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk