Json block behaviors OmniAttachable: Difference between revisions

From Vintage Story Wiki
Update
(→‎Purpose: Update example)
(Update)
Line 1: Line 1:
== Purpose ==
== Purpose ==
Can be attached on any block side. Used for:
This [[Modding:Json_Block_Behaviors|behavior]] turns the block into an [[Modding:Block_Attachment|attachment block]] that can be attached on any face. Additionally this behavior [[Modding:Block Orientation|orients]] the attachment block to face the parent block.
* Lantern
 
Example use:
== Used by blocks ==
* crystal
* lantern
 
== Usage ==
 
When the block is placed, the behavior will verify that the selected face on the parent block accepts the attachment. If the selected parent face rejects the attachment, then attachment block finds the first neighbor block that accepts the attachment. If all of the neighbors reject the attachment, then placing the attachment block is rejected.
 
If the parent block changes such that it no longer accepts the attachment, then the attachment block is broken.
 
If the block passes the attachment checks, then it is oriented to the parent. In order to do so, one of the variant groups must contain all facing codes. By default that variant group uses the <code>orientation</code> code, but a different code selected with the <code>facingCode</code> property.
 
All of the states of the orientation group can be directly specified, or the "up" and "down" states can be added to the ones from the <code>abstract/horizontalorientation</code> [[Json:block:worldvariantgroups|world property]]:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
variantgroups: [
variantgroups: [
{ code:"position", states: ["up", "down"], loadFromProperties: "abstract/horizontalorientation" }
{ code:"orientation", states: ["up", "down"], loadFromProperties: "abstract/horizontalorientation" }
],
],
</syntaxhighlight>
</syntaxhighlight>
When the block is broken, the "up" variant is dropped.


== Properties ==
== Properties ==
<code>facingPos (int, default: 1)</code> The facing position for the dropped block and the pick block. 1 is "up".
; <code>facingCode</code>&colon; (variant code, default &colon; "orientation")
 
: The code of the variant group of the block that contains all of the facing codes.
; <code>attachmentAreas</code>&colon; (facing code -> RotatableCube)
: The attachment area (part of the parent block that should be solid) for each face that the block can attach to. This field is optional. If a face is missing, then a null attachment area will be given to the parent block. Most parent blocks ignore the attachment area when deciding whether to accept an attachment.


{{Navbox/modding|Vintage Story}}
{{Navbox/modding|Vintage Story}}
Confirmedusers
261

edits