Yanfly Event Spawner - Region Spawns ignoring script call?

mars714

Veteran
Veteran
Joined
Jun 6, 2017
Messages
41
Reaction score
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.


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!
 

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
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.


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!
Code:
Yanfly.SpawnEventTemplateInRegion('PlantRocks', 1, true);
Yanfly.SpawnEventTemplateInRegion('AnimalRocks', 1, true);
$gameVariables.setValue(5, $gameVariables.value(5) + 2);
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,096
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.

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.
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
 

mars714

Veteran
Veteran
Joined
Jun 6, 2017
Messages
41
Reaction score
12
First Language
English
Primarily Uses
Other
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.
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:


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:

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...

Code:
Yanfly.SpawnEventTemplateInRegion('PlantRocks', 1, true);
Yanfly.SpawnEventTemplateInRegion('AnimalRocks', 1, true);
$gameVariables.setValue(5, $gameVariables.value(5) + 2);
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.
 

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
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);
 

mars714

Veteran
Veteran
Joined
Jun 6, 2017
Messages
41
Reaction score
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)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,377
Reaction score
7,209
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?
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,096
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.

Yanfly.SpawnEventTemplateInRegion('PlantRocks', 1, true)
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]);
 

mars714

Veteran
Veteran
Joined
Jun 6, 2017
Messages
41
Reaction score
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...
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,377
Reaction score
7,209
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.
 

mars714

Veteran
Veteran
Joined
Jun 6, 2017
Messages
41
Reaction score
12
First Language
English
Primarily Uses
Other


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...
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,377
Reaction score
7,209
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.
 

mars714

Veteran
Veteran
Joined
Jun 6, 2017
Messages
41
Reaction score
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.


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

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Besides my Might and Magic inspired project, I have always wanted to make a Fire Emblem-like game. Time is the culprit... Between life, composing music packs, and working on a game can it be done!? The tactical plugins for MV work quite well based on what I have tested.
Yaaay! My second public script is out and approved! A VX Ace Final Fantasy IX styled Throw Script!

I look forward to all the constructive feedback I get but most importantly I hope everyone who ends up using it enjoys!

Yaaaay! Making scripts is fun lol. :D
When you're lost out therrrrre and you're alllll alone, ahwahwah waitin, to carry you hooooommmme, uhhheverywhere you look! (someone hit me with those backing vocals)
X.X cant focus... too many thing want do... help!
Day 2 of teaching MV, student can move cat across the map.

Forum statistics

Threads
100,525
Messages
976,813
Members
132,080
Latest member
nwr
Top