Examples > text-adventures COMPANION ZMACHINE.JS (10/28) objAddr(o) { if (o < 1) throw new ZError(`bad object number ${o}`); return this.version <= 3 ? this.objects + 62 + (o - 1) * 9 : this.objects + 126 + (o - 1) * 14; } parent(o) { const a = this.objAddr(o); return this.version <= 3 ? this.mem[a + 4] : this.rw(a + 6); } sibling(o) { const a = this.objAddr(o); return this.version <= 3 ? this.mem[a + 5] : this.rw(a + 8); } child(o) { const a = this.objAddr(o); return this.version <= 3 ? this.mem[a + 6] : this.rw(a + 10); } setParent(o, v) { const a = this.objAddr(o); if (this.version <= 3) this.mem[a + 4] = v; else this.ww(a + 6, v); } setSibling(o, v) { const a = this.objAddr(o); if (this.version <= 3) this.mem[a + 5] = v; else this.ww(a + 8, v); } setChild(o, v) { const a = this.objAddr(o); if (this.version <= 3) this.mem[a + 6] = v; else this.ww(a + 10, v); } propTable(o) { return this.rw(this.objAddr(o) + (this.version <= 3 ? 7 : 12)); } objectName(o) { const t = this.propTable(o); return this.mem[t] ? this.decode(t + 1).text : ''; } testAttr(o, n) { return (this.mem[this.objAddr(o) + (n >> 3)] & (0x80 >> (n & 7))) !== 0; } setAttr(o, n, on) { const a = this.objAddr(o) + (n >> 3); if (on) this.mem[a] |= 0x80 >> (n & 7); else this.mem[a] &= ~(0x80 >> (n & 7)); } Next: 32 Companion zmachine.js (11/28)