Mod play questions

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
jinxtengu
Posts: 122
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Mod play questions

Post 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.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Re: Mod play questions

Post 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...
jinxtengu
Posts: 122
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post 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 :

Code: Select all

BASS_Free();
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.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post 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)?
jinxtengu
Posts: 122
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post 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.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

jinxtengu wrote:return healthy.value<=0;
Just use

Code: Select all

return healthy<=0;
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.
jinxtengu
Posts: 122
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post 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
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post 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.).
jinxtengu
Posts: 122
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post by jinxtengu »

ah thanks. Sorry to be a bother.
Post Reply