# Verdigris Verdigris is the base game's redstone: power from 0 to 15 that wire carries from the blocks that make it to the blocks that use it. A block joins in by listing the base game's [components](components.md) in its JSON: `bworld:verdigris_source` to give power and `bworld:verdigris_input` to take it. Neither needs code. What a block gives or takes is one of its [states](states.md), so it's saved, sent to players and drawn with variants like any other state, and no script calls another mod's. A block that does something when it's powered, like a door opening, reacts to its input's state in its own component's `on_state_change`. ## How Power Works Every block gives some power out of each of its 6 sides, 0 for most. - A **source** gives power out of some of its sides. Some of those are **strong**, and also power a solid block there. - A [solid block](index.md#solid-blocks), like stone, makes no power, but it's powered by the strong sides pointing into it and by wire lying on it, and gives that to the blocks around it. That's how a lever on one side of a wall opens a door on the other. Wire lying on a solid block only takes what strong sides give it, not what other wire does, so a wire can't keep itself on through the block it lies on. - **Wire** carries power. Every wire joined to another is one net with one power, the most anything gives into any of it, however long it is. It joins the sides of blocks that make or take power, and gives its power to the blocks it lies on and the blocks it joins, not to ones it only runs past. - An **input** takes power from each of its sides: what the block there gives out of that side, that block's power if it's solid, or a wire's power when the wire lies on it or joins it. It's powered when any of them gives it more than 0. ## Sides Both components name a block's sides by face: `north`, `east`, `south`, `west`, `top` and `bottom`. A block that points somewhere can say `facing`, and then also name `front`, `back` and `sides`, the four around the way it points. `facing` is a state's name. With 2 bits it's read as `north`, `east`, `south` and `west`, and with 3 bits as those, then `top` and `bottom`. For a block on a floor, wall or ceiling, like a lever, it's `{ "face": "face", "facing": "facing" }`: `face` 0 is the floor, where it points up, 1 a wall, where it points the way `facing` says, and 2 the ceiling, where it points down. Its `back` is the block it's on. ## `bworld:verdigris_source` | Param | Default | Meaning | | ---------- | ---------- | ------------------------------------------------------------------------- | | `power` | | The power it gives, 0 to 15: a number, or the name of a state that has it | | `when` | | A 1 bit state. It only gives power while that's 1 | | `facing` | | Which way it points, see [Sides](#sides) | | `out` | every side | The sides it gives power out of | | `strong` | none | The sides that also power a solid block there | | `connects` | `out` | The sides wire joins | Change the states it reads with `ctx.world.set_state` and the blocks beside it hear of it. The component tells the blocks around the solid blocks its strong sides power, which aren't beside it. The verdigris block gives 15 out of every side, always: ```json "components": { "bworld:verdigris_source": { "power": 15 } } ``` The lever gives 15 while it's `powered`, out of every side, and strongly into the block it's on. Its own component flips `powered` when it's right clicked: ```json "bworld:verdigris_source": { "power": 15, "when": "powered", "facing": { "face": "face", "facing": "facing" }, "strong": ["back"] } ``` The torch gives power out of every side but the block it's on, and strongly into the block above it: ```json "bworld:verdigris_source": { "power": 15, "when": "lit", "facing": "facing", "out": ["front", "sides"], "strong": ["top"] } ``` ## `bworld:verdigris_input` | Param | Default | Meaning | | ---------- | ---------- | ------------------------------------------------------------- | | `state` | | A 1 bit state it keeps whether it's powered in: 1 while it is | | `power` | | A 4 bit state it keeps how much power comes in in, 0 to 15 | | `facing` | | Which way it points, see [Sides](#sides) | | `in` | every side | The sides it takes power from | | `connects` | `in` | The sides wire joins | The component works out its input when the block is placed and whenever a block beside it changes, and sets the state, which does nothing when it's already right. A block that does more the more power it gets, like Create's adjustable chain gearshift, also names a 4 bit `power` state, which gets the most power coming into any of its sides. It's set before `state`, so `on_state_change` sees both up to date when `state` changes. A trapdoor lists it with a `powered` state: ```json "components": { "bworld:trapdoor": {}, "bworld:verdigris_input": { "state": "powered" } } ``` and its server component opens it when `powered` changes, so one opened or closed by hand stays that way until the power does: ```ts ctx.components.register_block("bworld:trapdoor", { on_state_change(block, _params, before) { const powered = ctx.world.get_state(block.x, block.y, block.z, "powered"); if (powered !== before.powered) ctx.world.set_state(block.x, block.y, block.z, "open", powered ? 1 : 0); }, }); ``` ## Both A block can list both, like the pulse repeater, which takes power from behind it and gives it out of its front. Its component sets `powering` with a [scheduled tick](components.md#scheduled-ticks) once its delay is up: ```json "bworld:verdigris_source": { "power": 15, "when": "powering", "facing": "facing", "out": ["front"], "strong": ["front"], "connects": ["front", "back"] }, "bworld:verdigris_input": { "state": "powered", "facing": "facing", "in": ["back"] } ``` Wire joins a side when either component's `connects` names it. A block whose output leads back to its own input, like an inverter wired to itself, flips back and forth until the [neighbor update limit](components.md#changes) stops it, unless it waits a scheduled tick between flips. The torch waits 2 ticks, and burns out for a while when it flips too often.