Attaching entities to model / bone

I got a little stuck in attaching my rings to the heartlings

Some commands work for some situations but maybe someone can give some wise answers to this:
or just tell me if i`m wrong

“render_type”: "merge_with_model"
merges my qb with the hearthling model qb…my entitiy moves around with the hearthling…no problem. i use that for circlets and amulets

but a ring is stiff in the air, because it is sticky to the finger as if the hearthling is standing around with straightened fingers

“render_type”: "attach_to_bone"
i only get errors there. Can i define which bone it should attach to ?
the error defines that it cant do "add child to bone" (referencing towards equipment_piece_component.lua) so i read that but im not understanding what to do with my .json

Please help me with
"merge_with_model"
"attach_to_bone"
get_bone_for_slot
slot_to_bone_map (like mainhand, offhand)

is there a way to define a new slot_to_bone_map ?

If i could use this the right way it would expand possible modding greatly.

Hi @Chabonit :smile:!

Can we get a snapshot of it :slight_smile:?

EDIT: Do you plan the ring to be separated from the accessory slot?

Its like reverse engineering now, but im on it
Yes it should be another slot with amulets thats not a problem

here is a screen with this code
“slot”: “jewel”,
“render_type”: “merge_with_model”,

The ring is there, but:

  1. the finger is gone (ok transparent is set to falsemaybe that caused that)
  2. the ring is not aligned with the right finger bone 22 (hmm…if i look at this picture …i get an oppinion whats wrong…i think it should be right_finger 21… i will try that)
  3. i want to scale it down to be a ring not a metal block
    (tried to add component “render_info”…scale but it`s not working

Ok it`s getting better
i renamed the matrix of my qb to right_finger_21 that looks better
set transparent to true

now the fingers are there and its attached to the right “bone”
leaves the scaling prob

Great :smile:! I was just about to suggest that :sweat_smile:

Well we usually use:

“render_info”: {
“scale”: x
},

But I only got it to work on items with “attach_to_bone”.
I’m not having luck with “merge_with_model” items though.
Sorry :sweat:.

.

Theres a little bit of logic in there because
if you wwant to merge with model the voxel size should be the same and attach to bone attaches a “new” item which can be as large or tiny as it wants

hmm…but if i trie to attach to bone…how can i give stonehearth the bone which it should be attached to…

without you get this
release-707 (x64)[M]
No matching overload found, candidates: custom [class std::weak_ptr] add_child_to_bone(custom [class std::weak_ptr],custom [class std::weak_ptr],std::string const&)
stack traceback:
[C]: in function ‘add_child_to_bone’
…onents/equipment_piece/equipment_piece_component.lua:252: in function ‘_attach_to_bone’
…onents/equipment_piece/equipment_piece_component.lua:199: in function ‘_setup_item_rendering’
…onents/equipment_piece/equipment_piece_component.lua:118: in function ‘equip’
…ehearth/components/equipment/equipment_component.lua:182: in function ‘equip_item’
…/actions/upgrade_equipment/equip_carrying_action.lua:36: in function <…/actions/upgrade_equipment/equip_carrying_action.lua:22>
[C]: ?
[C]: ?
[C]: ?
[C]: ?
[C]: ?
[C]: ?
[C]: in function 'run’
stonehearth/components/ai/ai_component.lua:595: in function <stonehearth/components/ai/ai_component.lua:579>
[C]: in function 'xpcall’
radiant/modules/common.lua:265: in function 'xpcall’
stonehearth/components/ai/ai_component.lua:579: in function '_thread_main’
stonehearth/services/server/threads/thread.lua:273: in function <stonehearth/services/server/threads/thread.lua:270>
[C]: in function 'xpcall’
radiant/modules/common.lua:265: in function 'xpcall’
stonehearth/services/server/threads/thread.lua:270: in function 'f’
radiant/lib/env.lua:15: in function <radiant/lib/env.lua:14>

Maybe someone can enlighten me and explain me this lua
(taken from equipment_piece_component)
function EquipmentPieceComponent:_attach_to_bone()
local entity_container = self._sv.owner:add_component(‘entity_container’)
local bone_name = self:_get_bone_for_slot(self:get_slot())
log:debug(’%s attaching %s to bone %s’, self._sv.owner, self._entity, bone_name)
local mob = self._entity:add_component(‘mob’)
mob:set_transform(_radiant.csg.Transform())
entity_container:add_child_to_bone(self._entity, bone_name)
end