Page 1 of 1
Mod play questions
Posted: Tue Jan 08, 2013 3:37 am
by jinxtengu
Hi iv'e been having some issues with playing mod files in my z game (the same game I was working on before)
Iv'e had a look at the mod play example and I've gotten a mod to play on start up of my game, but for some reason I get an error message when I put the initialize code in the "on start" of an app state.
It says unknown function.
also I'd like to know what z expression to use to stop a mod from playing.
Is it possible to have a mod set to looping? and how is it possible to check if a particular mod is playing?
any comments welcome.
Re: Mod play questions
Posted: Tue Jan 08, 2013 9:50 am
by Rado1
Hi jinxtengu,
jinxtengu wrote:but for some reason I get an error message when I put the initialize code in the "on start" of an app state.
I did not have this problem with BASS. Cannot you send your project or some part of it which demonstrates the problem?
jinxtengu wrote:also I'd like to know what z expression to use to stop a mod from playing.
BASS_Stop() or BASS_ChannelPause(channel_handle) just to pause channel playing. I think BASS_ChannelPause is not in the built-in version of the external library, so you should add it by yourself:
int BASS_ChannelPause(int handle) {}
jinxtengu wrote:Is it possible to have a mod set to looping? and how is it possible to check if a particular mod is playing?
I think it's looping by default, isn't it? If not, then you can use the BASS_SAMPLE_LOOP (4) flag in the BASS_ChannelFlags() function, which also should be added manually:
int BASS_ChannelFlags(int handle, int flags, int mask) {}
To check playing of a channel is achieved by the BASS_ChannelIsActive function; also to be added to external library:
int BASS_ChannelIsActive(int handle) {}
BTW Ville, cannot you extend the embedded external BASS library component by these functions (or maybe some more useful functions/constants which can be translated to ZGE's type system easily)? If I find some free time, I can help with this. Maybe it would be better to use the definition file as for Bullet or OpenGL...
Posted: Wed Jan 09, 2013 10:19 am
by jinxtengu
the code I'm trying to run is copied from the mod play demo.
Code: Select all
int ok;
//Start music
ok=BASS_Init(-1, 44100, 0, 0, 0);
if(!ok) {
App.Caption="Error init: " + intToStr(BASS_ErrorGetCode());
return;
}
//Music downloaded from http://modarchive.org/
string musicFile = "398vcf.mod";
int musicId = BASS_MusicLoad(0,musicFile,0,0,0,0,0);
if(!musicId) {
App.Caption="Error load music: " + intToStr(BASS_ErrorGetCode());
return;
}
MusicHandle=musicid;
if(!BASS_ChannelPlay(musicId, 0)) {
App.Caption="Error play music: " + intToStr(BASS_ErrorGetCode());
return;
}
App.Caption="Music is playing!";
this works if it is in the "on loaded" file tree but not if I place it under an app state.
I don't know why this happens.
even running this code :
under an app state give an error message when the program is run, but the code editor doesn't register an error.
I should point out that I am still using version 1.9.9
of z game editor. I didn't want to upgrade until I finish the current game i'm working on because loading it in newer versions causes some problems with the 3d models.
Posted: Wed Jan 09, 2013 11:11 am
by Rado1
The code is correct. In ZGE 3.0.0b it's working also from AppState's OnStart section. Anyway I have one suspicion: did you move also the ZExternalLibrary component to AppState? It should remain in the OnLoaded section of ZApplication.
Is it too difficult to migrate your project to the latest ZGE version (or at least to stable release 2.0.1)?
Posted: Thu Jan 10, 2013 11:02 am
by jinxtengu
I fixed the problem with the mod play in my game:
after moving the Zexternal library bass.dll to the top of the "on loaded" file tree the code for playing mods works when placed in the app states.
also
I tried migrating the project to z game version 3 beta but as soon as the game was run I got an error message from this line of code:
return healthy.value<=0;
"error in expression for node: Condition.
Could not determine type: value(line:1, col: 25)"
i don't understand why this happens.
also i'd really appreciate if someone could explain to me how to use the BASS_SAMPLE_LOOP (4) flag to get Mod files looping.
I have manually added "int BASS_ChannelFlags(int handle, int flags, int mask) {}" to the bass library, however I don't understand how to use the functions properly.
Posted: Thu Jan 10, 2013 11:20 am
by Rado1
jinxtengu wrote:return healthy.value<=0;
Just use
jinxtengu wrote:also i'd really appreciate if someone could explain to me how to use the BASS_SAMPLE_LOOP (4) flag to get Mod files looping.
I have manually added "int BASS_ChannelFlags(int handle, int flags, int mask) {}" to the bass library, however I don't understand how to use the functions properly.
Just download the
bass24.zip file and this contains bass.chm help - everything is described there; it's not too difficult to understand. Of course, I can help you in the case of further questions.
Posted: Fri Jan 11, 2013 1:13 am
by jinxtengu
thanks for your help.
I'll read bass.chm documentation.
changing the code to "return healthy<=0;"
fixed the error.
I got a few other errors. I fixed a few of them but I got stuck on this condition:
return App.CollidedCategory==22;
I tried removing "App." but that didn't help
Posted: Fri Jan 11, 2013 8:05 am
by Rado1
jinxtengu, instead of "App.CollidedCategory==22;" you should use Model.CollidedWith property which is set to the model that the current model has collided with. Ville discussed this change
here (point 6.).
Posted: Fri Jan 11, 2013 12:57 pm
by jinxtengu
ah thanks. Sorry to be a bother.