Closed nob345 closed 3 months ago
you need to handle onDamage method so when if a player punches dgate it will change the value of the toggleable. example:
// boolean
block.toggleable.open = !block.toggleable.open;
Place.tileUpdate(this.base, this.peer, itemMeta?.type || 0, block, this.world);
to be able player & other player see if the dgate are open/closed, you need to set the flags of the block to these flags Flags
case ActionTypes.SWITCHEROO: {
let flag = 0x0;
buf = Buffer.alloc(8);
if (block.toggleable?.open) flag |= Flags.FLAGS_OPEN; // if the block was closed then dont give FLAGS_LOCKED since its for door only.
if (block.toggleable?.openToPublic) flags |= Flags.FLAGS_PUBLIC;
buf.writeUInt32LE(block.fg | (block.bg << 16));
buf.writeUint16LE(lockPos, 4);
buf.writeUint16LE(flag, 6);
break;
}
also for FLAGS_PUBLIC
I'll assuming that player no access might be able to punch it, maybe TIAS.
I don't fully understand how to do this and I feel like an idiot. Can you please help me if you are not busy? I added your code under the SEED action in the onPunch event and it didn't work. Normally I am more resourceful .d
Problems
Place.ts
`case ActionTypes.SWITCHEROO: { //dgate p.block.switch = { locked: true};
}`
`case ActionTypes.GATEWAY: { p.block.gateway = { locked: true};
}`
Player.ts
case ActionTypes.SWITCHEROO: { if (this.world.data.owner) { if (this.world.data.owner.id !== this.peer.data?.id_user) return; } const dialog = new DialogBuilder() .defaultColor() .addQuickExit() .addLabelWithIcon(
`wEdit ${itemMeta.name}```, itemMeta.id as number, "big") .addCheckbox("lock", "Is open to public", "NOT_SELECTED") .embed("tilex", block.x) .embed("tiley", block.y) .embed("itemID", itemMeta.id) .endDialog("switch_end", "Cancel", "OK") .str(); this.peer.send(Variant.from("OnDialogRequest", dialog)); break; } case ActionTypes.GATEWAY: { if (this.world.data.owner) { if (this.world.data.owner.id !== this.peer.data?.id_user) return; }}`
GatewayEnd.ts
const world = peer.hasWorld(peer.data.world); const pos = parseInt(action.tilex) + parseInt(action.tiley) * (world?.data.width as number); const block = world?.data.blocks[pos] as Block; const itemMeta = this.base.items.metadata.items.find((i) => i.id === parseInt(action.itemID));
if (world?.data.owner) { if (world?.data.owner.id !== peer.data?.id_user) return; }
const lockname = action.lock === "1" ? true : false;
block.gateway.locked = lockname;
Place.tileUpdate(this.base, peer, itemMeta?.type || 0, block, world as World);
Information