Finish verdigris for now
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// the blocks that make and use signals, see "Blocks" in REDSTONE.md. what they give out is their bworld:verdigris_source
|
||||
// params, this is what makes their states change
|
||||
// the blocks that make and use signals. what they give out is their bworld:verdigris_source params, this is what makes
|
||||
// their states change
|
||||
import type { BlockRef, Face, Position, ServerContext } from "bworld/server";
|
||||
import { power_from } from "./inputs.ts";
|
||||
import type { SignalReader } from "./signals.ts";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// the power blocks take in, see "How Power Works" in REDSTONE.md: a source's output, a solid block's power, and the
|
||||
// the power blocks take in, see docs/modding/blocks/verdigris.md: a source's output, a solid block's power, and the
|
||||
// power of wire that lies on them or joins them
|
||||
import type { Face } from "bworld/shared";
|
||||
import { block_power, type InputParams, MAX_POWER, output, sides_of, type SignalReader, WIRE } from "./signals.ts";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// which faces of its cell a wire covers and what it joins, see "Joining" in REDSTONE.md. a wire cell covers some of its
|
||||
// six faces, each lying on the block on that side, and the wire on two faces that meet joins at that edge. a face's
|
||||
// other directions lead out of the cell, and its arm_ states say which of those it joins. the shared rule sets them the
|
||||
// same on the server and clients, and works out a join between two cells the same from either end
|
||||
// which faces of its cell a wire covers and what it joins. a wire cell covers some of its six faces, each lying on the
|
||||
// block on that side, and the wire on two faces that meet joins at that edge. a face's other directions lead out of the
|
||||
// cell, and its arm_ states say which of those it joins. the shared rule sets them the same on the server and clients,
|
||||
// and works out a join between two cells the same from either end
|
||||
import type { Face } from "bworld/shared";
|
||||
import { AIR, type BlockReader, connects, WIRE } from "./signals.ts";
|
||||
import { DIRECTIONS, FACES, OPPOSITE, step } from "./sides.ts";
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// verdigris's components, see REDSTONE.md: the wire, which keeps its net's power through the net index, sources,
|
||||
// inputs, and the devices
|
||||
// verdigris's components: the wire, which keeps its net's power through the net index, sources, inputs, and the devices
|
||||
import type { BlockRef, Face, Position, ServerContext } from "bworld/server";
|
||||
import { register_lever, register_pulse_repeater, register_torch } from "./devices.ts";
|
||||
import { arms_of, around_edge, can_cover, covers, face_states, faces_of, MAX_ARMS } from "./joins.ts";
|
||||
@@ -87,8 +86,8 @@ function set_input(ctx: ServerContext, world: SignalReader, block: BlockRef, par
|
||||
ctx.world.set_state(block.x, block.y, block.z, params.state, powered);
|
||||
}
|
||||
|
||||
// the wires on the next faces of the blocks a wire lies on, which it joins or could join around their edges. they aren't
|
||||
// among the six blocks beside it the engine tells
|
||||
// the wires on the next faces of the blocks a wire lies on, which it joins or could join around their edges. they
|
||||
// aren't among the six blocks beside it the engine tells
|
||||
function tell_around_edges(world: SignalWorld, block: BlockRef) {
|
||||
const faces = faces_of(world, block.x, block.y, block.z);
|
||||
for (const face of faces) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// verdigris placement and joins, see REDSTONE.md. rules, so a player sees a wire join or a lever turn to the wall the
|
||||
// moment they place it. power, delays and clicks are the server's, see server.ts
|
||||
// verdigris placement and joins. rules, so a player sees a wire join or a lever turn to the wall the moment they place
|
||||
// it. power, delays and clicks are the server's, see server.ts
|
||||
import type { BlockPlacement, Face, SharedContext } from "bworld/shared";
|
||||
import { arms_of, can_cover, face_states, faces_of } from "./joins.ts";
|
||||
import { type BlockReader, type InputParams, params_lookup, type SourceParams } from "./signals.ts";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// faces, and the directions along them a wire lying on one runs, see REDSTONE.md
|
||||
// faces, and the directions along them a wire lying on one runs
|
||||
import type { Face } from "bworld/shared";
|
||||
|
||||
// the six faces in the order of a 3 bit facing state's values: a 2 bit facing's four, then top and bottom
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// the power blocks give each other, see "How Power Works" in REDSTONE.md. every signal is a block state, so this only
|
||||
// the power blocks give each other, see docs/modding/blocks/verdigris.md. every signal is a block state, so this only
|
||||
// reads states, through a small world instead of ctx so it runs the same in shared scripts, server scripts and tests
|
||||
import type { Face, Id } from "bworld/shared";
|
||||
import { FACES, type FacingParam, front_of, named_sides, OPPOSITE, type SideName, step } from "./sides.ts";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// wire nets, see "Power" in REDSTONE.md: a wire cell and every wire cell it reaches through its joins are one net, and
|
||||
// they all have the same power, the most any block gives into any of them. a cell's faces always join each other, so
|
||||
// it's one piece of one net. NetIndex keeps the nets between changes, see "The Net Index"
|
||||
// wire nets: a wire cell and every wire cell it reaches through its joins are one net, and they all have the same
|
||||
// power, the most any block gives into any of them. a cell's faces always join each other, so it's one piece of one
|
||||
// net. NetIndex keeps the nets between changes
|
||||
import type { Face } from "bworld/shared";
|
||||
import { cell_through, faces_of, joins_out, ways_out } from "./joins.ts";
|
||||
import { type BlockReader, MAX_POWER, output, type SignalReader, solid_power } from "./signals.ts";
|
||||
@@ -77,9 +77,9 @@ function most(inputs: Map<number, number>) {
|
||||
}
|
||||
|
||||
// the nets of the wire cells anything has touched, kept between changes so most changes cost a few reads instead of a
|
||||
// walk, see "The Net Index" in REDSTONE.md. it's only in memory, and a cell it doesn't have is walked the first time
|
||||
// anything touches it, so it can't hold anything the world doesn't. the wire's server hooks call created, breaking,
|
||||
// reshaped and beside_changed
|
||||
// the nets of the wire cells anything has touched, kept between changes so most changes cost a few reads instead of a
|
||||
// walk. it's only in memory, and a cell it doesn't have is walked the first time anything touches it, so it can't hold
|
||||
// anything the world doesn't. the wire's server hooks call created, breaking, reshaped and beside_changed
|
||||
export class NetIndex {
|
||||
readonly #world: SignalWorld;
|
||||
// each cell's net, by packed position
|
||||
|
||||
Reference in New Issue
Block a user