Neat little things I've discovered.

Discussion in 'Learning Javascript' started by mogwai, Apr 8, 2017.

  1. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    570
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    I decided to make a thread for all those little neat things I discover tinkering with javascript. (that haven't been requested yet) These aren't really plugins, but rather scripts that do a thing like what the engine is supposed to do, but may not be well known.
    ___________________________________________________________

    My first thing, I just learned is that changes to game $gameSystem._windowTone happen instantly, so you can use it to make flashing windows. There may be a plugin that does this, but it can really be done with plain javascript.
    [​IMG]
    This can be acheived without plugin, via event script call...
    PHP:
    if(this.colorInterval === undefined){
        var 
    rand255 = function(){return Math.round(Math.random()*255)};
        
    this.reTone $gameSystem._windowTone;
        
    this.colorInterval setInterval(function(){
            
    $gameSystem._windowTone = [rand255(),rand255(),rand255()];
        }, 
    100);
    }
    And to turn off... EDIT: Oops! forgot to add (this)... It was broken, but I fixed it. I should have tested first... another one of those IIFE event script gotchas, for me...
    PHP:
    clearInterval(this.colorInterval);
    delete this.colorInterval;
    $gameSystem._windowTone this.reTone;
    ___________________________________________________________

    These neat little things never cease to amaze me. Post neat little things you've discovered/learned too.
     
    Last edited: Apr 8, 2017
    #1
    Fernyfer775, Shugo and Lestroth like this.
  2. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,468
    Likes Received:
    1,181
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
  3. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    570
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Slightly off topic, until someone makes a general javascript chat thread, but don't let me forget this Grep command for making hundreds of function aliases at once.
    Code:
    \n((([^\.\n]+)\.[^\s]+) = function\(\) \{)
    Code:
    \n\3.prototype.aliasInit4Name = \2;\n\1 \n\tthis.aliasInit4Name.apply(this, arguments);\n\tthis.domWindowName="\3";
    It took me a minute to cognite and type, so I'm posting it someplace for future reference. I'll lose it if I save it to a txt file.
    [​IMG]

    [​IMG]

    EDIT: Yowza! Crash!
    Don't worry about the stack size. I just now had to append iterated numbers to each alias also with Grep.

    The neat thing I discovered here is ES6 IdentifierReference;
    var foo = "bar"; {foo} === "foo";
    too bad MV does not have it

    Carry on...
     
    Last edited: Apr 8, 2017
    #3
  4. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    570
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    All the pro scripters keep a master list of all their stuff in a link or whatever.
    I've decided to compile a list of all the plugins and event scripts I've come up with on this forums (that I could find). I'm not starting a new thread because this forum already has a ton of my inactive threads. This is all stuff I've learned too, anyway.

    No particular order, just where I went and found them.

    Two different plugins to change a sprite's color.
    https://forums.rpgmakerweb.com/index.php?threads/freezing-event.75257/
    [​IMG]




    Spawn and shoot projectiles from an event page. (plugin)
    https://forums.rpgmakerweb.com/index.php?threads/tower-that-shoot-player.75560/
    [​IMG]

    Make events non-passable to certain events based on self switch. (plugin)
    https://forums.rpgmakerweb.com/index.php?threads/player-event-barrier.76237/page-4
    [​IMG]

    Skill that evaluates javascript from item notes. (plugin)
    https://forums.rpgmakerweb.com/inde...instant-reaction-to-switch.76262/#post-716258
    [​IMG]

    Party members who don't fight in battle, like pets. (plugin)
    https://forums.rpgmakerweb.com/inde...ers-followers-who-dont-fight-in-battle.76703/
    [​IMG] [​IMG]




    Get events by name. (small plugin)
    https://forums.rpgmakerweb.com/inde...t_emily-both-move-to-mapx-0-and-mapy-0.76548/
    PHP:
    var RPGMakerMV RPGMakerMV || {};
    RPGMakerMV.getEventsByName = function(name){
      var 
    events = [];
      for(var 
    0$dataMap.events.lengthi++){
        if(
    $dataMap.events[i] === null) continue;
        if(
    $dataMap.events[i].name !== undefined && $dataMap.events[i].name === name)
          
    events.push($gameMap._events[$dataMap.events[i].id]);
      }
      return 
    events;
    }

    Missing images don't crash game, but rather are substituted with a dummy image.
    https://forums.rpgmakerweb.com/inde...ind-such-and-such-png-oog-or-waht-ever.76165/
    [​IMG]






    Playing music continues and overrides any autostart music when a switch is on.
    https://forums.rpgmakerweb.com/index.php?threads/map-to-ship-music.75483/




    Certain enemies move random, but chase you when you move. (plugin)
    https://forums.rpgmakerweb.com/index.php?threads/move-after-player.74877/


    Disable/Enable total player movement by event script.
    https://forums.rpgmakerweb.com/index.php?threads/block-player-movement.74387/

    Game focus/camera temporarily follows event instead of hero.
    https://forums.rpgmakerweb.com/index.php?threads/cinematic-camera-control.74391/



    Plugin to record/playback/save audio from microphone.
    https://forums.rpgmakerweb.com/index.php?threads/plugin-to-record-voice.77683/
    [​IMG]


    Pin message to picture, like showing two messages at the same time.(plugin)
    https://forums.rpgmakerweb.com/index.php?threads/two-dialogues-at-the-same-time.77045/#post-727548
    [​IMG]

    Actual simultaneous messages. (plugin)
    https://forums.rpgmakerweb.com/inde...ues-at-the-same-time.77045/page-3#post-729636
    PHP:
    \[top]This is some \[middle]This is some  \[bottom]This is some
    \[top]text on the  \[middle]text on the   \[bottom]text on the
    \[top]top window   \[middle]middle window \[bottom]bottom window
    \[top]four rows    \[middle]four rows     \[bottom]four rows
    [​IMG]








     
    Last edited: May 2, 2017
    #4
  5. Kyuukon

    Kyuukon 主人公 Veteran

    Messages:
    2,176
    Likes Received:
    989
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    This is very useful! Thanks!
     
    #5
    mogwai likes this.
  6. Bricabrac

    Bricabrac The Storyteller Veteran

    Messages:
    106
    Likes Received:
    179
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMMV
    Lots of lovely stuff. Thank you!
     
    #6

Share This Page