Text Plugin Doubt

Discussion in 'JS Plugin Requests' started by shinichi999, Mar 5, 2017.

Thread Status:
Not open for further replies.
  1. shinichi999

    shinichi999 Veteran Veteran

    Messages:
    134
    Likes Received:
    13
    First Language:
    Spanish
    I've been looking this for many weeks and I can`t find something similar... is there a way on RPG Maker MV of having a manual scrolling text? I mean.. something like a word document.. text that you can scroll manually up and down.. and not only an automatic down scrolling text... I've been looking on internet for a plugin for that, but I can`t find something related.

    Do you have any suggestions, guys? Thank you very much in advance! :)
     
    #1
  2. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,396
    Likes Received:
    12,631
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    Not without a plug-in, as that isn't a built in feature of the program.

    Moved to Plug-In Requests since the desired feature will require a plug-in

     
    #2
  3. shinichi999

    shinichi999 Veteran Veteran

    Messages:
    134
    Likes Received:
    13
    First Language:
    Spanish
    Got it, but what plugin? Can`t find a plugin for that :(
     
    #3
  4. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,052
    Likes Received:
    10,702
    First Language:
    English
    Primarily Uses:
    RMVXA
    Which is why it's in Plugin Requests. If you can't find what you are looking for, you can ask others if they have seen something suitable, or maybe someone would write one for you. That happens in this particular forum, so your thread got moved from wherever it was to here.
     
    #4
  5. shinichi999

    shinichi999 Veteran Veteran

    Messages:
    134
    Likes Received:
    13
    First Language:
    Spanish
    Thank you, I really hope to find help here :)
     
    #5
  6. shinichi999

    shinichi999 Veteran Veteran

    Messages:
    134
    Likes Received:
    13
    First Language:
    Spanish
    No one? :(
     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,672
    Likes Received:
    6,594
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    writing a plugin usually takes more than a few days, and there are only a limited number of people who have the programming knowledge to write something like that. Please continue asking (I consider it a good idea to have a plugin like this available for encyclopedia items or general world building descriptions), but it will probably take quite a while until it is done.
     
    #7
  8. shinichi999

    shinichi999 Veteran Veteran

    Messages:
    134
    Likes Received:
    13
    First Language:
    Spanish
    Of course I know this takes time. I just want to know if somebody could help me with this, I would really appreciate it!
     
    #8
  9. Hiek

    Hiek Creator Veteran

    Messages:
    231
    Likes Received:
    57
    First Language:
    English
    @Andar, I know how he feels. He wants someone who might have taken this request into the works to respond with something like: "I'll do this, give me like a week or two." instead of just working in silence, not letting the requester even know that it's being worked on.

    I see this a lot on the forums and it also bothers me.
    If someone took the request and started working on it, they should respond letting you know instead of leaving you in the dark making you bump your threads/asking more.
     
    #9
    shinichi999 likes this.
  10. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    I've just tinkered with the Game_Message and Window_Message a little bit. I keep making bad things happen to it trying to rewind it the text.

    Is this really for the game messages? Because when you say scrolling text like a manual, I think story/instructions text and my mind goes straight to an HTML element with CSS overflow auto that can be read and scrolled manually. You can make that happen pretty easy.
     
    #10
  11. Trihan

    Trihan Speedy Scripter Veteran

    Messages:
    1,483
    Likes Received:
    980
    Location:
    Buckie, Scotland
    First Language:
    English
    Dictating what someone putting their time and effort into fulfilling a request "should" do is the best way to turn off anyone who might have been inclined to help. Sometimes (speaking for myself at least) we'll see a request and be like "Huh, that sounds neat. I think I'll have a bash at it" and we'll tinker around but we don't want to tie ourselves to a deadline or make promises we can't keep, so we won't post it unless and until we have it fully done.

    The second I post in a topic "Yeah I'm working on this!" it creates an obligation between me and the requester, and sometimes I just don't want that obligation to be hanging over me.
     
    #11
    Galv likes this.
  12. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    I really think I'm on to something here, since it's the most "like a word document" thing I can think of happening in MV. The thing is basically a Chrome browser.
    PHP:
    var div document.createElement("div");
    var 
    css = {
    width:"500px",
    height:"500px",
    overflow:"auto",
    background:'url("img/pictures/coolThing.png") 0 0 scroll #fff',
    color:"#000",
    position:"fixed",
    left:"50%",
    top:"90px",
    marginLeft:"-250px",
    zIndex:99
    };
    for(
    sty in css){
      
    div.style[sty] = css[sty];
    }
    var 
    text document.createTextNode(
      
    "This is a long body of text. "+
      
    "Scrollable when needed"
    );
    div.appendChild(text);
    document.body.appendChild(div);
    And then to remove again...
    PHP:
    div.parentNode.removeChild(div);
    Heh. Like your avatar, is it Case Closed?
     
    Last edited: Mar 12, 2017
    #12
    Andar likes this.
  13. shinichi999

    shinichi999 Veteran Veteran

    Messages:
    134
    Likes Received:
    13
    First Language:
    Spanish

    Yes, I'm the official translator of Case Closed in Latin America (AKA Detective Conan) (In Spanish of course lol)

    Coming back to the point, I really like your idea! I'm making a videogame for college, so I would like to be able to read text books in order to study (like in real life), but I don`t know anything about creating Plugins, and moreover if you can have color on the text, that would be great! :D
     
    #13
  14. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    With this plugin, you should be able to load txt files into a scrollable element.

    [​IMG]
    Call it by event script like so...
    PHP:
    loadTXTfile("loremipsum.txt"); // where loremipsum.txt is a file in your game folder
    Keep in mind, this is an element not inside the canvas, so it could have disadvantages like being on top of menus and windows. If you can do a little CSS, you can pretty it up a little.

    PHP:
    var loadTXTfile = function(file){
       if(
    $gamePlayer.canMoveAfterTxt === undefined){
           
    $gamePlayer.canMoveAfterTxt $gamePlayer.canMove;
       }
       var 
    xhr = new XMLHttpRequest();
       
    xhr.open("GET"filetrue);
       
    xhr.onreadystatechange = function () {
               if(
    xhr.readyState === && xhr.responseText.length 0) {
                   
    removeTXTelement();
                   
    $gamePlayer.canMove = function(){
                       return 
    false;
                   }
                   
    // create element
                   
    var div document.createElement("div");
                   
    // style element
                   
    var css = {
                       
    width:"420px",
                       
    maxHeight:"420px",
                       
    overflow:"auto",
                       
    background:'url("img/pictures/paper.png") 0 0 scroll #fff',
                       
    color:"#000",
                       
    font:'"Lucida Sans Unicode", "Lucida Grande", sans-serif',
                       
    position:"fixed",
                       
    left:"50%",
                       
    borderRadius:"5px",
                       
    padding:"15px",
                       
    border:"3px solid #000",
                       
    boxShadow:"-3px 3px 50px #000",
                       
    top:"50%",
                       
    marginLeft:"-210px",
                       
    marginTop:"-210px",
                       
    zIndex:99999
                   
    };
                   for(
    sty in css){
                       
    div.style[sty] = css[sty];
                   }
                   
    div.id "DOMElementWithText";
                   
    // give the element the text of the text file
                   
    div.innerHTML xhr.responseText.replace(/\n/g"<br>");
                   
    document.body.appendChild(div);
                   
    window.addEventListener("keyup"removeTXTelement);
               }
           };
       
    xhr.send();
    };
    var 
    txtOpenInAction false;
    var 
    removeTXTelement = function(e){
       var 
    ok !== undefined && Input.keyMapper[e.keyCode] === "ok";
       if(
    ok && !txtOpenInAction){
           
    txtOpenInAction true// prevents from closing right when open  
       
    } else if(ok && txtOpenInAction){
           
    txtOpenInAction false;
           
    window.removeEventListener("keyup"removeTXTelement);
           
    $gamePlayer.canMove $gamePlayer.canMoveAfterTxt;
           if(
    document.getElementById("DOMElementWithText") !== null)
               
    document.getElementById("DOMElementWithText").parentNode.removeChild(
                   
    document.getElementById("DOMElementWithText")
               );
       }
    };
     
    #14
  15. shinichi999

    shinichi999 Veteran Veteran

    Messages:
    134
    Likes Received:
    13
    First Language:
    Spanish
    Wow dude, this is EXACTLY what I want! I just have one big doubt... how can I use it? I pasted the code inside a .js and I tried to load the "loadTXTfile" in the plugin command, but it doesn`t work.
     
    Last edited: Mar 13, 2017
    #15
  16. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm sorry. I've never used plugin commands before. I just made it so it takes an event script call (the one above plugin command)

    Also in the plugins folder and turn it on whatever you name it, too.

    Is that plugin command button new? I don't think I've noticed it until recently.
     
    #16
  17. Trihan

    Trihan Speedy Scripter Veteran

    Messages:
    1,483
    Likes Received:
    980
    Location:
    Buckie, Scotland
    First Language:
    English
    In order to add new plugin commands, you alias the pluginCommand function of Game_Interpreter, like so:

    Code:
    var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
        Game_Interpreter.prototype.pluginCommand = function(command, args) {
            _Game_Interpreter_pluginCommand.call(this, command, args);
            if (command.toLowerCase() === YOUR COMMAND NAME HERE) {
                loadTXTfile(name);
            }
        };
     
    #17
  18. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    paper.png < put this in your /img/pictures/ folder too if you want the same background as the GIF example. Or you can make your own. I find elements a lot more dressable than what goes on inside of a canvas because they have hard browser legacy css.
     
    #18
  19. shinichi999

    shinichi999 Veteran Veteran

    Messages:
    134
    Likes Received:
    13
    First Language:
    Spanish
    OK now I'm totally lost hahahaha... what are you talking about, guys? How can I use that code? ;_;

    How can I paste it into a .js file? ;_; Sorry, I'm not good with these things :headshake:
     
    #19
  20. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Ok. I've improved on this since last night. I notice MV was cancelling keyboard and wheel events preventing scrolling on the element, so I've commented out one line in the core. I've also added Trihan's command thing, so now you call either call this script by event...
    PHP:
    loadTXTfile("loremipsum.txt");
    or by command
    PHP:
    loadTXTfile loremipsum.txt
    PHP:
    var _Game_Interpreter_pluginCommand Game_Interpreter.prototype.pluginCommand;
        
    Game_Interpreter.prototype.pluginCommand = function(commandargs) {
            
    _Game_Interpreter_pluginCommand.call(thiscommandargs);
            if (
    command.toLowerCase() === "loadtxtfile") {
                
    loadTXTfile(args);
            }
        };
    var 
    loadTXTfile = function(file){
       if(
    $gamePlayer.canMoveAfterTxt === undefined){
           
    $gamePlayer.canMoveAfterTxt $gamePlayer.canMove;
           
    Input._shouldPreventDefaultAfterTxt Input._shouldPreventDefault;
       }
       var 
    xhr = new XMLHttpRequest();
       
    xhr.open("GET"filetrue);
       
    xhr.onreadystatechange = function () {
               if(
    xhr.readyState === && xhr.responseText.length 0) {
                   
    removeTXTelement();
                   
    $gamePlayer.canMove = function(){
                       return 
    false;
                   };
                   
    Input._shouldPreventDefault = function(){
                       return 
    false;
                   };
                   
    // create element
                   
    var div document.createElement("div");
                   
    // style element
                   
    var css = {
                       
    width:"420px",
                       
    maxHeight:"420px",
                       
    overflow:"auto",
                       
    background:'url("img/pictures/paper.png") 0 0 scroll #fff',
                       
    color:"#000",
                       
    font:'"Lucida Sans Unicode", "Lucida Grande", sans-serif',
                       
    position:"fixed",
                       
    left:"50%",
                       
    borderRadius:"5px",
                       
    padding:"15px",
                       
    border:"3px solid #000",
                       
    boxShadow:"-3px 3px 50px #000",
                       
    top:"50%",
                       
    marginLeft:"-210px",
                       
    marginTop:"-210px",
                       
    zIndex:99999
                   
    };
                   for(
    sty in css){
                       
    div.style[sty] = css[sty];
                   }
                   
    div.id "DOMElementWithText";
                   
    // give the element the text of the text file
                   
    div.innerHTML xhr.responseText.replace(/\n/g"<br>");
                   
    document.body.appendChild(div);
                   
    document.getElementById("DOMElementWithText").focus();
                   
    window.addEventListener("keyup"removeTXTelement);
               }
           };
       
    xhr.send();
    };
    var 
    txtOpenInAction false;
    var 
    removeTXTelement = function(e){
       var 
    ok !== undefined && Input.keyMapper[e.keyCode] === "ok";
       if(
    ok && !txtOpenInAction){
           
    txtOpenInAction true// prevents from closing right when open  
       
    } else if(ok && txtOpenInAction){
           
    txtOpenInAction false;
           
    window.removeEventListener("keyup"removeTXTelement);
           
    $gamePlayer.canMove $gamePlayer.canMoveAfterTxt;
           
    Input._shouldPreventDefault Input._shouldPreventDefaultAfterTxt;
           if(
    document.getElementById("DOMElementWithText") !== null)
               
    document.getElementById("DOMElementWithText").parentNode.removeChild(
                   
    document.getElementById("DOMElementWithText")
               );
       }
    };
    TouchInput._setupEventHandlers = function() {
        
    document.addEventListener('mousedown'this._onMouseDown.bind(this));
        
    document.addEventListener('mousemove'this._onMouseMove.bind(this));
        
    document.addEventListener('mouseup'this._onMouseUp.bind(this));
    //  document.addEventListener('wheel', this._onWheel.bind(this));
        
    document.addEventListener('touchstart'this._onTouchStart.bind(this));
        
    document.addEventListener('touchmove'this._onTouchMove.bind(this));
        
    document.addEventListener('touchend'this._onTouchEnd.bind(this));
        
    document.addEventListener('touchcancel'this._onTouchCancel.bind(this));
        
    document.addEventListener('pointerdown'this._onPointerDown.bind(this));
    };
     
    #20
Thread Status:
Not open for further replies.

Share This Page