Objeto Chat

.html ›› .html ›› .html ››
Parent Previous Next

Objeto Chat

Este objeto representa uma interface de batepapo no RRPG Firecast.


Herança

O Objeto Chat possui todas as características de um WrappedObject. Veja:


Características

Além das características herdadas, o Objeto Chat também possui as seguintes características:


Propriedades e atributos

Propriedade

Tipo

Descrição

impersonation

Impersonation table

Represents the current UI impersonation selected by the user in the chat.


Remarks:

  • Not all chat types allow impersonations.
  • Attempts to change the UI impersonation while the current user does not have permission to impersonate will be ignored. You can use the setImpersonation method if you need to identify if the change was accepted.


medium

Medium table

(Read-only) Contains the identification of the chat medium to which this object is related.


room

Objeto Mesa

(Somente leitura) Contém a mesa a qual este chat pertence.


Importante: Pode ser nil se o chat não pertencer a uma mesa. 


participants

Array of Entity table

(Read-only) Contains the identification of all participants in this chat


talemarkOptions

TalemarkOptions table

Contains the Talemark options used when the user sends messages to this chat.


Remarks:

  • Assigning nil to this property will reset the Talemark options to the user settings.



Métodos


Método

Descrição

chat:asyncInvite(logins)


Asynchronously invites users to this chat.


Arguments:

  • logins - An array of strings containing the usernames to be invited to the group private chat.


Return:


Remarks:

  • This method works with group private chats only. It is possible to check what kind of chat this is by accessing the value of "medium" property.


chat:asyncQueryLogRecs([params])

Asynchronously queries the log for messages stored on the server


Arguments:

    • (Optional) params - A QueryLogRecsParams table describing how to fetch the LogRecs. If missing, the latest messages from the chat will be fetched.


Return:


Remarks:

    • This function retrieves messages from the server's log. To read local messages, use the method chat:readLogRecs() instead.


chat:asyncRoll(expression[, message[, params]])

Asynchronously executes a dice roll in the chat.


Arguments:

    • expression - A string containing the expression of the roll, such as "1d20 + 5," or a Roll Object.
    • (Optional) message - A string containing an additional message describing the roll.
    • (Optional) params - A SendMessageParameters table containing parameters of the message.


Return:

    • A promise for three pieces of information in the following order:
      • A number containing the roll result
      • A Roll Object describing the roll result.
      • A LogRec table describing the sent message.


Remarks:


Short example:

 local promise = chat:asyncRoll("1d20 + 5");                     

 local n, rollObject, logRec = await(promise);       

 -- the variables n, rollObject, and logRec contain the return values of the promise.


chat:asyncSendAction(content[, params])

Asynchronously sends an action message to the chat.


Arguments:

    • content - A string containing the action message to be sent.
    • (Optional) params - A SendMessageParameters table containing parameters of the message.

Return:


chat:asyncSendLaugh([params])

Asynchronously sends a laugh message to the chat.


Arguments:

Return:


chat:asyncSendStd(content[, params])

Asynchronously sends a standard message to the chat.


Arguments:

    • content - A string containing the standard message to be sent.
    • (Optional) params - A SendMessageParameters table containing parameters of the message.

Return:


chat:enviarMensagem(msg)


Envia uma mensagem comum para o chat, como se o usuário a tivesse digitado.


Parâmetros:

    • msg - a mensagem que deseja enviar no chat.


Observações:


chat:enviarAcao(acao)


Enviar uma mensagem como uma ação para o chat.


Parâmetros:

    • acao - a mensagem que deseja enviar no chat com formatação de ação.


Observações:


chat:enviarRisada()


Enviar uma típica risada do RRPG para o chat.


Observações:


chat:enviarMensagemNPC(npc, msg)

Envia uma mensagem para o chat como se um NPC estivesse falando.


Parâmetros:

    • npc - cadeia de caracteres contendo o nome do NPC
    • msg - a mensagem que deseja enviar no chat.


Observação: 

    • Apenas o mestre da mesa consegue enviar mensagens como NPC.
    • Prefira usar a função chat:asyncSendStd() ao invés desta.


chat:enviarNarracao(narracao)

Enviar uma mensagem como narrador para o chat.


Parâmetros:

    • narracao - a mensagem que deseja enviar no chat com formatação de narração.


Observação: 

    • Apenas o mestre da mesa consegue enviar narrações.
    • Prefira usar a função chat:asyncSendStd() ao invés desta.


chat:readLogRecs()

Reads the messages of the chat.


Arguments:

None


Return:


Remarks:

    • Only messages already available on the Firecast client are returned. This function does not query the server. To query the server, use the method chat:asyncQueryLogRecs() instead.
    • The returned array is already sorted in the same way the user sees the messages on the interface.
    • Messages that are in the process of being sent or have failed to send are not returned by this function.
    • This function also reads the generic system log messages written to the chat.


