engine/gamesys/src/gamesys/scripts/script_spine_model.cpp
/*# sets the spine skin
     * Sets the spine skin on a spine model.
     *
     * @name spine.set_skin
     * @param url [type:string|hash|url] the spine model for which to set skin
     * @param spine_skin [type:string|hash] spine skin id
     * @param [spine_slot] [type:string|hash] optional slot id to only change a specific slot
     * @examples
     *
     * The following examples assumes that the spine model has id "spinemodel".
     *
     * Change skin of a Spine model
     *
     * ```lua
     * function init(self)
     *   spine.set_skin("#spinemodel", "monster")
     * end
     * ```
     *
     * Change only part of the Spine model to a different skin.
     *
     * ```lua
     * function monster_transform_arm(self)
     *   -- The player is transforming into a monster, begin with changing the arm.
     *   spine.set_skin("#spinemodel", "monster", "left_arm_slot")
     * end
     * ```
     */
sets the spine skin
Sets the spine skin on a spine model.



The following examples assumes that the spine model has id "spinemodel".

Change skin of a Spine model



Change only part of the Spine model to a different skin.

```lua
function monster_transform_arm(self)
The player is transforming into a monster, begin with changing the arm.
sets the spine skin Sets the spine skin on a spine model . The following examples assumes that the spine model has id " spinemodel " . Change skin of a Spine model Change only part of the Spine model to a different skin . ` ` ` lua function monster_transform_arm ( self ) The player is transforming into a monster begin with changing the arm .
int SpineComp_SetSkin(lua_State* L)
    {
        int top = lua_gettop(L);
        dmGameObject::HInstance sender_instance = CheckGoInstance(L);
        dmGameObject::HCollection collection = dmGameObject::GetCollection(sender_instance);
        uintptr_t user_data;
        dmMessage::URL receiver;
        SpineModelWorld* world = 0;
        dmGameObject::GetComponentUserDataFromLua(L, 1, collection, SPINE_MODEL_EXT, &user_data, &receiver, (void**) &world);
        SpineModelComponent* component = world->m_Components.Get(user_data);
        dmhash_t skin_id = dmScript::CheckHashOrString(L, 2);
        if (top > 2) {
            dmhash_t slot_id = dmScript::CheckHashOrString(L, 3);
            if (!CompSpineModelSetSkinSlot(component, skin_id, slot_id))
            {
                return luaL_error(L, "failed to set spine skin ('%s') slot '%s' for spine component", dmHashReverseSafe64(skin_id), dmHashReverseSafe64(slot_id));
            }
        } else {
            if (!CompSpineModelSetSkin(component, skin_id))
            {
                return luaL_error(L, "failed to set spine skin '%s' for spine component", dmHashReverseSafe64(skin_id));
            }
        }
        assert(top == lua_gettop(L));
        return 0;
    }
int SpineComp_SetSkin ( lua_State * L ) { int top = lua_gettop ( L ) ; dmGameObject :: HInstance sender_instance = CheckGoInstance ( L ) ; dmGameObject :: HCollection collection = dmGameObject :: GetCollection ( sender_instance ) ; uintptr_t user_data ; dmMessage :: URL receiver ; SpineModelWorld * world = 0 ; dmGameObject :: GetComponentUserDataFromLua ( L , 1 , collection , SPINE_MODEL_EXT , & user_data , & receiver , ( void * * ) & world ) ; SpineModelComponent * component = world -> m_Components . Get ( user_data ) ; dmhash_t skin_id = dmScript :: CheckHashOrString ( L , 2 ) ; if ( top > 2 ) { dmhash_t slot_id = dmScript :: CheckHashOrString ( L , 3 ) ; if ( ! CompSpineModelSetSkinSlot ( component , skin_id , slot_id ) ) { return luaL_error ( L , " " , dmHashReverseSafe64 ( skin_id ) , dmHashReverseSafe64 ( slot_id ) ) ; } } else { if ( ! CompSpineModelSetSkin ( component , skin_id ) ) { return luaL_error ( L , " " , dmHashReverseSafe64 ( skin_id ) ) ; } } assert ( top == lua_gettop ( L ) ) ; return 0 ; }
sets the spine skin
 Sets the spine skin on a spine model.
sets the spine skin Sets the spine skin on a spine model .