Edit: Whoa! You hadn't responded while I was writing this, Alec. Thanks for the info!
Technically you can do so by calling "entity_initSkeletal(getNaija(), "priest")". This causes the avatar to change correctly while editing, but as soon as I switch back to the game it crashes. I think the problem is that entities often keep bones in their variables (such as the neck for hanging the cloak). These bone references are to pointers that change depending upon the skeleton, so when you change the skeleton the bone references are garbage and entity_getBoneByName needs to be called again. There should be a function in Naija's script that allows it to reinitialise those for costume changes, but I don't know how to call an entity's function from another script directly. I really doubt you can.
One way to hack this is to make a second entity that hides Naija and moves itself into her place. Here's a start of doing that:
dofile("scripts/entities/entityinclude.lua")
n = 0 -- Link to naija.
function init(me)
setupEntity(me)
entity_setEntityType(me, ET_ENEMY)
entity_initSkeletal(me, "mermanthin")
entity_setState(me, STATE_IDLE)
-- Find the Naija entity.
n = getNaija ()
-- Move the bones to the right positions.
entity_animate (me, "idle", LOOP_INF)
end
function update(me, dt)
-- Hide Naija.
entity_alpha (n, 0)
-- Face the same way as Naija; I don't know how to get rid of the transition.
entity_flipToSame (me, n)
-- Move to Naija's position.
entity_setPosition (me, entity_getPosition (n))
-- Change to Naija's angle.
entity_rotate (me, entity_getRotation (n))
-- Use the same animation as Naija if they're different.
-- If the skeleton doesn't have this animation then it turns into a body part jumble.
if entity_getAnimationName (me) ~= entity_getAnimationName (n) then
entity_animate (me, entity_getAnimationName (n), LOOP_INF)
end
end
Just put that into an entity lua file, add it to entitygroups.txt, and then put it in the level (you can keep the editor open and just hit F1 to reload the level). As soon as you get out of the editor you should look like a mermanic jerk. His animations work for idling, swimming, surging, and sort of for wall hanging (he doesn't have a proper animation hanging onto the ground and he tries to walk along the wall).
Even if you could substitute a skeleton directly, the behaviour would be similar to what you see with this hack, with body part jumbles showing up if it doesn't have that animation. Naturally a sea turtle doesn't know how to hang onto walls, or even how to swim.
Edit edit: Here's an update of the animation part that allows you to substitute animations which don't work, and it also shows a nice way to use setControlHint to pass information about game state while testing. You can keep Naija from hanging by calling "avatar_fallOffWall ()" in the update function.
anim = entity_getAnimationName (n)
if entity_getAnimationName (me) ~= anim then
changeto = anim -- The animation to change to, or "no change" to ignore Naija.
-- We don't have "walllookup" (for when holding onto the floor), so use "wall" instead.
if anim == "walllookup" then
changeto = "wall"
end
if changeto ~= "no change" and entity_getAnimationName (me) ~= changeto then
entity_animate (me, changeto, LOOP_INF)
end
-- setControlHint ("Animation: " .. entity_getAnimationName (n), 0, 0, 0, 2)
end