Modding Help ScalingGroups, Offset, and image flips (object direction)

Discussion in 'Starbound Modding' started by Olxinos, Oct 26, 2014.

  1. Olxinos

    Olxinos Scruffy Nerf-Herder

    Good evening or whatever instant of the day you're reading this topic!
    So, i've played Starbound for a couple months, and i wanted to give modding a try. So, yesterday, i came up with some turret (highly inspired of the vanilla standing turret). The thing is, i want my turret to be placed with both directions and to display some kind of energy gauge on one side of the turret, but it doesn't work very well.

    Long story short, when the game tries to flip the sprite, it doesn't flip the animation-parts 'offset' or the scalingGroups' 'pivot'. I can deal with the former by adding "blanks" in the spritemap, but not the latter which leads to this annoying situation:
    misplacedgauge.png
    The left turret is fine (although running out of energy), but not the right one which shows up a misplaced energy gauge (on the bottom right corner).

    So i wondered whether:
    - i was doing it horribly wrong and there is a so much better way to do so
    - it is a desirable behaviour not to take into account these attributes when flipping the image (and why such a behaviour)
    On a side note, i'd also like to know how to crop images rather than scaling them (the latter causes a problem when displaying a "wave" animation on the gauge, you can see it on the previous image although it's small), but that's not what i am posting for.

    To "clarify" things, here is the .animation file:
    Code:
    {
      "animatedParts" :
      {
        "stateTypes" :
        {
          "cannonMode" :
          {
            "priority" : 0,
            "default" : "off",
            "states" :
            {
              "idle" : {},
              "off" : {},
              "shoot" :
              {
                "frames" : 4,
                "cycle" : 0.25,
                "mode" : "transition",
                "transition" : "idle"
              }
            }
          },
          "turretMode" :
          {
            "default" : "auto",
            "states" :
            {
              "auto" :
              {
                "frames" : 10,
                "cycle" : 1,
                "mode" : "loop"
              },
              "off" :
              {
                "frames" : 10,
                "cycle" : 1,
                "mode" : "loop"
              }
            }
          },
          "usedMode" :
          {
            "default" : "single",
            "states" :
            {
              "single" :
              {
                "frames" : 10,
                "cycle" : 1,
                "mode" : "loop"
              }
            }
          }
        },
    
        "parts" :
        {
          "cannon" :
          {
            "properties" :
            {
              "offset" : [0, 1.75],
              "rotationGroup" : "cannon",
              "centered" : false,
              "zLevel" : 3
            },
    
            "partStates" :
            {
              "cannonMode" :
              {
                "idle" :
                {
                  "properties" :
                  {
                    "image" : "<partImage>:idle"
                  }
                },
                "off" :
                {
                  "properties" :
                  {
                    "image" : "<partImage>:off"
                  }
                },
                "shoot" :
                {
                  "properties" :
                  {
                    "image" : "<partImage>:shoot.<frame>"
                  }
                }
              }
            }
          },
    
          "base" :
          {
            "properties" :
            {
              "offset" : [0, 0],
              "centered" : false,
              "zLevel" : 1,
              "image" : "<partImage>"
            }
          },
          "energybar" :
          {
            "properties" :
            {
              "offset" : [2.125, 0.25],
              "centered" : false,
              "zLevel" : 3,
              "scalingGroup" : "energybar"
            },
    
            "partStates" :
            {
              "turretMode" :
              {
                "auto" :
                {
                  "properties" :
                  {
                    "image" : "<partImage>:auto.<frame>"
                  }
                },
                "off" :
                {
                  "properties" :
                  {
                    "image" : "<partImage>:manual.<frame>"
                  }
                }
              }
            }
          },
          "usedbar" :
          {
            "properties" :
            {
              "offset" : [2.125, 0.25],
              "centered" : false,
              "zLevel" : 2
            },
    
            "partStates" :
            {
              "usedMode" :
              {
                "single" :
                {
                  "properties" :
                  {
                    "image" : "<partImage>:default.<frame>"
                  }
                }
              }
            }
          }
        }
      },
    
      "rotationGroups" :
      {
        "cannon" :
        {
          "rotationCenter" : [1.375, 2.25],
          "angularVelocity" : 1
        }
      },
      "scalingGroups" :
      {
        "energybar" :
        {
          "pivot" : [3.25, 0.25]
        }
      }
    }
    
    I'll also post a dropbox link with all the files if you want to see other files in a couple minutes (if this forum allows me to do so, of course), but in case you'd want to run it, it requires starfoundry (as it consumes starfoundry energy).
    Also, don't hesitate to tell me if you know a better way to do (i did it yesterday and that was my first contact with starbound modding). For instance, i came up with something weird for the beam: shooting ten projectile-spawners with different timeToLive in order to display a long straight line, then adding some weird beamstart sprite because the beam seemed to be shoot one meter away from the turret. But now it works. Kind of.

    Edit:
    here's the link: https://www.dropbox.com/s/8assnq97pk471t3/oxs_ionturret_0.1.modpak?dl=0
    Edit3: updated the link
     
    Last edited: Oct 28, 2014

Share This Page