Help creating a persistent log window (SOLVED)

Discussion in 'Learning Javascript' started by Amarok, May 13, 2019.

  1. Amarok

    Amarok Veteran Veteran

    Messages:
    288
    Likes Received:
    710
    Location:
    Spain
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    Hello guys! so ive recently started to learn coding but this is still too much for me, if you don't know exactly what im talking about

    [​IMG]

    Just be able to open and close a window that shows up more lines of text as i add them, then once its filled it clears the window and starts again.
    I got the persistent custom window to show up, but i don't even know how to close it or update the text.
    Im assume this cant be that hard to add, but im still too much of a noob to figure it out, if anyone could give me a hand that would be awesome. Thanks in advance people!

    EDIT: i got this, was a lot easier than i thought! just declare a global variable on a plugin then use that variable to create the window, add text, close it, whatever.

    [​IMG]
     
    Last edited: May 15, 2019
    #1
  2. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,266
    Likes Received:
    2,314
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    you just need to store an array of strings as text, or an array of objects for text elements,, for example:

    Code:
    var text_array = [];
    
    function addToTextLog(newtext, otherdata){
      let text_obj = {};
      text_obj.text = newtext;
      text_obj.other = otherdata;
      text_array.push(text_obj);
    }
    
    function clearTextLog(){
      text_array = [];
    }
    
    // use functions as:..
    addToTextLog("my string of text", "someotherdataforathing");
    clearTextLog();
    
    Hope this helps :*
     
    #2
    Amarok likes this.
  3. Amarok

    Amarok Veteran Veteran

    Messages:
    288
    Likes Received:
    710
    Location:
    Spain
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    @?????? thanks! im still struggling to understand all the different stuff, for reference i used this little script @Astfgl66 posted on a previous thread (thanks a lot for sharing it btw!):

    var win = new Window_Base(150, 150, 100, 100); //x,y,width,height
    SceneManager._scene.addChild(win) //adds the window to the curent scene
    win.drawText("Your text", 0, 0, 100, "left"); //draws the text

    Would it be possible to use your solution on this window? sorry if what i ask sounds ridiculous but i genuinely don't know, just got started with arrays and cycles recently
     
    #3
  4. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,266
    Likes Received:
    2,314
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    I feel like your using that as a script call from within some event, in which case, i recommend you look further into how object oriented programming works.

    In short, yes, my solution would work, but only if used in the right way. I'd recommend a guide for how to create a plugin for a custom window. once your at that point, it should be easier to understand how to make the window show the text you want. :)
     
    #4
    Amarok likes this.
  5. Amarok

    Amarok Veteran Veteran

    Messages:
    288
    Likes Received:
    710
    Location:
    Spain
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    @?????? thanks again! i guess i really tried to bite more than i can chew haha i will start following tutorials from the basics again, if you have any recommendation to get started i would appreciate that a lot aswell.
     
    #5
  6. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    671
    Likes Received:
    517
    First Language:
    French
    You probably want to create your custom window with a plugin for this.
    Look into window base and draw your text within your own update function.
    Use the built in show and hide methods to close or open the window.

    There's a lot of example of what you want to do, look into the core scripts for inspiration. At least within window base since that's what you're creating.
     
    #6
    Amarok likes this.
  7. Amarok

    Amarok Veteran Veteran

    Messages:
    288
    Likes Received:
    710
    Location:
    Spain
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    @Astfgl66 awesome, will do that, thanks again!
     
    #7

Share This Page