X13Studios Posted September 29, 2011 Share Posted September 29, 2011 (edited) Hey there for my world I thought it would be neat if there was Musical Diamonds that would play music. I found a script it kinda worked for me but what i want is single songs. 1 song per Diamond. This is the script i was using i need this but for 1 song not 5. I tried to alter myself but didn't work. Tyvm for you time and efforts P.S it didn't work right for me. I could only get it to play 2 diff songs, Could just be me though Scn 1ZSmusicObjectScript Short Choosing Short Choice Short Choice2 Short MusicChoice Short MusicChoice2 Begin onActivate player if Choosing == 0 set Choosing to -1 endif end Begin onEquip player if Choosing == 0 set Choosing to -3 endif end Begin gameMode If (Choosing == -1) MessageBox "What would you like to do?", "Take", "Select Music", "Done" set Choosing to 1 set Choice to GetButtonPressed elseif (Choosing == 1) if (Choice == -1) set Choice to GetButtonPressed elseif (Choice == 0) Activate Set Choosing to 0 elseif (Choice == 1) Set Choosing to -2 elseif (Choice == 2) Set Choosing to 0 endif Endif If (Choosing == -2) MessageBox "Wich music would you like to play?", "A Little Piece Of Heaven", "Critical Acclaim", "Danger Line", "Fiction", "Save Me", "Back", "Cancel" set Choosing to 2 set MusicChoice to GetButtonPressed elseif (Choosing == 2) if (MusicChoice == -1) set MusicChoice to GetButtonPressed elseif (MusicChoice == 0) StreamMusic "Data\Music\MyMusic\A Little Piece Of Heaven.mp3" Set Choosing to -1 elseif (MusicChoice == 1) StreamMusic "Data\Music\MyMusic\Critical Acclaim.mp3" Set Choosing to -1 elseif (MusicChoice == 2) StreamMusic "Data\Music\MyMusic\Danger Line.mp3" Set Choosing to -1 elseif (MusicChoice == 3) StreamMusic "Data\Music\MyMusic\Fiction.mp3" Set Choosing to -1 elseif (MusicChoice == 4) StreamMusic "Data\Music\MyMusic\Save Me.mp3" Set Choosing to -1 elseif (MusicChoice == 5) Set Choosing to -1 elseif (MusicChoice == 6) Set Choosing to 0 endif Endif End Begin menuMode If (Choosing == -3) MessageBox "What would you like to do?", "Drop", "Select Music", "Done" set Choosing to 3 set Choice2 to GetButtonPressed elseif (Choosing == 3) if (Choice2 == -1) set Choice2 to GetButtonPressed elseif (Choice2 == 0) DropMe Set Choosing to 0 elseif (Choice2 == 1) Set Choosing to -4 elseif (Choice2 == 2) Set Choosing to 0 endif Endif If (Choosing == -4) MessageBox "Witch music would you like to play?", "A Little Piece Of Heaven", "Critical Acclaim", "Danger Line", "Fiction", "Save Me", "Back", "Cancel" set Choosing to 4 set MusicChoice2 to GetButtonPressed elseif (Choosing == 4) if (MusicChoice2 == -1) set MusicChoice2 to GetButtonPressed elseif (MusicChoice2 == 0) StreamMusic "Data\Music\MyMusic\A Little Piece Of Heaven.mp3" Set Choosing to -3 elseif (MusicChoice2 == 1) StreamMusic "Data\Music\MyMusic\Critical Acclaim.mp3" Set Choosing to -3 elseif (MusicChoice2 == 2) StreamMusic "Data\Music\MyMusic\Danger Line.mp3" Set Choosing to -3 elseif (MusicChoice2 == 3) StreamMusic "Data\Music\MyMusic\Fiction.mp3" Set Choosing to -3 elseif (MusicChoice2 == 4) StreamMusic "Data\Music\MyMusic\Save Me.mp3" Set Choosing to -3 elseif (MusicChoice2 == 5) Set Choosing to -3 elseif (MusicChoice2 == 6) Set Choosing to 0 endif Endif End Edited September 29, 2011 by X13Studios Link to comment Share on other sites More sharing options...
X13Studios Posted September 30, 2011 Author Share Posted September 30, 2011 bump Link to comment Share on other sites More sharing options...
WarRatsG Posted September 30, 2011 Share Posted September 30, 2011 (edited) So you want the script be pretty much the same, only offer 1 song instead of 5? Simple. Just cut out everything in the "If Choosing == -2" block, then put whatever song you want in the "ElseIf ( Choice == 1 )" block and change "set choosing to -2" to "Set Choosing to 0" in that same block. Repeat the above step but with "If Choosing == -4" and "ElseIf Choice2 == 1". Understood? :thumbsup: As for why it didn't work, it might be due to selecting a track just after another track started playing. Just a theory ;) EDIT:: Chuck some "return"s in there, it could use a few. A good example would be where GetButtonPressed returns -1, because no more of the script will be of use anyway. Edited September 30, 2011 by WarRatsG Link to comment Share on other sites More sharing options...
X13Studios Posted September 30, 2011 Author Share Posted September 30, 2011 thats excelent advice but i dont think im that good at scripting yet im novice at best. I posted this wodering if sum1 could make the changes and repost so i could try it. I'm sorry for being a hastle im more of a mapper/story type of person. I'll prob break it if i try Link to comment Share on other sites More sharing options...
metricjester Posted September 30, 2011 Share Posted September 30, 2011 Not sure if this will work cause it's my first coding attempt, but I just applied the same logic as WarRatsG was suggestingScn 1ZSmusicObjectScript Short Choosing Short Choice Short Choice2 Short MusicChoice Short MusicChoice2 Begin onActivate player if Choosing == 0 set Choosing to -1 endif end Begin onEquip player if Choosing == 0 set Choosing to -3 endif end Begin gameMode If (Choosing == -1) MessageBox "What would you like to do?", "Take", "Play Music", "Done" set Choosing to 1 set Choice to GetButtonPressed elseif (Choosing == 1) if (Choice == -1) set Choice to GetButtonPressed elseif (Choice == 0) Activate Set Choosing to 0 elseif (Choice == 1) Set Choosing to -2 elseif (Choice == 2) Set Choosing to 0 endif Endif If (Choosing == -2) MessageBox "Playing 'A Little Piece Of Heaven'" StreamMusic "Data\Music\MyMusic\A Little Piece Of Heaven.mp3" Endif End Begin menuMode If (Choosing == -3) MessageBox "What would you like to do?", "Drop", "Play Music", "Done" set Choosing to 3 set Choice2 to GetButtonPressed elseif (Choosing == 3) if (Choice2 == -1) set Choice2 to GetButtonPressed elseif (Choice2 == 0) DropMe Set Choosing to 0 elseif (Choice2 == 1) Set Choosing to -4 elseif (Choice2 == 2) Set Choosing to 0 endif Endif If (Choosing == -4) MessageBox "Play A Little Piece Of Heaven" StreamMusic "Data\Music\MyMusic\A Little Piece Of Heaven.mp3" Endif End Link to comment Share on other sites More sharing options...
X13Studios Posted September 30, 2011 Author Share Posted September 30, 2011 thanx ill give it a shot and let u know if it worked Link to comment Share on other sites More sharing options...
X13Studios Posted September 30, 2011 Author Share Posted September 30, 2011 a small sumthing must be missing cause when i press play music the message box playing a little pice of heaven uber flashes and dosent do anything i cant close the menu uither so i have to task manager out. Link to comment Share on other sites More sharing options...
X13Studios Posted September 30, 2011 Author Share Posted September 30, 2011 i think may have figured out why my original script didnt work. the 2 songs that did work had 141kbps and the ones that didnt work were 250+kbps ill try lowering the kbps on the ones that didnt work. Maybe that will fix my problem i would still like the singe song script but if this works it will do till i am able to get a single script. Link to comment Share on other sites More sharing options...
WarRatsG Posted October 1, 2011 Share Posted October 1, 2011 (edited) Not sure if this will work cause it's my first coding attempt, but I just applied the same logic as WarRatsG was suggestingScn 1ZSmusicObjectScript You had the right idea. Basically the script will not work because the music will try to re-stream every frame. It's a simple logic error, observe: If Choosing == -2 MessageBox "Playing <Music>" StreamMusic <Music> endif Notice that there is nothing setting "Choosing" back to 0; choosing will always be at -2 and every frame this block will play. A MessageBox will appear and the music will re-stream, every frame. The solution is simple... If Choosing == -2 MessageBox "Playing <Music>" StreamMusic <Music> Set Choosing to 0 endif Or even better, copy and paste the code directly into the choice section... Begin gameMode If (Choosing == -1) MessageBox "What would you like to do?", "Take", "Play Music", "Done" set Choosing to 1 set Choice to GetButtonPressed elseif (Choosing == 1) if (Choice == -1) set Choice to GetButtonPressed elseif (Choice == 0) Activate Set Choosing to 0 elseif (Choice == 1) MessageBox "Playing <Music> ;;;;In here, it used to say "Set Choosing to -2", which is irrelevant now. StreamMusic <Music> Set Choosing to 0 elseif (Choice == 2) Set Choosing to 0 endif Endif So if I were to make a new script, with "return"s and all, it would read... Scn 1ZSmusicObjectScript Short Choosing Short Choice Short Choice2 Begin onActivate player if Choosing == 0 set Choosing to -1 endif end Begin onEquip player if Choosing == 0 set Choosing to -3 endif end Begin gameMode If Choosing == 0 Return Endif If (Choosing == -1) MessageBox "What would you like to do?", "Take", "Play Music", "Done" set Choosing to 1 set Choice to GetButtonPressed Return elseif (Choosing == 1) if (Choice == -1) set Choice to GetButtonPressed Return elseif (Choice == 0) Activate Set Choosing to 0 Return elseif (Choice == 1) MessageBox "Playing 'A Little Piece Of Heaven'" StreamMusic "Data\Music\MyMusic\A Little Piece Of Heaven.mp3" Set Choosing to 0 Return elseif (Choice == 2) Set Choosing to 0 Return endif Endif End Begin menuMode If Choosing == 0 Return endif If (Choosing == -3) MessageBox "What would you like to do?", "Drop", "Play Music", "Done" set Choosing to 3 set Choice2 to GetButtonPressed Return elseif (Choosing == 3) if (Choice2 == -1) set Choice2 to GetButtonPressed Return elseif (Choice2 == 0) DropMe Set Choosing to 0 Return elseif (Choice2 == 1) MessageBox "Play A Little Piece Of Heaven" StreamMusic "Data\Music\MyMusic\A Little Piece Of Heaven.mp3" Set Choosing to 0 Return elseif (Choice2 == 2) Set Choosing to 0 Return endif Endif End This should work as you intended it to. Edited October 1, 2011 by WarRatsG Link to comment Share on other sites More sharing options...
JDFan Posted October 1, 2011 Share Posted October 1, 2011 (edited) WarRatsG --- One question for you about the above script in this section : elseif (Choice == 0) Activate Set Choosing to 0 Return Wouldn't the ACTIVATE also act as a return and then the variable not get set so it should be : elseif (Choice == 0) Set Choosing to 0 Activate Return Or even just :elseif (Choice == 0) Set Choosing to 0 Activate Or am I incorrect ? (possible since I'm just learning the scripting but IIRC I had a problem with this type of scenario before causing problems for a script I was writing ) Edited October 1, 2011 by JDFan Link to comment Share on other sites More sharing options...
Recommended Posts