Author Topic: How would I made a music datablock via code?  (Read 1324 times)

I am making a gamemode that I intend to be fully plug and play. Meaning every required addon and file are built into the gamemode itself.

I searched around and seemed to find some code, however it didn't work.

Code: [Select]
//activate all internal music
datablock AudioProfile(musicData_Ambience_-_Fire)
{
fileName = "./Music/Ambience_-_Fire.ogg";
description = "AudioMusicLooping3d";
preload = "1";
uiName = "Ambience_-_Fire";
};
What did I do wrong?

Does serverplay2d(musicData_Ambience_-_Fire); work with your gamemode loaded?

If yes, is the problem that it doesn't show up in the music list when you wrench a brick? If I remember right you have to add it to the music name list but I'm not sure how to do that right now.

No matter what I do to try to fix it it just keeps slamming me with a syntax error, with the ## ## around the F of the first line.

Maybe I'm using the wrong datablock type or something?

Current code: (my entire server.cs)
Code: [Select]
//exec all internal addons
exec("./knife/server.cs");
exec("./modter4x/server.cs");
exec("./Event_SetPlayerTransform.cs");
exec("./Event_FireRelay.cs");
exec("./roads/server.cs");
exec("./trees/server.cs");
exec("./zones/Bricks.cs");
exec("./zones.cs");

//activate all internal music
datablock AudioProfile(musicData_Ambience_-_Fire.ogg)
{
fileName = "Add-Ons/Gamemode_Blockland_Turmoil/Music/Ambience_-_Fire.ogg";
description = "AudioMusicLooping3d";
preload = "1";
uiName = "Ambience - Fire";
};
« Last Edit: February 01, 2015, 01:25:07 PM by Crispy_ »

You have a dash in there, meaning it's trying to subtract "_Fire" from "musicData_Ambience_" which will not work, thus syntax errors. Either put it in quotes, or get rid of the dash.

Now it's saying the ) on that same line is a syntax error. I tried quoting the dash, then the whole name, then putting the { on the same line, still errors. I'll try removing the dash.

Alright now the syntax error is gone, but when i try playing it via the music brick, it plays nothing. It still shows up on the list, it's just no sound playing at all.

Code: [Select]
//exec all internal addons
exec("./knife/server.cs");
exec("./modter4x/server.cs");
exec("./Event_SetPlayerTransform.cs");
exec("./Event_FireRelay.cs");
exec("./roads/server.cs");
exec("./trees/server.cs");
exec("./zones/Bricks.cs");
exec("./zones.cs");

//activate all internal music
datablock AudioProfile(musicData_Ambience_Fire)
{
fileName = "Add-Ons/Gamemode_Blockland_Turmoil/Music/Ambience_Fire.ogg";
description = "AudioMusicLooping3d";
preload = "1";
uiName = "Ambience Fire";
};

Placing an underscore _ where the space is in the uiName did not make any difference.
« Last Edit: February 01, 2015, 01:39:13 PM by Crispy_ »

Well for starters you'll have a bad time trying to get a .ogg playing from a zip file, that's why all music is in the music directory, not in zipped files. However switching to .wav will increase the files size a little too much. Your best bet is to just make your add-on in a file that can be executed from the Blockland directory and put everything in the proper place.
Also if it is not playing be sure that the sound is in fact mono, and that it meets the file size requirements.

-nvm-

Is the ogg mono?

Try using the ogg out of a zip
« Last Edit: February 01, 2015, 04:49:09 PM by Advanced Bot »

Well for starters you'll have a bad time trying to get a .ogg playing from a zip file, that's why all music is in the music directory, not in zipped files.
If it manages to play outside of a zip but not within, you could host the .ogg files on a site and have it download that, since you'll likely come up with issues trying to copy the file using file objects and you can't fileCopy from a zip.
Just make it so the game mode can't be started until all of the .ogg files are present, and have a client code ask the player to download it.

Welp I guess this is solved then. Sadly I will be using wavs, I understand this will up the file size but I really want this to be completely plug and play. Thanks for your help though, guys.