Author Topic: Jukebox script  (Read 535 times)

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« on: August 18, 2010, 10:35:53 am »


               Hey, just looking for a script that can make a placeable object into a jukebox which plays music when a pc touches it.
               
               

               
            

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« Reply #1 on: August 18, 2010, 01:11:06 pm »


               Nevermind about this post anymore. I don't need a script for this.
               
               

               
            

Legacy_C Writer

  • Jr. Member
  • **
  • Posts: 73
  • Karma: +0/-0
Jukebox script
« Reply #2 on: August 18, 2010, 01:11:46 pm »


               Edit: I didn't see your response until after I finished mine, but I'll still keep it here in case you decide you can find a use out of it.

Are you looking for this to happen as part of a conversation, or when you "use" it?

This script will assume the latter and allow you to turn it off:

void main()
{
   if (GetLocalInt(GetFirstPC(), "JukeboxOn") ==0) // Run the first couple of functions if the jukebox is not flagged as on
   {
       MusicBackgroundChangeDay(GetArea(OBJECT_SELF), TRACK_CITYNIGHT); // You could use any of the tracks under "Constants"
       SetLocalInt(GetFirstPC(), "JukeboxOn", 1); // Flag jukebox as being on
   }
   else
   {
       MusicBackgroundChangeDay(GetArea(OBJECT_SELF), TRACK_DESERT_DAY); // Just an example track - set this to whatever it was
       SetLocalInt(GetFirstPC(), "JukeboxOn", 0); // Flag jukebox as being off
   }
}

If you wanted it as part of a conversation with more sophisticated options, then reply and state what you wanted PCs to be able to do and I'll see if I can point you in the right direction.
               
               

               


                     Modifié par C Writer, 18 août 2010 - 12:12 .
                     
                  


            

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« Reply #3 on: August 18, 2010, 06:02:44 pm »


               What I want it to do is open up a conversation and play three different songs from the nwn soundtrack (obviously, lol). The character can choose which song. I remember when I use to play on Amia and they had this same thing. However; once the song was chosen there was no way to stop the song during the whole game unless the player chose another song, which would spiral around to the same conclusion. Actually if I remember correctly, it wasn't a placeable, but an actual NPC that let one choose the songs. Would it be less of a nuisance to just have an npc and name him Bard, than have a jukebox placeable open up a conversation? I'd much prefer the placeable though.
               
               

               
            

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« Reply #4 on: August 18, 2010, 06:10:03 pm »


               The reason I said earlier that I didn't need the script was because I found a simple way on Nwn Script Directory that did this: http://nwn.wikia.com...ith_a_PC_on_use

Then I just added the bard song sound to the Other Actions tab. A simple way indeed, but I'm trying to keep my module simple since it's a single player game. I'm trying to emphasize alot on storyline and dialogue which i've already done with the main quest npcs, boss creatures, and merchants. All I have to do now is create the in-depth dialogue for the commoners and defenders, as well as create the normal creature encounters.

I'm trying to keep this single player module simple. Not trying to do anything extraordinary, but to do original things extraordinarily. At least that's what my fortune cookie said at Mandarin. lol

But it does make sense though, since that's what I've been aiming for.
               
               

               
            

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« Reply #5 on: August 18, 2010, 06:15:27 pm »


               This was one of my first of two modules. Let's just say the second one was more precise in regards to scripts, but the dungeons were rushed, so it wasn't as good as my first one which was more unprecise in terms of scripts, but more fun. I deleted my second one which was a failure.
Here is a link to my very first module: http://nwvault.ign.c....Detail&id=5881
I had alot more downloads than the 180 it says there because I re-uploaded it a second time to change a few things.
I'm currently working on my third module which might possibly be my last. I don't know yet.
Apart from that, I've always wanted to make a multiplayer Action Pane module based on the Anphillia RP server's concept. The way I'd like to approach that kind of module is instead of pvp, everyone will be on Axfells side who are the evil warlords and the antiheroes based on destroying the zealous Cleavens. Just a brainstorm at the moment.
               
               

               


                     Modifié par Renton007, 18 août 2010 - 05:32 .
                     
                  


            

Legacy_C Writer

  • Jr. Member
  • **
  • Posts: 73
  • Karma: +0/-0
Jukebox script
« Reply #6 on: August 18, 2010, 07:20:18 pm »


               Via scripting, you can trigger conversations with placeables instead of NPCs. Simply throw in the ActionStartConversation() function in the placable's OnUsed script. Then, under the "Actions Taken" tab in the conversation editor, you can directly change the music tracks with each option. You can assign conversations to placeables under the "Advanced" tab. Although the fact that you needing to trigger the conversation may seem to be unneccesary and redundant, it can in fact be helpful if you only want the conversation to be triggered under certain circumstances (with usage of the all-powerful 'if').
               
               

               
            

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« Reply #7 on: August 18, 2010, 07:48:46 pm »


               Okay, I tried that and only the first track played. How do I turn it off?
I titled TRACK_BATTLE_ARIBETH to Aribeth's Last Stand in the conversation editor, but TRACK_HOTU_UNDERMOUNTAIN plays instead. I titled TRACK_HOTU_UNDERMOUNTAIN as Halaster's Undermountain and Aribeth's Last Stand plays instead. Those were choice one and choice two backwards.
And how do you add more than two songs with that script you posted above? I at least want to include four tracks.
               
               

               


                     Modifié par Renton007, 18 août 2010 - 07:11 .
                     
                  


            