chat:rolarDados(rolagem [, msg, calllback])

Envia uma rolagem de dados para o chat.


Parâmetros:

    • rolagem - um Objeto Rolagem ou uma cadeia de caracteres contendo a rolagem de dados.
    • (OPCIONAL) msg - Uma mensagem para acompanhar a rolagem de dados.
    • (OPCIONAL) callback - Uma função que será invocada após a rolagem ser executada no chat. A função recebe no primeiro parâmetro um NOVO Objeto Rolagem contendo o resultado da rolagem.


Observações:

    • Esta função tem comportamento assíncrono. Isto é, a função retorna imediatamente e o resto do código continua sendo executado enquanto a rolagem é feita em segundo plano. Depois de algum tempo, quando o RRPG já souber o resultado, é que a função "callback" será invocada.
    • A função callback pode não ser invocada se a rolagem não for autorizada/realizada pelo RRPG. Exemplo de situações: A mesa está moderada e o usuário não possui o modo +voz para rolar dados, a conexão com o servidor caiu antes da rolagem ser realizada, etc..
    • Prefira usar a função chat:asyncRoll() ao invés desta.


Veja também o exemplo 2.


chat:setImpersonation(impersonation)

Attempts to change the UI impersonation selected by the user in the chat.


Arguments:


Return:

    • A Boolean; Indicates if the change was accepted, and the impersonation was incorporated into the UI.


chat:write(text [, breakLine, allowSmileys])

or

chat:escrever(texto [, quebrarLinha, permitirSmileys])


Escreve/Imprime um texto no chat. O texto não é enviado para ninguém e só é exibido para o usuário que está usando o Firecast.


Parâmetros:

    • text - cadeia de caracteres contendo o texto que deve ser impresso no chat.
    • (OPCIONAL) breakLine - Este parâmetro é ignorado no Firecast 8+
    • (OPCIONAL) allowSmileys - Booleano indicando se o RRPG deve interpretar smileys neste texto. Se omitido, o valor padrão true é assumido.


Observações:


chat:writeEx(text[, talemarkOptions])

Write/print a text in the chat. The text is not sent; only the local user can see the text.


Arguments:

    • text - A string containing the text to be printed.
    • (Optional) talemarkOptions - A TalemarkOptions table containing how Firecast should color and format the text. If missing, Firecast will use a default TalemarkOptions.


Return:

    • A Boolean indicating if the operation was concluded successfully.




Exemplos

Exemplo 1 - Uma ficha enviando um Hello World para a sua mesa.

<?xml version="1.0" encoding="UTF-8"?>
<form name="frmFichaTeste">         

        <button>
                <event name="onClick"> 
                        local minhaMesa = Firecast.getRoomOf(sheet);
                        local chat = minhaMesa.chat;                       

                        chat:enviarMensagem("Olá mundo!!!!");
                </event>
        </button>
</form>



Exemplo 2 - Uma ficha fazendo um teste (de resistência, por exemplo) e postando o resultado na mesa.

<?xml version="1.0" encoding="UTF-8"?>
<form name="frmTeste">
        <script>
                local function realizarTesteDeResistencia()            
                        -- obter a mesa do personagem
                        local mesaDoPersonagem = Firecast.getRoomOf(sheet);                       

                        -- se o usuário não preencheu modificador, vamos usar o valor 0
                        sheet.modificador = sheet.modificador or 0;                        

                        mesaDoPersonagem.chat:rolarDados("1d20 + " .. sheet.modificador, "Teste de Resistência",
                                function (rolado)
                                        -- A dificuldade do teste é 15                               

                                        if rolado.resultado >= 15 then
                                                mesaDoPersonagem.chat:enviarMensagem("SUCESSO =) você tirou " .. rolado.resultado);
                                        else
                                                mesaDoPersonagem.chat:enviarMensagem("FALHA =/ você tirou " .. rolado.resultado);
                                        end;                                         

                                end);          
                end;               
        </script> 

        <button onClick="realizarTesteDeResistencia()"/>
</form>



Example 3 - Using asyncRoll


<?xml version="1.0" encoding="UTF-8"?>

<form name="frmTest">

    <script>

        local function mindCheck()

            -- Get the room

            local room = Firecast.getRoomOf(sheet); 

            

            -- Start the roll

            local promise = room.chat:asyncRoll("1d20 + " .. tostring(sheet.mind or 0));

            

            -- Await for the roll to conclude

            local resultNumber = await(promise);

            

            -- Compare the result

            if resultNumber >= 15 then

                room.chat:write("Success!");

            else

                room.chat:write("Failure!");

            end;

        end;

    </script>  

    

    <button onClick="mindCheck()"/>

</form>

 

Created with the Personal Edition of HelpNDoc: Streamline your documentation process with HelpNDoc's WinHelp HLP to CHM conversion feature