Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Displaying Loading Screen Type Messages

October 04 (4 years ago)

I saw this youtube video https://www.youtube.com/watch?v=MJSVE3gvNQs&t=320s&ab_channel=NickOlivo and wanted something like this for my session but I couldn't get it to work and I got no error message. I hope someone can help me

October 04 (4 years ago)

Edited October 04 (4 years ago)
Nick O.
Forum Champion

Replied on the video. :)

October 04 (4 years ago)

I tried it now and nothing is shown in the chat but now I get an error message "SyntaxError: Unexpected string" I don't know if I typed it correctly so I added a screenshot and hope it helps 




October 04 (4 years ago)


October 04 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

If you could post the text of the code you're using (rather than an image), it would be easier for others to try and debug it with you. =D

October 04 (4 years ago)

on("ready",function(){    

    var isItRunning;

    on("change:campaign:playerpageid",function(){

        var currentPage = getObj("page",Campaign().get("playerpageid"));

        if (currentPage.get("name")=="breakScreen"){

            var textBox;

            var token = findObjs({

                name:"textLocation",log("Here"),

                type:"graphic",

                pageid:Campaign().get("playerpageid")

            });

            if (token[0] === undefined){

                sendChat("API","Could not locate a token named textLocation");

                return;

            }

            var textLocation = token[0];

            if(!state.BreakScreen){

                log("increate")

                textBox = createObj("text",

                {

                    text:"Hello World",

                    font_size:36,

                    font_family:"Contrail One",

                    color:"rgb(255,255,255)",

                    layer:"objects",

                    pageid:Campaign().get("playerpageid"),

                    left:textLocation.get("left"),

                    top:textLocation.get("top")

                });

                state.BreakScreen = {

                    module:"Break Screen",

                    textID:textBox.get("id")

                }

            }

            else{

                textBox = getObj("text",state.BreakScreen.textID);

            }

            var tables = findObjs({

                type:"rollabletable",

                name:"loadingMessages"

            });

            if (tables[0] === undefined){

                sendChat("API","Unable to locate a rollable table called loadingMessages");

                return;

            }

            var loadingMessagesTable = tables[0];

            var messageList = findObjs({

                type:"tableitem",

                rollabletableid:loadingMessagesTable.get("id")

            });

            isItRunning = setInterval(function(){

                var tableItem = messageList[(randomInteger(messageList.length)-1)];

                textBox.set({

                    text:tableItem.get("name"),

                    left:textLocation.get("left"),

                    top:textLocation.get("top")

                }); 

            },3000);

        }

        else{

            clearInterval(isItRunning);

        }

    });

    

    

    on("chat:message",function(msg){

        if(msg.type=="api" && msg.content.indexOf("!clearBreakScreenText")==0){

            textBox = getObj("text",state.BreakScreen.textID);

            if(textBox!==undefined){

             textBox.remove();

            }

            state.BreakScreen = undefined;

        }

    });

});


October 04 (4 years ago)

Edited October 04 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

Inside the var token, there's this line:

name:"textLocation",log("Here"),

Change that to

name:"textLocation",
October 05 (4 years ago)

yes nick told me that i should add this "log" after the name:textlocation i do not know how to do that so i just wrote it after the name:textlocation 


this is the original one


on("ready",function(){    

    var isItRunning;

    on("change:campaign:playerpageid",function(){

        var currentPage = getObj("page",Campaign().get("playerpageid"));

        if (currentPage.get("name")=="breakScreen"){

            var textBox;

            var token = findObjs({

                name:"textLocation",

                type:"graphic",

                pageid:Campaign().get("playerpageid")

            });

            if (token[0] === undefined){

                sendChat("API","Could not locate a token named textLocation");

                return;

            }

            var textLocation = token[0];

            if(!state.BreakScreen){

                log("increate")

                textBox = createObj("text",

                {

                    text:"Hello World",

                    font_size:36,

                    font_family:"Contrail One",

                    color:"rgb(255,255,255)",

                    layer:"objects",

                    pageid:Campaign().get("playerpageid"),

                    left:textLocation.get("left"),

                    top:textLocation.get("top")

                });

                state.BreakScreen = {

                    module:"Break Screen",

                    textID:textBox.get("id")

                }

            }

            else{

                textBox = getObj("text",state.BreakScreen.textID);

            }

            var tables = findObjs({

                type:"rollabletable",

                name:"loadingMessages"

            });

            if (tables[0] === undefined){

                sendChat("API","Unable to locate a rollable table called loadingMessages");

                return;

            }

            var loadingMessagesTable = tables[0];

            var messageList = findObjs({

                type:"tableitem",

                rollabletableid:loadingMessagesTable.get("id")

            });

            isItRunning = setInterval(function(){

                var tableItem = messageList[(randomInteger(messageList.length)-1)];

                textBox.set({

                    text:tableItem.get("name"),

                    left:textLocation.get("left"),

                    top:textLocation.get("top")

                }); 

            },3000);

        }

        else{

            clearInterval(isItRunning);

        }

    });

    

    

    on("chat:message",function(msg){

        if(msg.type=="api" && msg.content.indexOf("!clearBreakScreenText")==0){

            textBox = getObj("text",state.BreakScreen.textID);

            if(textBox!==undefined){

             textBox.remove();

            }

            state.BreakScreen = undefined;

        }

    });

});

October 05 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Verify that the player ribbon is on the same page as the token named "textLocation".


October 05 (4 years ago)

so the player banner is on the break screen and the token "textLocation" is on the break screen but nothing happens (I use code from github again)

October 05 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

With the API running, and while personally on the break page, try moving the player ribbon to another page, then move it back to the break page.

October 05 (4 years ago)

OMG you are the king it works now i feel stupid :(

October 05 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

No worries, it's a very subtle bug.  Basically, the script only activates when the ribbon is moved to the break page.  If the ribbon has always started there, it will never activate the script.  Probably the script needs a bit of startup logic that kicks of the functionality if the api script starts and the ribbon is already on the page.

October 05 (4 years ago)

yes but as it is now is enough for me thanks again to all who have helped :)