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?
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.
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.
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.
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.
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))
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. >.<;;
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 Thanks Errors4l!
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).