Skip to content

Binding Error for ShowText Fixed #4

@jackien1

Description

@jackien1

I changed the code from

Robot.prototype.showText = function(text, interval, scrIn, complete) { let ind = scrIn?-3:0, tId = setInterval(timeFunc, interval); function timeFunc() { if(ind < 1) { this.write(164); for(let i=0,l=-ind; i<l; i++) this.write(0); this.write(text.substring(0,4-l)); } else { let str = text.substr(ind,4); this.write(164,str); for(let i=0,l=4-str.length; i<l; i++) this.write(0); if(!str.length || (!scrIn && str.length < 4)) { if(str.length) this.write(164,0,0,0,0); clearTimeout(tId); if(typeof complete == "function") complete(); } } ind++; } timeFunc(); return tId; }

to

Robot.prototype.showText = function(text, interval, scrIn, complete) { let ind = scrIn?-3:0, tId = setInterval(timeFunc.bind(this), interval); function timeFunc() { if(ind < 1) { console.log(this == undefined) this.write(164); for(var i= 0,l =- ind; i<l; i++) this.write(0); this.write(text.substring(0,4-l)); } else { let str = text.substr(ind,4); this.write(164,str); for(var i=0,l=4-str.length; i<l; i++) this.write(0); if(!str.length || (!scrIn && str.length < 4)) { if(str.length) this.write(164,0,0,0,0); clearTimeout(tId); if(typeof complete == "function") complete(); } } ind++; } return tId; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions