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

Strange Issue with Matt's Doors Script + Bump

October 16 (7 years ago)
Tony R.
Sheet Author
It seems that doors that have been linked and tokens that have been "bumped" sometimes forget they are linked after I exit roll20 (they work perfectly fine right after they are set up). I am not able to easily recreate this bug, but linked doors and bumped tokens will eventually stop working within a few hours.

This is only an issue for recently created doors and bumped tokens. Bumped tokens and linked doors I set up a few weeks ago function normally. I started noticing this issue several days ago. This issue causes no errors in the API Output Console, and the scripts still run and work normally for freshly linked doors or bumped tokens, as well as doors I linked several weeks ago. I have tried restarting the API sandbox, but that does not fix anything

Example for issue with Bump, since it is difficult for me to explain with words: GIF.

When I try to use the !OpenDoor command on switches having this issue, the api output console writes "{}", which is the same message I get if I type that command while selecting something that isn't a linked switch for a door.

The only error I get in the dev console in chrome seems to not be related to either script, but rather with an image of a shadow I found in the art library. This only happens when loading one of the pages it question, and does not happen in relation to the Doors/Bump. I will include it here in case it is relevant: 
Access to Image at 'https://s3.amazonaws.com/files.d20.io/images/369927/dwsvAMUHTMuU7CakvsDOLA/thumb.png?135280991355555555' from origin 'https://app.roll20.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://app.roll20.net' is therefore not allowed access.

Scripts:
Doors Script: Aaron's Updated Matt's Door Script.
Bump: Latest version found in Script Library

Other Scripts Used:
5th Edition OGL by Roll20 Companion, latest version found in script library
Aaron's Map Lock, version 0.4.4
Roll20 Audio Master: Latest version found in script library
Torch: Latest version found in script library
Aaron's Imperial Calendar, version 0.1.2
TokenMod: Latest version found in script library
Keven's TokenAction Creator, version 0.2.4

I also use a small initiative script that I found on the forums a some time ago. I can't find the original link, but I think Aaron posted it as an example.
on('ready',function(){
    "use strict";


    on('chat:message',function(msg){
        var args,cmds,who,initial,change,entry;


        if('api' === msg.type && msg.content.match(/^!act\b/) && playerIsGM(msg.playerid) ){


            if(_.has(msg,'inlinerolls')){
                msg.content = _.chain(msg.inlinerolls)
                    .reduce(function(m,v,k){
                        var ti=_.reduce(v.results.rolls,function(m2,v2){
                            if(_.has(v2,'table')){
                                m2.push(_.reduce(v2.results,function(m3,v3){
                                    m3.push(v3.tableItem.name);
                                    return m3;
                                },[]).join(', '));
                            }
                            return m2;
                        },[]).join(', ');
                        m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0;
                        return m;
                    },{})
                    .reduce(function(m,v,k){
                        return m.replace(k,v);
                    },msg.content)
                    .value();
            }


            args = msg.content
                .replace(/<br\/>\n/g, ' ')
                .replace(/(\{\{(.*?)\}\})/g," $2 ")
                .split(/\s+--/);


            cmds=args.shift().split(/\s+/);
            change=parseFloat(cmds[1])||'+1';
            initial=parseFloat(cmds[2])||0;
            entry=args.join(' ');


            if(entry.length){
                let to=JSON.parse(Campaign().get('turnorder'))||[];
                to.unshift({
                    id: "-1",
                    pr: initial,
                    custom: entry,
                    formula: change
                });
                Campaign().set('turnorder',JSON.stringify(to));
            } else {
                who=getObj('player',msg.playerid).get('_displayname');
                sendChat('ACT',`/w "${who}" <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;">Error: no entry name provided.</div></div>`);
            }
        }
    });
});

I am including both of these issues in a single post as both scripts started exhibiting these issues at the same time. Let me know if there is any more information I can provide.

(Btw, thank you for making + updating so many scripts, Aaron! They really improve my games)
October 16 (7 years ago)
The Aaron
Pro
API Scripter

Can you install this little script, save it, and wait for the output "State Test: undefined" then save it again and see if you get "State Test: state is writeable" the second and subsequent times?
on('ready',()=>{
log(`State Test: ${state.test}`);
state.test='state is writeable';
});

A working case should look like this in the API Console Log:
"State Test: undefined"
Restarting sandbox due to script changes...
Previous shutdown complete, starting up...
Spinning up new sandbox...
"State Test: state is writeable"
A failing case will look like this:
"State Test: undefined"
Restarting sandbox due to script changes...
Previous shutdown complete, starting up...
Spinning up new sandbox... 
"State Test: undefined"


I suspect you're suffering from the state write bug.
October 16 (7 years ago)
Tony R.
Sheet Author
I got "State Test: state is writeable" upon saving the above script.
October 16 (7 years ago)
The Aaron
Pro
API Scripter
Oh!  Well, that's good!

