Modding Help Anyway to get a player/NPC's "bodycolor" color mapping?

Discussion in 'Starbound Modding' started by Stellario, Oct 30, 2016.

  1. Stellario

    Stellario Seal Broken

    Still working on a mod that includes a skin tone in an armor piece (extra muscle). I got a status effect working when it gets equipped, but is there a way to access a player's "bodycolor" mapings from within a status script?

    Also, is there a way to cause a status effect even when an object is in a social slot?
     
  2. Errors4l

    Errors4l Spaceman Spiff

    If you can obtain the player's entity id in the status script, you might want to take a look at world.entityPortrait(id, "full").
    I believe the 5th layer (result[5].image) is what you're looking for; this consists of a full image path and the directives.
     
  3. Stellario

    Stellario Seal Broken

    Thank You! I will try that!
     
  4. Stellario

    Stellario Seal Broken

    Ah, it didn't work... I was able to get the current player portrait, but the contents changes based on player's current outfit. If they're wearing armor there's no way to get the skin tone.
     
  5. Errors4l

    Errors4l Spaceman Spiff

    Are you sure? The parts should still be there, and the directives will be the same regardless. You'll just have to figure out the order of the layers.
     
  6. Stellario

    Stellario Seal Broken

    If a player has armor on, portrait just shows the armor png and it's directives, not the (nude) body part. I might make another status effect that removes the armor temporarily, then do a search for "torso" and store the directives attached to that png... then apply different status effect that does what I wanted.
     
  7. Errors4l

    Errors4l Spaceman Spiff

    The portrait is a collection of layers. The only time layers affect each other is when a mask is applied (eg when the mask of a hat is applied to hair layer). Even with armor equipped, the body is under there (as made obvious by the fact that you can still see your body in-game when wearing clothes that don't cover your entire body). Try to log the entity portrait, and see what the actual image paths are.
    sb.logInfo("%s", sb.printJson(portrait))
     
  8. Stellario

    Stellario Seal Broken

    OMG! You're absolutely right! I dunno why I thought it disappeared.... I must have misread the list a bunch of times--I totally thought it wasn't there. >.<;;
     
    Errors4l likes this.
  9. Stellario

    Stellario Seal Broken

    Just for future reference to other modders:
    This basic bit of code applies a status effect to recolor everything according to the directives on the layer that contains "body.png." The status effect is attached to a leg armor in this picture. Prolly don't need it to fire off every update though.
    Code:
    function update(dt)
        local portrait = world.entityPortrait(entity.id(), "full")
        for key, value in pairs(portrait) do
            if string.find(portrait[key].image, "body.png") then
                local body_image =  portrait[key].image
                local directive_location = string.find(body_image, "replace")
                local directives = string.sub(body_image,directive_location)
                effect.setParentDirectives(directives)
            end
        end
    end
    [​IMG]

    Thanks Errors4l!
     
    Last edited: Nov 3, 2016
    DrPvtSkittles, IHart and Errors4l like this.
  10. C0bra5

    C0bra5 Oxygen Tank

    welp i don't know how you found that out, but o god have you fixed one of my biggest problem.
     
  11. Errors4l

    Errors4l Spaceman Spiff

    I display the player's character in the Wardrobe interface mod. For that, I had to figure out what layer numbers I had to apply masks to and such when you select a different hat.
    You can't identify the layers by name, so wearing pants vs. not wearing pants changes the indices of body layers. The forearm layer, for example, would be found later in the returned collection, since it comes aftermost clothing layers. The best/only way to find a layer is to read and parse the image path (eg. /humanoid... is body, /items... is clothing).
     
  12. IHart

    IHart Scruffy Nerf-Herder

    saving this for a rainy day
     

Share This Page