EarendelDevelopers / factorio-mods

This is a public repository for tracking issues with Earendel's factorio mods.
19 stars 3 forks source link

Jetpack compatibility with Scooty's Armor Swap - graphics do not update along with player color changes #338

Closed scotthmccoy closed 7 months ago

scotthmccoy commented 7 months ago

My own mod, Scooty's Armor Swap, adds a hotkey which cycles through armors in the inventory and updates the player's color to whatever it was when the armor was last worn, effectively allowing armors to be "dyed". Sadly, player color changes do not seem to affect the jetpack.

Expected: Changing player color while using jetpack will change the color of the jetpack sprites

Observed: Jetpack sprite color changes do not take effect until the player lands

Proposed Fix: Insert the following on line 71 of jetpack-graphics-sound.lua:

    rendering.set_color(jetpack.animation_mask, jetpack.character.player and jetpack.character.player.color or jetpack.character.color)

I've tested the fix pretty thoroughly and it doesn't seem to affect UPS.

Quezler commented 7 months ago

alternatively, in your own mod it should be possible to do: (in an event listener, so it doesn't run every tick)

local jetpack = remote.call("jetpack", "get_jetpack_for_character", {character=player.character})
rendering.set_color(jetpack.animation_mask, jetpack.character.player and jetpack.character.player.color or jetpack.character.color)
scotthmccoy commented 7 months ago

Oh dang, I didn't realize that mods can talk to each other like that. That fix is working perfectly, thank you!