Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Variable not working? [RMMV]

A topic by Turbo123 created 86 days ago Views: 223 Replies: 8
Viewing posts 1 to 6
(1 edit)

Hello, I just bought the script as I'm trying to make it so that when a character goes from one map (throne room) to another (hallway) it continues the same music at approximately the same point in the bgm. So far, I am using a common event, and it looks like this.


I am then loading that common event onto the map using the map note: <OnMapStartCommonEvent:3> with the (DEX_MapStartCommonEvent) plugin.


The music loads, it plays, however variable does not work, continue does not work, nor variablemix. It always starts at the beginning.


I have tried creating an event on each map and doing the same thing with the "plugin commands" running in either parallel or auto, but it crashes my game. What am I doing wrong?

Developer

Without testing, my first thought is: don't run this in Parallel. Parallel events must be used with caution, even outside scripts. In a Parallel event, it's re-running the two commands back-to-back constantly.

Furthermore, the load command takes a couple of seconds, so running Play immediately after it (even if not in Parallel) will likely cause desynching weirdness in variable mix play. You should generally load the music before you need it, by at least a few seconds. In another event, if need be.

"Auto" events block the normal game flow from running, so you need to turn off whatever switch activates it at the end of the event. However, I don't think either one is what you're looking for here. It sounds like what you really want to do is just have a "None" trigger common event, and call it with the "Common Event..." command.

If you're still having problems after all of this, let me know.

Developer (2 edits)

Just to test, I loaded this in a Parallel common event just to see what would happen. No music played at all, and the game crashed after about half a minute. Yeah, I can't say I'm surprised. What surprises me most was that you said it played from the beginning - at all!

When I changed it to a "None" common event, no more crashing, but yeah, desynching. Like I said, you must give the track time to load. If I space out the loading and playing, I get no desynch issues.

I'm confused still. Is there any way you can upload a demo showing the process so I can visually see it in action by any chance?

Developer (1 edit)

A demo feels extreme for this. All you need to do is call the LoadBGM command before you need the music - at least a few seconds before! It can be when you enter the previous room or something, that's fine! It can run in the background while something else is going on! Just don't call the PlayBGM command until you've let it load. And... don't use Parallel or Auto events for this. There is a "Common Event..." command, which will run everything in a common event just once. 

In fact, do you really even need a common event for this?

(1 edit)

I don't know if I need a common event for this, I have done this 100 different ways and it just never allows me to "continue" the song. It just ALWAYS repeats if it works or it doesn't work it just doesn't play at all. I am still learning about creating events and am fairly new to RPG Maker as a whole. Here is what I have, Can you explain to me what I'm doing wrong from these screenshots?



I have created this a hundred times over and in different ways. If I take away the Parallel Trigger, it doesn't load. It's added onto my starting map in the top left as an event. So I am not sure how I can start it without a Parallel or Autorun Trigger, I have done multiple events, with the LoadBGM first and then the PlayBGM, I have ran self switches on and off and added event pages... Nothing is working.

I have also called it using that DEX_MapStartCommonEvents plugin and just calling it as that from the Common Events with "None", but I don't know. It's either nothing works or it just plays from the beginning.

Okay so, I decided to start fresh and see if I could just use a blank project and it seems to be working with how I am doing it here with "parallel".  I am gonna guess it's a plugin conflict. I will report back when I find out what is causing it. ty.

(1 edit)

Alright, so my "overcomplicating" this has messed it all up, Me adding that stupid common event plugin and calling it that way was what was making it not work. After I disabled that, it now seems to be working just fine with your instructions, I am running it in Parallel, I am not sure how else to "Call" an event to start on the maps load. But it's not crashing anymore and it seems to be keeping sync.

also I wasn't aware I didn't need to add the Load and Play to EACH individual map, that's so cool!!!


Is there anyway to add a variable of randomness between different tracks? So if I wanted a choice of 3 songs to play when you load into a certain map, is that doable?

Developer (1 edit)

Well, that solution is better than what you had. It could be better though. Recommendations:

1. Maybe I was unclear about the LoadBGM command? The LoadBGM command can happen at any time just so long as it's before PlayBGM by at least a few seconds. It does not need to be in the same event. You should use it significantly before you need it, not use it and throw a forced wait in within a single event. If memory isn't a concern, you could LoadBGM at the beginning of the game; it'll still be there when you need it. Granted, that forced wait is the only real reason it's working now (you were throttling the system without it), but...

2. You should be using Autorun for the "Play" event. In this case, the Wait would just bog down the game. Now, Autorun blocks the game flow until it's done, but PlayBGM is a very quick action in the grand scheme of things; you just need a way to tell it that it's done. There are two good ways to do this: 

2a. Use the "Erase Event" command to disable the event entirely until the next time the map is loaded (good if you want to run the event every time you load the map); or...

2b. Set a switch (preferably a Self Switch), make a second page for the event, and make the Condition of the page the switch that you set. Leave the second page blank with an Action Button trigger (good if you only want the event to run once ever). 

As for the randomness, you could absolutely do that. Set a variable to a random value between 1 and 3, and then use a Branch command. Like so: