운용해야하는 캐릭터가 많을 때 유용합니다.

왼쪽 보드에 캐릭터 토큰을 두고 선택한 다음 매크로를 클릭하면 as(말하기)가 해당 캐릭터로 변경.

on('ready',()=>{
   on('chat:message',(msg)=>{
        if('api' === msg.type && /^!switch/i.test(msg.content)){
            let p = getObj('player',msg.playerid);
            if(p){
                let a = msg.content.split(/\s+/);
                if(a.length>1) {
                    let c = findObjs({
                        type: 'character',
                        id: a[1]
                    })[0];
                    if(c){
                        p.set({
                            speakingas:`character|${a[1]}`
                        });
                        sendChat('',`/w "${p.get('displayname')}" <b>${c.get('name')}</b> 변경.`);
                    } else {
                        sendChat('',`/w "${p.get('displayname')}" No character found for ID <b>${a[1]}</b>!`);
                    }
                } else {
                    p.set({
                        speakingas: ''
                    });
                    sendChat('',`/w "${p.get('displayname')}" GM으로 변경.`);
                }
            }
        }
   }); 
});

 

Switch Avatar.txt
0.00MB

해당 API를 추가하고 아래의 매크로를 추가.

 

선택한 캐릭터로 말하는 매크로

!switch @{selected|character_id}

 

GM, 혹은 플레이어로 말하는 매크로

!switch

 

캐릭터 변경 알림 귓말이 없는 버전

on('ready',()=>{
   on('chat:message',(msg)=>{
        if('api' === msg.type && /^!switch/i.test(msg.content)){
            let p = getObj('player',msg.playerid);
            if(p){
                let a = msg.content.split(/\s+/);
                if(a.length>1) {
                    let c = findObjs({
                        type: 'character',
                        id: a[1]
                    })[0];
                    if(c){
                        p.set({
                            speakingas:`character|${a[1]}`
                        });
                    } 
                } else {
                    p.set({
                        speakingas: ''
                    });
                    sendChat();
                }
            }
        }
   }); 
});

 

 

출처: www.app.roll20.net/forum/post/7565888/script-snippet-switch-swap-your-speaking-as-and-avatar-easilyapp.roll20.net/forum/post/7565888/script-snippet-switch-swap-your-speaking-as-and-avatar-easily

'Roll20 세팅 > API(pro 회원 전용)' 카테고리의 다른 글

[API] 탐사자 시트 데이터 입력기  (0) 2022.01.13