Modding Help Help with simple object animation

Discussion in 'Starbound Modding' started by Sectrix, Feb 25, 2017.

  1. Sectrix

    Sectrix Phantasmal Quasar

    Been out of the SB modding scene awhile, and I can't figure how to make a simple animation.

    I have an image file of the two sprites in a single row. Each sprite is 16x16 pixels, making the image file 16x32.

    All of the files for the object reside in the same folder: textInput.

    Here's the relevant part of the object file:

    Code:
    "inventoryIcon" : "textInputIcon.png",
      "orientations" :
       [
         {
           "image" : "textInput.png:<frame>.off",
           "imagePosition" : [0, 0],
           "spaceScan" : 0.1,
           "anchors" : ["background"]
         }
       ],
    
      "animation" : "textInput.animation",
      "animationParts" :
      {
      "switch" : "textInput.png"
      },
      "animationPosition" : [0, 0],
    


    And the animation file:
    Code:
    {
    "animatedParts" :
       {
       "stateTypes" :
         {
         "switchState" :
           {
           "default" : "default",
           "states" :
             {
             "off" :
               {
               "frames" : 2,
               "cycle" : 3,
               "mode" : "loop"
               }
             }
           }
         },
    
       "parts" :
         {
         "switch" :
           {
           "properties" :
             {
             "centered" : false
             },
    
           "partStates" :
             {
             "switchState" :
               {
               "off" :
                 {
                 "properties" :
                   {
                   "image" : "<partImage>:default.<frame>"
                   }
                 }
               }
             }
           }
         }
       }
    }


    And finally, the frames file:

    Code:
    {
    "frameGrid" :
        {
        "size" : [16, 32],
        "dimensions" : [2, 1],
        "names" :
            ["default1", "default2"]
        },
    
    "aliases" :
        {
        "default.off" : "default1",
        "default.1" : "default1",
        "default.2" : "default2"
        }
    }


    The logs show it can't find textInput.png:

    Code:
    [15:03:29.297] [Error] Could not load image asset '/textInput/textInput.png', using placeholder default.
    (JsonException) size() called on improper json type
    [15:03:29.305] [Error] Could not load image asset '/textInput/textInput.png:default.off', using placeholder default.
    (AssetException) No associated frames file found for image '/textInput/textInput.png' while resolving image frame '/textInput/textInput.png:default.off'
    


    Those are the only errors in the log. Through trial and error, I've found it must be this line causing the issue:
    Code:
    "image" : "textInput.png:<frame>.off",
    
    All the files (including the .png) are in the same folder, so I'm assuming I've got the path wrong somehow. I've tried:
    Code:
    textInput.png
    /textInput.png
    /textInput/textInput.png
    textInput/textInput.png
    
    to no avail. I also made sure spelling and capital letters were correct.

    I feel like this is a super simple issue, but all the documentation I've found is horribly out of date. I looked at the 'scanner' wired object as an example, but I can't see what was done differently.
     
  2. IHart

    IHart Scruffy Nerf-Herder

    "image" : "textInput.png:<frame>.off" should probably be "image" : "textInput.png:default.off"
    in the same folder 'textInput.png' is an acceptable path. Fullpath would start with '/objects/..etc..' assuming you have your objects in the objects directory. Relative paths do not require the leading slash.
    Is your frames file names 'textInput.frames'?
     
  3. Sectrix

    Sectrix Phantasmal Quasar

    Just tried this, with the same result:


    Code:
    [15:55:32.419] [Error] Could not load image asset '/textInput/textInput.png', using placeholder default.
    (JsonException) size() called on improper json type
    [15:55:32.429] [Error] Could not load image asset '/textInput/textInput.png:default.off', using placeholder default.
    (AssetException) No associated frames file found for image '/textInput/textInput.png' while resolving image frame '/textInput/textInput.png:default.off'
    


    Yes, I made sure to name it the same as the image.
     
  4. mastercookie

    mastercookie Existential Complex

    is it just animation or is it a toggleable object?
     
  5. IHart

    IHart Scruffy Nerf-Herder

    I could probably fix it by tinkering with it if you want to share your files.
     
  6. Sectrix

    Sectrix Phantasmal Quasar

    Just a plain, looping animation. The object is interactable, if that makes a difference.
     
  7. mastercookie

    mastercookie Existential Complex

    in what way it is interactable? because if u start/stop animation by interacting, its one thing and if it's always looping, it's actually quite simple.
     
  8. bk3k

    bk3k Oxygen Tank

    Keep in mind <this> will be swapped with another piece of text.
    Thus
    Code:
    "textInput.png:<frame>.off"
    translates to
    Code:
    "textInput.png:1.off"
    and after the frame change
    Code:
    "textInput.png:2.off"
    everything in your string after : will be your frame names. You need to have a literal string name available to match or you'll get that error.

    Also note if you use the <color> tag(not really used by starbound much now), the default color is "default" and if recolored it would need a frame for "red1", "red2", "yellow1", "yellow2", etc.

    It is popular(but not mandatory) to use the convention of "default.1", "default.2" as frames names.
    That would derive from "default.<frame>" and is simply provides a visual distinction in the frame names for the part that refers to actual state frames.

    You can define your own tags in the animation file too, and swap their values via lua. But first you have to get this part down.
     
  9. mastercookie

    mastercookie Existential Complex

    rub it in, wont u :)
     
  10. bk3k

    bk3k Oxygen Tank

    Well anyhow I guess I can just give you the answer, but I wanted you to understand WHY the answer is what it is.

    I'd change the frames file like so
    Code:
    {
      "frameGrid" : {
        "size" : [16, 32],
        "dimensions" : [2, 1],
        "names" : [
          "default.1", "default.2"
        ]
      },
    
      "aliases" : {
        "default.off" : "default.1",
        "default.default" : "default.1"
      }
    }
    and probably for the object

    Code:
    "textInput.png:default.default"
    But I believe
    Code:
    "textInput.png:default.1"
    Code:
    "textInput.png:default.off"
    Code:
    "textInput.png:default.<frame>"
    would all get you there. That's just the image while placing it. Your animation file will take over the actual animation.

    Probably
    Code:
    "<partImage>:default.<frame>"
    etc for your .animation files. But if you add more frames for more states, then obviously append that into the string as necessary.

    Honestly I haven't even looked at your animation file yet.

    Yes, I will.
     
    Last edited: Feb 25, 2017
  11. Sectrix

    Sectrix Phantasmal Quasar

    Hmm, I've tried your suggestion bk3k, but I still get the exact same error in the logs:


    Code:
    [18:08:38.057] [Error] Could not load image asset '/textInput/textInput.png', using placeholder default.
    (JsonException) size() called on improper json type
    [18:08:38.065] [Error] Could not load image asset '/textInput/textInput.png:default.default', using placeholder default.
    (AssetException) No associated frames file found for image '/textInput/textInput.png' while resolving image frame '/textInput/textInput.png:default.default'
    


    I appreciate your help so far, though.
     
  12. Sectrix

    Sectrix Phantasmal Quasar

    It is interactable in that it opens a ScriptConsole. I don't want interaction to have anything to do with the animation.
     
  13. Sectrix

    Sectrix Phantasmal Quasar

    Here's the source files, if anyone wants to try it out on their own:

    textInput.object: http://pastebin.com/fkrkir4C
    textInput.animation: http://pastebin.com/MMAnqMB9
    textInput.frames: http://pastebin.com/HLeTVuTW
    textInputIcon.png: http://imgur.com/a/Wb5KX
    textInput.png: http://imgur.com/a/UmOL0

    You'll probably have to delete all the penguinGUI stuff to get it to work - there's way too many files to link them here. Downloading the original penguinGUI won't work either since the mod author hasn't updated since beta. I had to update it on my own.
     
  14. bk3k

    bk3k Oxygen Tank

    I want to establish some facts then

    1. the object is located in /textInput/
    2. the .png file, .frames file, and .animation file are all located in this same folder
    3. the .png file is specifically named textInput.png
    4. the .frames file is specifically named textInput.frames and again is located in the same folder as the identically named(besides the extension) .png file
    5. your animation file is specifically named textInput.animation

    Are all of these things true?

    Also make sure that if you're on Windows, you've disabled the folder option for "hide extensions for known types". That is an option that SHOULD NEVER HAVE EXISTED. Worst idea ever. Besides problems like this that can occur
    Favorite_Band-Favorite_song.mp3.exe
    That's a fine way to trick people into running viruses.

    edit: after seeing your image, I can tell you your frames file is wrong. The correct answer is -

    Code:
    "size" : [16, 16],
    The size is how big a single frame is, not the total PNG dimensions.
    Your "dimensions" are correct. 2 x 1 aka [x, y]
    This file is telling Starbound how to cut up your PNG image, if that makes more sense to you.
     
    Last edited: Feb 26, 2017
  15. Sectrix

    Sectrix Phantasmal Quasar

    Yes, all of those things are true.

    http://imgur.com/a/P3x5a
    And also I checked to make sure that folder option was disabled; it is.

    You can ignore the .objectt file, it's an alternative version without the animation stuff that I'm using until this is sorted out.
     
  16. bk3k

    bk3k Oxygen Tank

    Note my edit at the end of my last post.
    I also thought I saw a JSON error in your animation file, but I just misread it until I adjusted the brackets.
    You can thank me later.
    Code:
    {
      "animatedParts" :{
        "stateTypes" : {
          "switchState" : {
            "default" : "default",
            "states" : {
              "off" : {
                "frames" : 2,
                "cycle" : 3,
                "mode" : "loop"
              }
            }
          }
        },
        "parts" : {
          "switch" : {
            "properties" : {
              "centered" : false
            },
            "partStates" : {
              "switchState" : {
                "off" : {
                  "properties" : {
                    "image" : "<partImage>:default.<frame>"
                  }
                }
              }
            }
          }
        }
      }
    }
    I use notepad++ with the index guide turned on, 2 space tabs, bracket highlighting, and language specific profiles. That makes a world of difference for actually reading JSON files, but you want to keep your brackets aligned for it to work best.

    For example when highlighting the { after "switchState" : , I can see both it and the closing bracket } highlighted in red. I can also see a faint (but highlighted) line following down from the forward " of "switchState" to that same closing bracket.

    This makes finding JSON errors 1000x easier, not to mention allowing you to catch them right off. And actually following the JSON structure is also 1000x easier.

    Also note that unlike the Steam workshop, you can attach files directly to these forum posts. That includes .zip and .7z files. So that's easier for everyone.
     
  17. Sectrix

    Sectrix Phantasmal Quasar

    Ahh, I was sure that was it. But it isn't. Same error, still can't find the image. This is maddening.

    I even closed GIMP just in case it was locking the file.

    As an aside, I prefer my brackets the way I had them. Been doing it that way as long as I can remember. I find the other way harder to read. I also have Notepad++, and setup in much the same way.

    In any case, I appreciate all your effort.
     
  18. bk3k

    bk3k Oxygen Tank

    So with this frames file
    Code:
    {
      "frameGrid" : {
        "size" : [16, 16],
        "dimensions" : [2, 1],
        "names" : [
          "default.1", "default.2"
        ]
      },
    
      "aliases" : {
        "default.off" : "default.1",
        "default.default" : "default.1"
      }
    }
    and your object as seen on pastebin, you still get that error? Specifically after fixing the "size" in the frames? That is odd because I could see how having the size wrong would lead to

    Code:
    Could not load image asset '/textInput/textInput.png', using placeholder default.
    (JsonException) size() called on improper json type
    Possibly your animation file though...
    I just noticed this but

    Code:
          "switchState" : {
            "default" : "default",
            "states" : {
              "off" : {
                "frames" : 2,
                "cycle" : 3,
                "mode" : "loop"
              }
            }
          }
    You don't have a state mentioned there under the nameSpace of "default" so that's probably a problem. The only state you have is "off" so your animation file should say this.

    Code:
    {
      "animatedParts" :{
        "stateTypes" : {
          "switchState" : {
            "default" : "off",
            "states" : {
              "off" : {
                "frames" : 2,
                "cycle" : 3,
                "mode" : "loop"
              }
            }
          }
        },
         "parts" : {
          "switch" : {
            "properties" : {
              "centered" : false
            },
             "partStates" : {
              "switchState" : {
                "off" : {
                  "properties" : {
                    "image" : "<partImage>:default.<frame>"
                  }
                }
              }
            }
          }
        }
      }
    }
    A useful animation file to check out would be
    /object/wired/door/door.animation
    paired with any door object that uses it plus their associated PNGs and .frames files
     
  19. mastercookie

    mastercookie Existential Complex

    i can tell u what i use for simple animations:
    frames file look like this
    Code:
    {
      "frameGrid" : {
        "size" : [16, 16],
        "dimensions" : [2, 1],
        "names" : [
          [ "default.0", "default.1"]
      },
    
      "aliases" : {
        "default.default" : "default.0"
      }
    }
    "size" is the size of one frame, not the whole image.
    "dimensions" is basically the amount of frames


    and the .object is like this (relevant parts):
    Code:
    
    {
      "orientations" : [
      {
      "dualImage" : "textInput.png:<color>.<frame>",
    
      "imagePosition" : [0, 0],
      "frames" : 2,
      "animationCycle" : 3,
    
      "spaceScan" : 0.3,     
      "anchors" : [ "bottom" ]
    
      }
      ]
    }
    i dont think u need .animation for simple stuff, since it's all in orientations (frames and cycle)
    so try deleting (or commenting) all of this:

    "animation" : "textInput.animation",
    "animationParts" : {
    "switch" : "textInput.png"
    },
    "animationPosition" : [0, 0],
     
  20. Sectrix

    Sectrix Phantasmal Quasar

    bk3k,
    Yes, I fixed the size field in the frames file; still the same error. I also changed the animation file as you suggested, with no difference.

    Mastercookie,
    I also tried your suggestions: I modified the frames and object files, and removed all references to animation. Still the same result.

    Overall, it seems to me it simply can't find the image and frames file for some reason. I checked permissions, made sure the file wasn't locked, changed the name, changed the name to all lowercase, placed copies of it all over the mods folder; and still the same persistent error:

    Code:
    [12:29:40.592] [Error] Could not load image asset '/textInput/animage.png', using placeholder default.
    (JsonException) size() called on improper json type
    [12:29:40.600] [Error] Could not load image asset '/textInput/animage.png:default.default', using placeholder default.
    (AssetException) No associated frames file found for image '/textInput/animage.png' while resolving image frame '/textInput/animage.png:default.default'
     

Share This Page