Json block behaviors WrenchOrientable

From Vintage Story Wiki

Purpose

The behavior puts the block in a wrench group, which allows the wrench tool to cycle through different variants of the block. Left clicking on the block with wrench replaces the block with the next one in the wrench group. Right clicking replaces the block with the previous one in the wrench group. Note that OmniRotatable behavior is similar, but it allows the variant to selected before the block is placed.

Used by blocks

  • banner
  • brickslabs
  • brickstairs
  • carvedlog
  • chute
  • clayshinglelabs
  • clayshinglestairs
  • clutter
  • cobblestoneslab
  • cobblestonestairs
  • debarkedlog
  • glassslab
  • jonas
  • log
  • mudbrickslab
  • planks
  • plankslab
  • plankstairs
  • plaster
  • polishedrockslab
  • quartzpillar
  • quartzslab
  • quartzstairs
  • stonebrickslab
  • stonebrickstairs
  • stonepathstairs

Usage

The baseCode property is required. All block variants that enable the WrenchOrientable behavior with the same baseCode property are placed in that wrench group. The baseCode is typically chosen as a prefix of the variant name for code style purposes, but any name could be chosen, as long as it does not match any other wrench groups. Typically all of the block variants in a wrench group are rotated versions of the same block, but it is possible to put different types of blocks in the same group, and the wrench would cycle between all of them.

The following example puts all variants of each wood type of placed logs in its own variant group. The baseCode is "log-placed-{wood}". For instance, the "log-placed-oak" wrench group contains "log-placed-oak-ud", "log-placed-oak-ns", and "log-placed-oak-we". Grown logs are not wrench rotatable, because the earlier "*-grown-*" clause overrides the subsequent "*" clause with the WrenchOrientable behavior.

{
    code: "log",
    ...
    behaviorsByType: {
        "*-grown-*": [...],
        "*": [... { name: "WrenchOrientable", properties: { baseCode: "log-placed-{wood}"  } }]
    },
    variantgroups: [
        { code: "type", states: ["grown", "placed"] },
        { code: "wood", states: ["aged"], loadFromProperties: "block/wood" },
        { code: "rotation", states: ["ud", "ns", "we"] },
    ],
    ...
}

Note that aside from using the WrenchOrientable behavior, there is another way to enable the wrench interaction with blocks. If the block class implements IWrenchOrientable, then the wrench will call IWrenchOrientable.Rotate on the block. It would be a mistake to have a block use both the WrenchOrientable behavior and have a block class that implements IWrenchOrientable, but for such blocks WrenchOrientable takes precedence.

Properties

baseCode (string)
The wrench group to put the block in.
hideInteractionHelpInSurvival (bool, default: false)
If false, then the rotate tooltip is shown when looking at the block.
Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Theme Pack
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository