export async function talk_as(idx, name, theatre_idx, message, emote, delay=4500) { theatre.functions.activateStagedByID(theatre_idx); theatre._sendTypingEvent(); theatre.setUserTyping(game.user.id, theatre.speakingAs); await new Promise(r => setTimeout(r, 800)); theatre._sendTypingEvent(); theatre.setUserTyping(game.user.id, theatre.speakingAs); theatre.setEmoteForInsertById(emote, "theatre-"+idx); await new Promise(r => setTimeout(r, 700)); ChatMessage.create({ user: game.user.id, speaker: ChatMessage.getSpeaker({token: canvas.tokens.objects.getChildByName(name)}), content: message }); await new Promise(r => setTimeout(r, delay)); theatre.setEmoteForInsertById("none", "theatre-"+idx); }