Some more kinetic blocks

This commit is contained in:
2026-10-28 22:10:48 -03:00
parent fa0748a9c5
commit b8cccb86ff
35 changed files with 670 additions and 73 deletions
+6 -4
View File
@@ -69,8 +69,9 @@ export function register_verdigris(ctx: ServerContext) {
},
});
// keeps whether the block is powered in its state, for the block's own component to react to in on_state_change.
// setting it to what it is does nothing, so most changes around it cost a few reads
// keeps whether the block is powered in its state, and how much power comes in in another if it says, for the
// block's own component to react to in on_state_change. setting it to what it is does nothing, so most changes
// around it cost a few reads
ctx.components.register_block<InputParams>("bworld:verdigris_input", {
on_create: (block, params) => set_input(ctx, world, block, params),
on_neighbor_change: (block, params) => set_input(ctx, world, block, params),
@@ -82,8 +83,9 @@ export function register_verdigris(ctx: ServerContext) {
}
function set_input(ctx: ServerContext, world: SignalReader, block: BlockRef, params: InputParams) {
const powered = input_power(world, block.x, block.y, block.z, params) > 0 ? 1 : 0;
ctx.world.set_state(block.x, block.y, block.z, params.state, powered);
const power = input_power(world, block.x, block.y, block.z, params);
if (params.power) ctx.world.set_state(block.x, block.y, block.z, params.power, power);
ctx.world.set_state(block.x, block.y, block.z, params.state, power > 0 ? 1 : 0);
}
// the wires on the next faces of the blocks a wire lies on, which it joins or could join around their edges. they
+2
View File
@@ -29,6 +29,8 @@ export interface SourceParams {
export interface InputParams {
// a 1 bit state, 1 while it's powered
state: string;
// a 4 bit state it keeps how much power comes in in, 0 to 15, for a block that does more the more it gets
power?: string;
facing?: FacingParam;
// the sides it takes power from, every side when not set
in?: SideName[];