extensions.ts
games/lantern-trial/extensions.ts
1import {game as trial} from './game';
2import lantern from '../../extensions/team-lantern/extension.json';
3import {defineGame,SDK_API,createWorldDocument,applyWorldTransaction,readExtension,PlaceBuilder,authoredEntityId} from '../../packages/sdk';
4const world=structuredClone(trial.world),court=world.places[0];
5world.id='The Shared Lantern';world.release='shared-lantern.1';delete world.gameplay;delete world.rewards;
6court.name=world.id;court.subtitle='Two travelers. Four alternating touches. One shared light.';
7court.objects=court.objects.filter(o=>!['gather','mend','release','rekindle','amber','tide','finish'].some(id=>o.id.startsWith(id+'.')&&id!=='release'));
8court.lettering=court.lettering!.filter(t=>['title','subtitle'].includes(t.id));court.lettering[0].text='T H E S H A R E D L A N T E R';court.lettering[1].text='Take turns touching the lantern. Four touches awaken it.';
9const lamp=court.objects.find(o=>o.id==='release.light')!;delete lamp.flagMaterial;
10court.interactions=[{id:'gift',kind:'pickup',label:'Keep the shared ember',itemName:'The shared ember',position:[-3,.85,2.5],radius:1.5}];
11const builder=new PlaceBuilder(court);builder.sphere([-3,1,2.5],[.25,.35,.25],{color:[1,.72,.3],emission:1.5},{id:'shared.ember',entityId:await authoredEntityId('shared-lantern.1','ember'),hideWithItem:'gift'});
12// A separate package is installed and bound using the same commands as authoring.
13const extension=readExtension(lantern),document=await createWorldDocument(world);
14const installed=await applyWorldTransaction(document,{format:1,baseRevision:document.revision,baseHash:document.sha256,commands:[
15 {kind:'install-extension',extension,grants:['state','material','unlock']},
16 {kind:'set-object-behavior',entity:lamp.entityId!,value:{id:'behavior.17757ee0-70d6-40cb-bc3a-f677a5db7505',label:'Share a little light',position:[0,0,.8],radius:1.8,module:extension.id,revision:extension.revision,configuration:{parameters:{turns:4},active:{color:[1,.72,.3],emission:4},unlocks:['gift']}}}
17]});
18export const game=defineGame({api:SDK_API,world:installed.world});
19