This isn't the first time I've seen this issue.  The Bump one has been plaguing my GM for months.  The correlation to more recently bumped tokens is interesting.  If you have that above situation still, I'd like to examine it and see if I can learn anything more, if you can PM me and invite and GM me.  It looks like it's reverting to an older saved state, but it's hard to say, and will be even harder to track down if that's the case.
October 16 (7 years ago)
The Aaron
Pro
API Scripter
Actually, it does look like you're hitting some kind of limit.  I adjusted the above sample to set 'state is writeable--AAAAAAAAAAAAAAAAAAAAAAAAA', which turns out to be too long for it to save as an update.
October 16 (7 years ago)
The Aaron
Pro
API Scripter
I think this is the transient state size bug.  I've pinged it over to the Devs.
October 17 (7 years ago)
Tony R.
Sheet Author
Thank you for looking into this -- hopefully it isn't anything too complicated to fix on the devs' end. Could this be something I might solve by deleting some doors/bumped tokens on unused maps?
October 17 (7 years ago)
The Aaron
Pro
API Scripter
That could certainly alleviate the issue for the time being.  I'd suggest doors, if you can.  They take up a much greater part of your state:
ShapedScripts:           Size: 0.002kb  Percent: 0.0%
roll20-logger:           Size: 0.022kb  Percent: 0.0%
FifthEditionOGLbyRoll20: Size: 0.085kb  Percent: 0.1%
TokenLock:               Size: 0.063kb  Percent: 0.1%
MapLock:                 Size: 4.712kb  Percent: 7.2%
ItsATrap:                Size: 0.085kb  Percent: 0.1%
DoorControls:            Size: 30.644kb Percent: 47.1%
Roll20AM:                Size: 10.830kb Percent: 16.6%
Torch:                   Size: 4.023kb  Percent: 6.2%
Bump:                    Size: 7.250kb  Percent: 11.1%
ImperialCalendar:        Size: 5.066kb  Percent: 7.8%
TokenMod:                Size: 0.139kb  Percent: 0.2%
PAGENAVIGATOR:           Size: 1.858kb  Percent: 2.9%
OneWayDynamicLighting:   Size: 0.002kb  Percent: 0.0%
test:                    Size: 0.046kb  Percent: 0.1%
RecursiveTable:          Size: 0.015kb  Percent: 0.0%
Total:                   Size: 65.080kb Percent: 100.0%

 
October 17 (7 years ago)
Tony R.
Sheet Author
I deleted a whole bunch of doors. That seems to have fixed it for the time being. I will try to remember to do that when I am done with a map from now on.
October 17 (7 years ago)
The Aaron
Pro
API Scripter
I'll see if I can optimize that...
October 17 (7 years ago)

Edited October 17 (7 years ago)
Just to clarify, then this issue with Bump is because of the size of the State?

If that is correct, I just want to point out two things:
  1. Thank you for figuring that out!  The Bump script was my most used script a year ago.  But it has become so unreliable that I had to quit using it.  :(
  2. I was right!  In an old thread I said that you (Aaron) were trying to make enough scripts to fill the State.  See:  https://app.roll20.net/forum/post/4525803/script-imperialcalendar-fully-featured-calendar-for-traveller-stars-without-number-and-other-scifi-games-public-player-and-private-notes-calendar-and-journal-formats/?pageforid=4539701#post-4539701
October 18 (7 years ago)
The Aaron
Pro
API Scripter
I can neither confirm nor deny....
Aaron, how did you get the state memory usage?  I'd also like to know what I could cut out so I could start using Bump again.

Thanks!
October 18 (7 years ago)
The Aaron
Pro
API Scripter
You can throw this script in:
on('ready',()=>{
    let size=JSON.stringify(state).length;
    Object.keys(state).forEach((k)=>{
        let ksize=JSON.stringify(state[k]).length;
        log(`${k}: Size: ${(ksize/1024).toFixed(3)}kb Percent: ${((ksize/size)*100).toFixed(1)}%`);
    });
    log(`Total: Size: ${size}b Percent: 100.0%`);
});
October 18 (7 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
Neat tool, turns out doors is a large part of my state as well... but overall it was smaller than I thought it would be for a nearly 3 yr old game :)
Running the provided script, I'm at "Total: Size: 65522b Percent: 100.0%".  And my recent Bumps also do not work.  So 65k seems to be the state ceiling.  (Which makes sense).

So now I guess I need to look into storing data some other way as I have a weather script that takes up roughly 35k of data in state.
October 18 (7 years ago)
The Aaron
Pro
API Scripter

Three of Swords said:

So 65k seems to be the state ceiling. 
October 19 (7 years ago)
Tony R.
Sheet Author
Thank you for that script to keep track of state memory usage!

I am certain now that all the issues were caused by having too many linked doors. Everything works again after unlinking ~50 or so old, unused doors. I am down to 51k used. Very glad to have bump working normally again -- I think it is my most important script in my library.

I hope roll20 might consider upping the state ceiling some time in the future (but I have no idea if it is a technical limitation or how difficult that would be to increase. I know nothing about javascript)
October 31 (7 years ago)
The Aaron
Pro
API Scripter
Tony, you shouldn't have a problem with copious doors now...
October 31 (7 years ago)
Tony R.
Sheet Author
Is there an updated Doors script I should add, or was the state ceiling changed? Either way, thanks for the help
October 31 (7 years ago)
The Aaron
Pro
API Scripter
State ceiling was increased from 65k to 2048k, will be in the corner announcement end of the week.
Good and bad news for me.

Good news for the future.  Bad news cuz I spent hours rewriting my weather script not to use the State.  :)

October 31 (7 years ago)
Ravenknight
KS Backer

The Aaron said:

State ceiling was increased from 65k to 2048k, will be in the corner announcement end of the week.

That is excellent news!
October 31 (7 years ago)
The Aaron
Pro
API Scripter
Yeah, I may have put some time into rewriting Matt's door script for the same reason...  On the plus side, there are some good benefits to not using the state if you do it right.  I was looking into creating a character to represent Matt's Door script, then using attributes to store configuration data.  The benefit is that then you could move configurations between games by moving that character.  You could even move between games that you didn't create a you could use the Character Vault.  The complicated bit comes in linking up to things in game without using IDs which wouldn't (shouldn't) be the same.  There's ways around that, but yeah.. complicated. =D