How to use runtimes so a program can be used in rpg maker mv

Discussion in 'Javascript/Plugin Support' started by sefeloth, Oct 11, 2018.

  1. sefeloth

    sefeloth Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    First Language:
    english
    I want to use creature (an animation software) in rpg maker mv. It has a pixi runtime, but I'm not sure how to use a runtime in rpg maker so that i can import the animation from creature to work. i know it is possible because a runtime was used to make spine and dragonbones work in rpg maker mv (they are also animation software) but i don't know how to do it myself. Could you please help?

    here is the github for all the runtimes they use: https://github.com/kestrelm/Creature_WebGL
     
    #1
  2. Poryg

    Poryg Pixie of the Emvee kingdom Veteran

    Messages:
    2,608
    Likes Received:
    6,105
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    You need to add in the PIXI runtime as a plugin and then create another plugin, which will be creature's implementation.
    Since I don't know the syntax, I cannot do anything, but it's usually creating Creature pbjects via the new keyword and thrn using SceneManager._scene.addChild.
     
    #2
  3. sefeloth

    sefeloth Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    First Language:
    english
    They provided an example here: http://www.kestrelmoon.com/creaturedocs/Game_Engine_Runtimes_And_Integration/PixiJS_Runtimes.html
    They explain some stuff in it, but there is a section called "complete code sample" to see how it was all done together. its halfway down the page

    They list 4 js to load (one of them is pixi), so i put the gl-matrix, mesh and render js as plugins and turned them on in engine. I then tried basically copy pasting the code into script calls for mv, but it's not working.

    it looks like the new keyword is creatureContainer but i could be wrong.

    i tried spending a lot of hours after your reply to see what else i could figure out online but im not having a lot of luck. how would you do this? my java understanding is not as good as yours so im not sure what i need to do. im just trying to implement the example "complete code sample" into rpg maker right now. its at halfway down the page
    http://www.kestrelmoon.com/creaturedocs/Game_Engine_Runtimes_And_Integration/PixiJS_Runtimes.html
     
    #3
  4. Poryg

    Poryg Pixie of the Emvee kingdom Veteran

    Messages:
    2,608
    Likes Received:
    6,105
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Copypasting the code into script calls is suicide, since each script call only has itself as its scope.
    You need to create a plugin.

    Code:
    DataManager._databaseFiles = [
    { name: '$dataActors', src: 'Actors.json' },
    { name: '$dataClasses', src: 'Classes.json' },
    { name: '$dataSkills', src: 'Skills.json' },
    { name: '$dataItems', src: 'Items.json' },
    { name: '$dataWeapons', src: 'Weapons.json' },
    { name: '$dataArmors', src: 'Armors.json' },
    { name: '$dataEnemies', src: 'Enemies.json' },
    { name: '$dataTroops', src: 'Troops.json' },
    { name: '$dataStates', src: 'States.json' },
    { name: '$dataAnimations', src: 'Animations.json' },
    { name: '$dataTilesets', src: 'Tilesets.json' },
    { name: '$dataCommonEvents', src: 'CommonEvents.json' },
    { name: '$dataSystem', src: 'System.json' },
    { name: '$dataMapInfos', src: 'MapInfos.json' },
    { name: '$dataTestCreature', src: 'default.json' }
    ];
    
    var alias_sceneMap_createDispObj = Scene_Map.prototype.createDisplayObjects;
    Scene_Map.prototype.createDisplayObjects = function () {
    alias_sceneMap_createDispObj.call(this);
    this.createDemoCreatureObject();
    }
    
    Scene_Map.prototype.createDemoCreatureObject = function () {
    this._creature = new Creature ($dataTestCreature, false);
    this._creature._anim1 = new CreatureAnimation($dataTestCreature, "default", false);
    this._creature._anim2 = new CreatureAnimation($dataTestCreature, "second", false);
    this._creature._manager = new CreatureManager(this._creature);
    this._creature._manager.AddAnimation(this._creature._anim1);
    this._creature._manager.AddAnimation(this._creature._anim2);
    this._creature._manager.SetActiveAnimationName("default", false);
    this._creature._manager.SetShouldLoop(true);
    this._creature._manager.SetIsPlaying(true);
    this._creature._manager.RunAtTime(0);
    
    var texture = PIXI.texture.fromImage ("character-dragon.png");
    this._creatureLayer = new PIXI.Container(); //displayObjectContainer is deprecated
    this._creatureLayer.position.x = window.innerWidth/2;
    this._creatureLayer.position.y = window.innerHeight/2;
    this._creatureLayer.scale.set(35.0);
    this.addChild(this._creatureLayer);
    this._creatureRenderer = new CreatureRenderer(this._creature._manager, texture);
    this._creatureLayer.addChild(this._creatureRenderer);
    }
    
    var alias_sceneMap_update = Scene_Map.prototype.update;
    Scene_Map.prototype.update = function () {
    alias_sceneMap_update.call(this);
    this.updateCreature();
    }
    
    Scene_Map.prototype.updateCreature = function () {
    this._creature._manager.Update(0.05);
    this._creatureRenderer.refresh();
    }
    
    Also, it's not java, it is javascript. And if you intend to implement that thing into MV, you should definitely learn the programming logic first. Because I am not going to build you a fully fledged plugin, since that's considerably more work than just implementing an already made code.
     
    Last edited: Oct 16, 2018
    #4
  5. sefeloth

    sefeloth Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    First Language:
    english
    I input this code as a plugin but i get "this.initDefaultData" is not a function. I put it last in the list when loading all the other js the demo required. loading the other js as plugins lets the game run fine until this plugin is included. I wanted to try solving this on my own before asking so i tried analyzing the difference between this and the html example given to see why it didnt work but after some hours of trying i couldnt figure out why.

    I've run the html example and it works fine on firefox. i dont understand what differences made the issue. i've tried very hard but I can't figure it out. The only differences i could tell were the pixi stage was not created presumably because rpg maker already does this and some words were switched presumably to make it work with rpg maker so i dont know why it doesnt work when the example works

    Do you know what the issue is? i did not want to trouble you with more questions so i put in a lot of effort to learn on my own, but i couldnt figure it out. Thank you for helping me so far and id appreciate your help again
     
    #5
  6. Poryg

    Poryg Pixie of the Emvee kingdom Veteran

    Messages:
    2,608
    Likes Received:
    6,105
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    When talking about an error, it is much more useful to give a log from the console (f8 or f12 while in game) rather than saying the name of the error, since from the name of the error it's impossible to know what line triggered this error.

    I have noticed a typo in the plugin I provided, so I'll fix it.

    EDIT: Btw. the error you got there probably means that the necessary scripts to make it work are deactivated, since my the initDefaultData function comes from CreatureMeshBone.js
    Another edit: Managed to get it to work on my computer according to this test animation.
    https://www.kestrelmoon.com/creature/dragon_pixijs.html
    Had to perform a couple of alterations in the code, so here is the code:
    Code:
    DataManager._databaseFiles = [
        { name: '$dataActors', src: 'Actors.json' },
        { name: '$dataClasses', src: 'Classes.json' },
        { name: '$dataSkills', src: 'Skills.json' },
        { name: '$dataItems', src: 'Items.json' },
        { name: '$dataWeapons', src: 'Weapons.json' },
        { name: '$dataArmors', src: 'Armors.json' },
        { name: '$dataEnemies', src: 'Enemies.json' },
        { name: '$dataTroops', src: 'Troops.json' },
        { name: '$dataStates', src: 'States.json' },
        { name: '$dataAnimations', src: 'Animations.json' },
        { name: '$dataTilesets', src: 'Tilesets.json' },
        { name: '$dataCommonEvents', src: 'CommonEvents.json' },
        { name: '$dataSystem', src: 'System.json' },
        { name: '$dataMapInfos', src: 'MapInfos.json' },
        { name: '$dataTestCreature', src: 'dragon2_sample.json' }
        ];
        
        var alias_sceneMap_createDispObj = Scene_Map.prototype.createDisplayObjects;
        Scene_Map.prototype.createDisplayObjects = function () {
        alias_sceneMap_createDispObj.call(this);
        this.createDemoCreatureObject();
        }
        
        Scene_Map.prototype.createDemoCreatureObject = function () {
        this._creature = new Creature ($dataTestCreature, false);
        this._creature._anim1 = new CreatureAnimation($dataTestCreature, "default", false);
        //this._creature._anim2 = new CreatureAnimation($dataTestCreature, "second", false);
        this._creature._manager = new CreatureManager(this._creature);
        this._creature._manager.AddAnimation(this._creature._anim1);
        //this._creature._manager.AddAnimation(this._creature._anim2);
        this._creature._manager.SetActiveAnimationName("default", false);
        this._creature._manager.SetShouldLoop(true);
        this._creature._manager.SetIsPlaying(true);
        this._creature._manager.RunAtTime(0);
        
        var texture = PIXI.Texture.fromImage ("dragon2_img.png");
        this._creatureLayer = new PIXI.Container(); //displayObjectContainer is deprecated
        this._creatureLayer.position.x = window.innerWidth/2;
        this._creatureLayer.position.y = window.innerHeight/2;
        this._creatureLayer.scale.set(35.0);
        this.addChild(this._creatureLayer);
        this._creatureRenderer = new CreatureRenderer(this._creature._manager, texture);
        this._creatureLayer.addChild(this._creatureRenderer);
        }
        
        var alias_sceneMap_update = Scene_Map.prototype.update;
        Scene_Map.prototype.update = function () {
        alias_sceneMap_update.call(this);
        this.updateCreature();
        }
        
        Scene_Map.prototype.updateCreature = function () {
        this._creature._manager.Update(0.05);
        this._creatureRenderer.refresh();
        }
    That's not all though, you also need to delete line "var Utils = {}" from CreatureMeshBone.js so that MV's Utils don't get overwritten.

    Screenshot_24.png

    And last but not least it is important to have the correct json name and correct image name. Feel free to edit the code I provided so that it corresponds to your case.
     
    Last edited: Oct 16, 2018
    #6
    sefeloth likes this.
  7. sefeloth

    sefeloth Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    First Language:
    english
    Here is the log from the console:
    https://gyazo.com/22185d02a8cb6ae62ef1fb1c01e522a7

    Sorry, I didn't realize it made much of a difference. The error does occur in the creatureMeshBone but i do have it activated as you can see below:
    https://gyazo.com/bb31616864e154acef5dc7791775025d

    I also highlighted it in the log. As far as I know, it is on. When I turn it off, I get "creature is not defined" error instead too. All the scripts in the demo should be on in the plugin manager. I also don't see the fix to the typo if you could send it again. thank you
     
    Last edited: Oct 16, 2018
    #7
  8. Poryg

    Poryg Pixie of the Emvee kingdom Veteran

    Messages:
    2,608
    Likes Received:
    6,105
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    I made another edit to the previous post. It contains full working code according to the example I integrated into MV (link is there) as well as necessary instructions.
     
    #8
    sefeloth likes this.
  9. sefeloth

    sefeloth Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    First Language:
    english
    thank you very much! i've had so much trouble trying to figure this out on my own but you solved it much quicker than the time it took me trying to even solve it. i wanted to just turn on animations on the map like this does.

    as a show of my appreciation i'd like to paypal you some money and i'm still shaky on how i'd like to easily turn on and off these animations so id like it if you could make a way to do that. the method you showed looks like it can load 1 animation easily but id want to load at least 6 and im not looking forward to implementing that after burning myself out trying to do this again. youre also very good at it too so i trust your skills and would appreciate if you could make it easy to have multiple animations and how to turn it on and off. i also think it'll be easier for you since you have an idea of how the creature code works. i would just need to play animations on the map

    edit: im pretty tired and going to bed so ill reply to you when i can tomorrow. i hope youll help me a bit more and thank you for what youve done so far
     
    Last edited: Oct 16, 2018
    #9
  10. Poryg

    Poryg Pixie of the Emvee kingdom Veteran

    Messages:
    2,608
    Likes Received:
    6,105
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    No need to paypal me anything, I already had all the code I needed in one example, I just made a slight edit and then modified it to the second example. I'd be exaggerating if I said it took 30 minutes. Nevertheless, I don't think I'm going to enhance the script, because as I said, I meant it to be only a very basic implementation of the example for you to learn. Implementing an actual code into the engine that actually does something would be more complex than this and currently I'm absolutely screwed in that matter, because I currently have things I need to do, but suffer from insomnia related to working night shifts, so I'm too tired to really do anything complex.
     
    #10
  11. sefeloth

    sefeloth Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    First Language:
    english
    well i do very much appreciate the help. im sorry to hear about the insomnia. i dont think i wouldve been able to figure out the utils confliction on my own. hearing you say the next part is more complex makes me nervous ^-^' since i already spent hours trying to learn coding to figure out this part. i think i will try to make the json loaded into an array parameter and make the png it reads into one as well? im not entirely sure how itll work out but thank you for the help again!
     
    #11
    ct_bolt likes this.

Share This Page