<!-- RUBY-BACKUP · part 492 -->
ode'){ togglePlaceMode(); return; }
  if(tl.indexOf('placeat ')===0){ var pp = tl.slice(8).trim().split(/\s+/); if(pp.length>=2){ var pxx=parseInt(pp[0],10), pzz=parseInt(pp[1],10); if(!isNaN(pxx)&&!isNaN(pzz)) setPlaceTarget(pxx,pzz); } return; }
  if(tl==='placeclear'){ PLACE_TARGET=null; if(placeMarker&&placeMarker.parent)placeMarker.parent.remove(placeMarker); codeStatus('placement cleared'); return; }
  if(tl==='replacemode'){ toggleReplaceMode(); return; }
  if(tl==='capsuleitems'){ loadCapsuleItems(); codeStatus(CAPSULE_ITEMS.length ? 'capsule holds '+CAPSULE_ITEMS.length+' items — use "restore" to bring them back' : 'capsule empty'); return; }
  if(tl==='restore'){
    loadCapsuleItems();
    if(CAPSULE_ITEMS.length===0){ codeStatus('nothing to restore'); return; }
    var pos = getPlacePos();
    var n = 0;
    CAPSULE_ITEMS.forEach(function(item){
      if(typeof placeStone==='function'){
        placeStone(pos.x + (n%5), pos.z + Math.floor(n/5), item.s, item.shape||'b', true, true, item.y||0, true);
        n++;
      }
    });
    codeStatus('restored '+n+' items from the capsule');
    CAPSULE_ITEMS = []; saveCapsuleItems();
    return;
  }
  if(tl==='clearplace'){ clearPlaceTarget(); return; }
  if(tl.indexOf('cleararea ')===0){ var cr=parseInt(tl.slice(10).trim(),10)||3; var pos=getPlacePos(); var n=clearAreaAt(pos.x,pos.z,cr); codeStatus('cleared '+n+' stones in radius '+cr); return; }
  if(tl==='desk' && isInsideDome()){ showDesk(); return; }
  if(tl.indexOf('conncolor ')===0){ var cc = tl.slice(10).trim(); if(cc) setConnColor(cc); else codeStatus('usage: conncolor <hex or name>'); return; }
  if(tl.indexOf('conntex ')===0){ var ct = tl.slice(8).trim(); if(ct) setConnTex(ct); else codeStatus('usage: conntex <texture name>'); return; }
  if(tl==='recolor'){ recolorConnections(); return; }
  if(tl==='walkon'){ if(!WALK) setWalk(true); return; }
  if(tl==='rain'){ RAIN_ON = !RAIN_ON; if(RAIN_ON) CLOUDS_ON = true; skySet(); codeStatus(RAIN_ON ? 'the Rain Law — totality, and the rain falls' : 'the sky clears'); return; }
  if(tl==='clouds'){ if(RAIN_ON){ codeStatus('the Law holds \u2014 rain keeps its clouds'); return; } CLOUDS_ON = !CLOUDS_ON; skySet(); codeStatus(CLOUDS_ON ? 'clouds gather' : 'the sky clears'); return; }
  if(tl==='whiteout'){ WHITEOUT_HELD = !WHITEOUT_HELD; codeStatus(WHITEOUT_HELD ? 'the white holds — two codes at once, on purpose' : 'the sky breathes again'); return; }
  if(tl==='floor'){ layFloor(); return; }
  if(tl==='whereami'){
    try{
      var wx = 0, wy = 0, wz = 0;
      if(typeof mePos!=='undefined'){ wx = mePos.x.toFixed(1); wy = mePos.y.toFixed(1); wz = mePos.z.toFixed(1); }
      codeStatus('Solid at (' + wx + ', ' + wy + ', ' + wz + ')');
    }catch(e){}
    return;
  }
  if(tl==='listall'){
    try{
      var counts = {};
      if(typeof scene!=='undefined'){
        scene.traverse(function(o){
          var n = (o.name||'unnamed').split('-')[0];
          counts[n] = (counts[n]||0)+1;
        });
      }
      var out = Object.keys(counts).map(function(k){ return k+':'+counts[k]; }).join(' ');
      codeStatus('World: ' + out);
    }catch(e){}
    return;
  }
  if(tl.indexOf('tp ')===0){
    try{
      var parts = tl.split(' ');
      if(parts.length >= 3){
        var tx = parseFloat(parts[1]), tz = parseFloat(parts[2]);
        if(typeof mePos!=='undefined'){
          mePos.x = tx; mePos.z = tz;
          if(typeof fortifiedGroundY==='function') mePos.y = fortifiedGroundY(tx, tz) + 5;
          codeStatus('Teleported to (' + tx + ', ' + tz + ')');
        }
      }
    }catch(e){}
    return;
  }
  if(tl.indexOf('bam ')===0 || tl.indexOf('mk ')===0){
    /* BAM — direct build, King's name — creates at player position, saves to server */
    /* supports: bam box 10 | bam box 10 x5 (batch) | bam wall 10 line 5 (row) */
    try{
      var parts = tl.split(' ');
      var shape = parts[1] || 'box';
      var size = parseFloat(parts[2]) || 5;
      var count = 1, lineMode = false;
      for(var pi=3; pi<parts.length; pi++){
        if(parts[pi]==='line') lineMode = true;
        else if(parts[pi][0]==='x') count = parseInt(parts[pi].slice(1))||1;
      }
      count = Math.min(count, 20); /* cap at 20 */
      /* remember for 'again' */
      window._lastBam = tl;
      var px = 0, py = 0, pz = 0;
      if(typeof mePos!=='undefined'){ px = mePos.x; pz = mePos.z; }
      if(typeof fortifiedGroundY==='function') py = fortifiedGroundY(px, pz) + size/2;
      var mat = new THREE.MeshStandardMaterial({color:0xffd700, metalness:0.5, roughness:0.4});
      var mesh = null;
      if(shape==='box') mesh = new THREE.Mesh(new THREE.BoxGeometry(size, size, size), mat);
      else if(shape==='sphere') mesh = new THREE.Mesh(new THREE.SphereGeometry(size/2, 16, 12), mat);
      else if(shape==='tower') mesh = new THREE.Mesh(new THREE.BoxGeometry(size/2, size*3, size/2), mat);
      else if(shape==='wall') mesh = new THREE.Mesh(new THREE.Box