Is it possible to write a script to get ZC to stop loading the screen's midi - and continue playing the existing midi - when Link enters a new room? Or is this hard-coded into the game?
Stop loading music
Started by
James24
, Mar 14 2012 01:40 AM
6 replies to this topic
#1
Posted 14 March 2012 - 01:40 AM
#2
Posted 14 March 2012 - 06:46 AM
i think this.
probably something like this.
QUOTE
void PlayMIDI(int MIDIid)
* Changes the current screen MIDI to MIDIid.
* Will revert to the DMap (or screen) MIDI upon leaving the screen.
* Changes the current screen MIDI to MIDIid.
* Will revert to the DMap (or screen) MIDI upon leaving the screen.
probably something like this.
CODE
import "std.zh"
ffc script new_script
{
void run()
{
Game->PlayMIDI(10);
}
}
ffc script new_script
{
void run()
{
Game->PlayMIDI(10);
}
}
Edited by tox_von, 14 March 2012 - 06:56 AM.
#3
Posted 14 March 2012 - 08:55 AM
There's no way to continue playing the current music. You can use Game->PlayMIDI() to change it back immediately, but it'll still restart the song.
You could do it the other way around - use a script to play the new music instead of setting a screen MIDI. Then you'd just have to give the script some indication that you don't want the music to change.
You could do it the other way around - use a script to play the new music instead of setting a screen MIDI. Then you'd just have to give the script some indication that you don't want the music to change.
#4
Posted 14 March 2012 - 12:48 PM
The closest you can get to this is by making sure the other screens use dmap midis (the default option) and change the dmap midi with scripting. The midi should not restart in this case.
Here is a quick script I made to do just that. I haven't tested it very thoroughly, so it might have some problems.
If you want to just make the currently playing midi continue playing on the current dmap, set D0 and D1 to a negative number (-1 is easy to remember) and leave D2 at 0. Note that this might not save between quest sessions (I haven't tested that), but it is persistent otherwise (you can set it for dmaps you are not even on).
Unfortunately, there is no way I know of to override screen specific midis set with the Screen Data dialog without restarting the midi again (though you can use them to change the dmap midi with this script), so you would have to consider that if you use this.
Here is a quick script I made to do just that. I haven't tested it very thoroughly, so it might have some problems.
CODE
import "std.zh"
// This script will change the DMap midi of a dmap.
// This is probably temporary and won't carry between game sessions.
// This doesn't work with the built-in Zelda 1 midis (sort of) due to laziness...
// d0 = The dmap midi to change. If less than 0 (-1 for example), it will pick the current dmap.
// d1 = The midi to change the dmap midi to. If less than 0 (-1 for example), it will pick the currently playing midi.
// d2 = Should the currently playing midi be changed? 0 = No. 1 = Yes.
ffc script dmapMIDIChange
{
void run(int dmap, int midi, bool changePlaying)
{
Waitframe(); // Delay detection...
while(true)
{
// Wait for screen to scroll in...
while(Link->Action == LA_SCROLLING)
Waitframe();
// Set up the automatic stuff...
if(this->InitD[1] < 0)
midi = Game->GetMIDI();
if(this->InitD[0] < 0)
dmap = Game->GetCurDMap();
if(Game->DMapMIDI[dmap] != midi)
Game->DMapMIDI[dmap] = midi; // Set the midi for the dmap
if(changePlaying && Game->GetMIDI() != midi)
Game->PlayMIDI(midi); // Change currently playing midi
Waitframe();
}//!End while(true)
}//!End void run()
}//!End dmapMIDIChange
// This script will change the DMap midi of a dmap.
// This is probably temporary and won't carry between game sessions.
// This doesn't work with the built-in Zelda 1 midis (sort of) due to laziness...
// d0 = The dmap midi to change. If less than 0 (-1 for example), it will pick the current dmap.
// d1 = The midi to change the dmap midi to. If less than 0 (-1 for example), it will pick the currently playing midi.
// d2 = Should the currently playing midi be changed? 0 = No. 1 = Yes.
ffc script dmapMIDIChange
{
void run(int dmap, int midi, bool changePlaying)
{
Waitframe(); // Delay detection...
while(true)
{
// Wait for screen to scroll in...
while(Link->Action == LA_SCROLLING)
Waitframe();
// Set up the automatic stuff...
if(this->InitD[1] < 0)
midi = Game->GetMIDI();
if(this->InitD[0] < 0)
dmap = Game->GetCurDMap();
if(Game->DMapMIDI[dmap] != midi)
Game->DMapMIDI[dmap] = midi; // Set the midi for the dmap
if(changePlaying && Game->GetMIDI() != midi)
Game->PlayMIDI(midi); // Change currently playing midi
Waitframe();
}//!End while(true)
}//!End void run()
}//!End dmapMIDIChange
If you want to just make the currently playing midi continue playing on the current dmap, set D0 and D1 to a negative number (-1 is easy to remember) and leave D2 at 0. Note that this might not save between quest sessions (I haven't tested that), but it is persistent otherwise (you can set it for dmaps you are not even on).
Unfortunately, there is no way I know of to override screen specific midis set with the Screen Data dialog without restarting the midi again (though you can use them to change the dmap midi with this script), so you would have to consider that if you use this.
#5
Posted 14 March 2012 - 08:31 PM
Thanks so much guys. I will test the code immediately Nick. I never realized there was a GetMIDI function (not on the ZCwiki??) or that you could change and get the Dmap's midi. This opens up a whole new realm of possibilities.
#6
Posted 14 March 2012 - 10:06 PM
ZCWiki is a bit out-of-date. It still has extremely useful information, but it hasn't been updated heavily in a long time. Looking at the recent changes list, it actually seems to be populated by a lot of spam bots.
For the most recent info on functions included with ZScript, it's best to refer to zscript.txt, which is included with ZC.
For the most recent info on functions included with ZScript, it's best to refer to zscript.txt, which is included with ZC.
#7
Posted 14 March 2012 - 10:27 PM
Thanks Nick. I'll keep that in mind. Just finished testing the script you wrote. It works with a couple of minor modifications.
1) The midi has to be changed before the screen is initialized (not after scrolling) - had to check that in the ffc box.
2) Don't have to tell ZC to play the changed midi - it will take care of that automatically.
Works like a charm though, its exactly what I wanted. Thanks.
1) The midi has to be changed before the screen is initialized (not after scrolling) - had to check that in the ffc box.
2) Don't have to tell ZC to play the changed midi - it will take care of that automatically.
Works like a charm though, its exactly what I wanted. Thanks.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users