Legacy_C Writer

  • Jr. Member
  • **
  • Posts: 73
  • Karma: +0/-0
Jukebox script
« Reply #8 on: August 18, 2010, 08:22:44 pm »


               Is there 'default' music playing when the jukebox is off? Because you should be able to set it back to that track with a 'turn off' option in your conversation window. If you actually want to turn all area music off however (assuming that there was never music playing until the jukebox was activated), then use the BackgroundMusicStop() command and then use BackgroundMusicPlay() along with your music changing function when you turn the jukebox back on again.



Also, if the two songs are truly backward, then that must be a mistake on BioWare's behalf. If that's the case, then you should be able to simply swap the names round. Finally, adding multiple tracks only requires multiple conversation choices with one song-changing function on it. The reason my script had two songs because it was meant for an OnUsed script (not a conversation one) which made simply clicking on the jukebox switch between the two - with help from the 'if' function which you won't really have need for if you go down the conversation route.
               
               

               
            

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« Reply #9 on: August 18, 2010, 08:29:37 pm »


               Yes, there is default music playing when the jukebox is off. As for knowing how to turn it off and ther BackgrounMusicPlay, I don't know how to to that. I only know how to copy scripts. I don't understand scripts at all. Can you post a script that has four multiple choices for Tracks please?
Okay, obviously one can turn it off with an "off' conversation node, but how do you do that when there are only two choices for songs?
Odd thing, now the songs don't play backwards. I copied the script above, made three nodes: Aribeth Last Stand, Undermountain, and Nothing at the moment (that's my turn-off node), and I attached all three nodes in Actions Taken with that script. When I click on my turn off, it just plays Aribeth's Last Stand.
               
               

               


                     Modifié par Renton007, 18 août 2010 - 07:46 .
                     
                  


            

Legacy_Bubba McThudd

  • Sr. Member
  • ****
  • Posts: 254
  • Karma: +0/-0
Jukebox script
« Reply #10 on: August 18, 2010, 09:06:38 pm »


                If you are trying to set up a band of minstrels who perform a variety of tunes, check out Calan's Tavern Band, a script set that I have used extensively in my mod Agrenost - Beneath the Cobbles.  It not only plays music tracks, it has animations for the musicians so it looks like they are playing their instruments (if that is what you are looking for).
               
               

               
            

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« Reply #11 on: August 18, 2010, 09:18:35 pm »


               Hey C Writer, I know I'm giving you a headache, so I'll just stick to that above script that you posted. I know how to use it and it's better being an OnUsed, instead of accessing it through a conversation. At least that I understand. It doesn't matter that it only plays one song. I'm keeping things simple. Actually no, is it possible for you to modify the above script, so that it can have at least two more songs. Three songs would be great.
Thanks for your patience.
               
               

               


                     Modifié par Renton007, 18 août 2010 - 08:21 .
                     
                  


            

Legacy_C Writer

  • Jr. Member
  • **
  • Posts: 73
  • Karma: +0/-0
Jukebox script
« Reply #12 on: August 18, 2010, 11:06:40 pm »


               Don't worry, I don't get headaches from helping people. I know that it may seem to be more simple having multiple songs and for you to be able to cycle through them OnUsed, but I assure you that it will be more simple to have it done via conversation - it will also be more reliable and user-friendly to the PC. Since there is a default music track when the jukebox is off, you needn't worry about BackgroundMusicPlay() or BackgroundMusicStop(), so forget I mentioned it.

All you need to do (after assigning your conversation file to the jukebox by accessing its "Advanced" tab under its properties) is put this script in the OnUsed event handler:

void main()
{
    ActionStartConversation(GetLastUsedBy());
}

As you may have guessed, every script (except 'text appears when' scripts which you don't need to worry about at the moment) has "void main()" and at least one pair of {}s in it so if you are told to run a certain funciton, after filling in its parameters (specified in the bottom window), just put it between the brackets.

When it comes to editing the conversation file, you need to put in multiple choices for the PC to say and attatch a script to the "ActionsTaken" tab (in the options near the bottom when you click each conversation option) for each line with a slightly different script. Here's an example:

void main()
{
    MusicBackgroundChangeDay(GetArea(OBJECT_SELF), TRACK_*);
    MusicBackgroundChangeNight(GetArea(OBJECT_SELF), TRACK_*);
}

Where I've put the *s, finish the constant with whatever music track you desire. So this will require multiple scripts for the conversation file. I assure you that this is a lot simpler and user-friendly than trying to figure out a script to go into the OnUsed handler without a conversation that simply loops through them. I suppose I could do that, but I would reccommend at least giving what I said a go first.
               
               

               
            

Legacy_Renton007

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Jukebox script
« Reply #13 on: August 19, 2010, 09:29:11 pm »


               Thanks man. I got it working! Hooray!

I didn't get much sleep yesterday, so my mind wasn't working at it's full potential.

The thing I didn't understand was the ChangeDay and ChangeNIght thing. I thought one of them was to play the music and the other to turn off the jukebox. I now realize that you have to put both the same track in Day and Night and use that same script and change the details and make multiple scripts to attach to those multiple nodes. I included three choices and they work perfectly. Two songs and a song which plays when the jukebox is turned off. I think I'll add three more songs now. Anyways, I totally get it now. Thanks man! '<img'>