Yanfly Event Spawner - Region Spawns ignoring script call?

Discussion in 'Javascript/Plugin Support' started by mars714, Dec 18, 2018.

  1. mars714

    mars714 Veteran Veteran

    Messages:
    41
    Likes Received:
    12
    First Language:
    English
    Primarily Uses:
    Other
    Hi. I'm having a bit of trouble with Yanflys event spawner, I'm sure I just need another set of eyes to double check my work, I know this problem has to be because of something I'm doing incomplete. I've already made major improvements of my efforts, Ive had crashes and although its probably just due to my own lack of understanding, I kinda think the help file leaves some stuff out that the video included....

    Anyway, here is my script call:

    var template = 'PlantRocks';
    var region = $gameMap.regionId(1);
    var preserved = true;

    Yanfly.SpawnEventTemplateInRegion(template, region, preserved)


    My most concern is with the 'var region' line. I am unsure its right but I have no alternate knowledge of how to write it. Also... I actually have two script calls spawning two different templates repeatedly, until a number is reached on a variable that count up each time it loops. Then it turns the common event switch off.

    [​IMG]

    The idea being I spawn the two types of mining rocks (pending future additions) thought the region until there are a decent number and then it switches off the event. The event is turned on by the time system, so it checks continually if it needs to be on. The spawn variable also goes down every time a mining rock is destroyed and item prize obtained.

    The game plays tough the common event, I can tell since when I debug the variable is at the amount it says to stop at. However when I search though the maps I see no evidence of the template events anywhere.

    ... I probably didn't need to explain all of that... but it never hurts to be detailed.

    Anyhow, if anyone knows why this code isn't working right, I'd love your help! I'll continue to fiddle with it myself, if I find an answer I'll update this post!
     
    #1
  2. Isabella Ava

    Isabella Ava Veteran Veteran

    Messages:
    635
    Likes Received:
    751
    First Language:
    English
    Code:
    Yanfly.SpawnEventTemplateInRegion('PlantRocks', 1, true);
    Yanfly.SpawnEventTemplateInRegion('AnimalRocks', 1, true);
    $gameVariables.setValue(5, $gameVariables.value(5) + 2);
     
    #2
  3. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,597
    Likes Received:
    1,003
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    The best place to test code is in the console, press F8 during playtest to open it. You can type Javascript directly in there and execute it, and you can see exactly what the results are, and which line(s) are incorrect.

    Your instinct is correct, you're just passing 1 parameter to that function but it's expecting 2 parameters - an x and y coordinate. It takes an x and y coordinate and then tells you the region ID of the tile at that x and y. In fact, there's an event command that does this too.

    More information on that function:
    https://kinoar.github.io/rmmv-doc-web/classes/game_map.html#regionid
     
    #3
  4. mars714

    mars714 Veteran Veteran

    Messages:
    41
    Likes Received:
    12
    First Language:
    English
    Primarily Uses:
    Other
    Okay doing that does seem to give a better idea whee and what the error is.. but even with the linked code, regionId(x: number, y: number): number, I return this error:

    [​IMG]

    It claims there is a missing ')' So I tired the line without the regionId(x: number, y: number): number, at the end... it was all I could think of... In Yanflys demonstration video, they have this code for a template event:

    [​IMG]
    It has separate tiggers for x and y, but also separate fields in the formula. So I'm not sure... Strange thing is This code isn't written anywhere besides the video...

    Thank you for the code, but its having a similar problem... Only when I open the console it reads no errors. If I had to guess its because its so very different from the demonstrated code it docent run, despite being correct in theory. Actually I was using the code:

    Yanfly.SpawnEventTemplateInRegion('PlantRocks', 1, true);
    Yanfly.SpawnEventTemplateInRegion('AnimalRocks', 1, true);

    by its self for a while, until I decided I must have missed something and watched the demonstration video.
     
    #4
  5. DrDhoom

    DrDhoom Monkey Needs a Hug Veteran

    Messages:
    153
    Likes Received:
    151
    Location:
    South Borneo
    First Language:
    Indonesian
    Primarily Uses:
    N/A
    Don't include x: and y: in the regionId parameter.
    Code:
    $gameMap.regionId(x, y);
    Example: $gameMap.regionId(5, 9);
     
    #5
  6. mars714

    mars714 Veteran Veteran

    Messages:
    41
    Likes Received:
    12
    First Language:
    English
    Primarily Uses:
    Other
    Okay, I still can't get this to work, My current code is:

    var template = 'PlantRocks';
    var region = $gameMap.regionId(23, 9);
    var preserved = true;

    Yanfly.SpawnEventTemplateInRegion('PlantRocks', 1, true)

    and nothing. what's more I've started getting walking glitches where I warp across the map, usually to the same spot... I need to take a closer look at it, as there is no event at the location, but it is at a transfer point for a staircase on another map... It may just be due to the amount of plugins I have, yet the console does not recognize it as happening or an error. Anyway I'm gonna fiddle with the alt project to see if I can get the code to work in any way... it may be the plugins, (although last time I tried it did not work)
     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,421
    Likes Received:
    6,485
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    1) please show us screenshots of your plugin manager to make sure that the plugins are installed correctly.
    There are several things that could have disabled or damaged one of yanfly's plugins like wrong order or a few other things, and we can check them with the plugin manager screenshot.

    2) please give a better description of what you want to do and what you expect to happen in your game.
    For example you mixed up two different commands, in your OP you're writing about the command to spawn inside a region and in your post #4 you gave a screenshot of the command to spawn at a xy coordinate - those are two different commands that should not be mixed up.

    3) in your last code variant, the three var's are no longer used and have no function, why do you still include them?
     
    #7
  8. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,597
    Likes Received:
    1,003
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    1. Just to double check, any errors or messages in the Console? (press F8 during playtest to open it)

    2.

    You're not using the value of the variable 'region', is that intentional?

    Can you add these 2 lines to the end and then look at the console output?
    Code:
    console.log($gameMap.validSpawnPoints([region]);
    console.log($gameMap.validSpawnPoints([1]);
    
     
    #8
  9. mars714

    mars714 Veteran Veteran

    Messages:
    41
    Likes Received:
    12
    First Language:
    English
    Primarily Uses:
    Other
    I have found the problem! The event spawner is NOT compatible with ANY Orange Plugins. (I Had time system and day night installed as a base line of my game) The test when all Orange plugins were off was successful. I have no idea how to create a compatible edit as I've never edited plugins. SO... I can ether go no Orange, or beg one/both of the developers to alter their plugin...
     
    #9
  10. Andar

    Andar Veteran Veteran

    Messages:
    28,421
    Likes Received:
    6,485
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    or you can show us screenshots of your plugin manager as I said above - there are ways to test for compatibility and solutions for it, which is (as I mentioned above) one of the other things that could be seen from the plugin manager.
     
    #10
  11. mars714

    mars714 Veteran Veteran

    Messages:
    41
    Likes Received:
    12
    First Language:
    English
    Primarily Uses:
    Other
    [​IMG]

    [​IMG]

    Alright, here are my plugins, I'm not using about 1/4 in addition to the ones that are off. So you do have a point...
     
    #11
  12. Andar

    Andar Veteran Veteran

    Messages:
    28,421
    Likes Received:
    6,485
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    I don't see any direct problem there, but you might want to make a backup of your project and then test if everything works if you place the orange plugins below the yanfly plugins.
     
    #12
  13. mars714

    mars714 Veteran Veteran

    Messages:
    41
    Likes Received:
    12
    First Language:
    English
    Primarily Uses:
    Other
    Good idea but its a no go. TBH I only got the spawn working in the test file with no maps, no other events and no items. I was expeancing heavy glitching in the current save file, so I created another, basically copy pasted all maps, items, and common events, and copied only used plugins, The new project runs Event Spawner fine.

    [​IMG]

    So I mean I can work without using Orange Time System.... But the HUD I may have to look for a replacement...
     
    #13

Share This Page