RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Flesh of a Radio

0 Members and 1 Guest are viewing this topic.

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Lol at topic name.

I know I said I'll never script again, but I couldn't help myself from making this.

Code: [Select]
class Jukebox

attr_reader :list

def initialize
@songs = Dir.entries("Audio/BGM/")
temp = @songs.clone
@list = []
for i in 0..(temp.size)
next if temp[i] == "." or temp[i] == ".." or temp[i] == nil
@list.push(temp[i])
end
for i in 0..(@list.size)
@list[i].gsub!(/\.[^\.]*\Z/) {|s| "" }
end
end

def find(song)
@list.each.do(|i| return i.index if i == song)
end

def play(song)
index = find(song)
Audio.bgm_play(@songs[index + 2], 100, 100)
end

def stop
Audio.bgm_stop
end

end

It is the flesh of a Radio/Jukebox.

All you need to do is script the bone.

Erm, let me speak English here.

All you need to do is script a scene that will utilize this in the game, allowing the player to choose songs to play as the bgm.

NOTE: This will only work for songs that have been imported!!!!

INSTRUCTIONS: The only ones that should use this should be those with the understanding of how it works. Making the music list shouldn't be too hard. $jukebox.list anyone?
To play a song, you would doj $jukebox.play("EXACT SONG NAME MINUS EXTENSION IN QUOTES").
Oh yeah, you'll also need to initialize $jukebox as an instance of the Jukebox class.
i.e. :
Code: [Select]
$jukebox = Jukebox.new


EDIT : Fixed error pointed out by Zeriab. :)
« Last Edit: June 20, 2007, 04:58:30 AM by Tsunokiette »
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

pokeball :)OfflineMale
********
Cheese
Rep:
Level 95
?
OMG OWNAGE! this is pure sweetness, thanks I am going to use this in an upcomming game of mine.  ;D
Watch out for: HaloOfTheSun

****
Rep:
Level 89
I is my hero!
This is cool, I tried to make a jukebox out of events before.
« Last Edit: February 21, 2007, 02:38:13 AM by bulls84 »

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
I edited it so it won't include "." and ".." in the list of songs.

It should still work. Please report any errors you obtain.

Also note that the last song in the list may or may not be nil.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

pokeball :)OfflineMale
********
Cheese
Rep:
Level 95
?
Can someone move this to script database...I tried looking for it and it wasn't there. =[
Watch out for: HaloOfTheSun

*
I love Firerain
Rep:
Level 97
=D
TSUNOKIETTE THIS SCRIPT ROCKS!
and stone and pebbles too!
Arlen is hot.

***
Rep:
Level 87
¥¥Death is Peace, and it is your friend¥¥
you could make an event with a juke box, but im sure the script version is way better.

********
Sailor Man
Rep:
Level 95
So about that money...
Brilliant!

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
Good idea Tsu, I like it.

There is just one thing. Is this part just supposed to remove the extensions?
Code: [Select]
for i in 0..(@list.size)
@list[i].gsub!(/.mid/) {|s| "" }
@list[i].gsub!(/.midi/) {|s| "" }
@list[i].gsub!(/.ogg/) {|s| "" }
@list[i].gsub!(/.wma/) {|s| "" }
@list[i].gsub!(/.mp3/) {|s| "" }
@list[i].gsub!(/.wav/) {|s| "" }
end

If you just want to remove all extensions and not just the 6 given you can use this code:
Code: [Select]
for i in 0..(@list.size)
@list[i].gsub!(/\.[^\.]*\Z/) {|s| "" }
end

If you want to just remove the extension of those specific files there still are some issues
First of all is the fact that . means any character. So basically if you have this filename: "owman.mp3" the resulting name will be "n".
Yes. It does not have to be at the end. If so you should use the $ sign \Z.
Hmm... Maybe I will write a tutorial on Regular Expressions.

Anyway, good job!

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
I only did the files that RPGMXP supports.

I've tested it, the filenames are exactly like they should be. ^_^

For example -

Code: [Select]
@list[i].gsub!(/.mid/) {|s| "" }

It doesn't just search for ., it searches for .mid as a whole.

And thanks for the feedback! :D
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
Then try naming the file this: "Somemid.mid" or perhaps this: "filename.mid.mid"

***
Rep:
Level 87
RMU Admin
Nice script. Im trying to learn scripting so im making my own juke box script to. The way im doing it is way simpler than this. Do you get to select what music to play?

*
A Random Custom Title
Rep:
Level 96
wah
Nah, I think it's random, but it supports any file that you import (er, at least the ones stated).

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
This is only the skeleton of a Jukebox script.
That is, the start of a Jukebox script.
It looks through all the files in "Audio/BGM/" and stores the supported files in a list.
Well... That is the purpose, but it after looking through it I can tell that it doesn't work right.
Maybe you could get Tsu to look at it again. This time I have written a RegExp Tutorials ^_^

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
It is clear that you don't know what this script does.
This simple reads all the support music files in your "Audio/BGM/" folder and allow you to find and play a song rather easily.
I suggest you make request topic with your request in.

**
Rep: +0/-0Level 87
My apologies - I figured it could be limited somehow, at least keeping it to one event chain rather than two. ;/

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
This is only the skeleton of a Jukebox script.
That is, the start of a Jukebox script.
It looks through all the files in "Audio/BGM/" and stores the supported files in a list.
Well... That is the purpose, but it after looking through it I can tell that it doesn't work right.
Maybe you could get Tsu to look at it again. This time I have written a RegExp Tutorials ^_^


To be honest I suck when it comes to Regular Expressions.
I went ahead and put your fix into the code. :D

@Polraudio : Good luck, if you need any help, just ask here. ;)  Unless of course, you've already asked and have received an answer already, making what I'm saying pointless... shutting up now... lol

@mastermoo420 : It doesn't play random songs. Though that should be easy to implement. As I said in the original post, if you do $jukebox.play("Song_Name_Minus_Extension") it will play the song you chose. To be more exact -

It will run the find method with the song name. This will search for the song in @list with the exact same name (it essentially find the song, thus the name of the method), and will return the index to the play method, storing it in index. It will then play the song, and the index of the song in @song is found by adding 2 to index since there are two files in the music folder known as '.' and '..' that aren't included in @list. To make a command window with the music choices, all you have to do is read from $jukebox.list to receive all of the song names - in the order they are in the folder.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*
A Random Custom Title
Rep:
Level 96
wah
I see.... Kind of. Zurgh. This script is too complex for me too understand. Go noob-ish scripting skills. @_@

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
@Moo:
The principle behind this script is that it lends a helping hand to people wanted to create a jukebox script.
Tsu just lets other people create the actual look ^_^

@Tsu:
I wanted you to start scripting again :P

*
A Random Custom Title
Rep:
Level 96
wah
@Moo:
The principle behind this script is that it lends a helping hand to people wanted to create a jukebox script.
Tsu just lets other people create the actual look ^_^
I knew that, but I was trying to understand how the jukebox inner workings worked.

Quote
@Tsu:
I wanted you to start scripting again :P
Everyone does. T_T NO! Even better: TEACH ME!! XD

*
Rep:
Level 72
~Few people understand the beauty of the night~
2014 Best Topic
*raises from the dead, like, waaaayyy dead*


Alright, I know this is a reaalllyyyy old script, but I'm trying to use it, and I realy can't figure out what's wrong. It all looks like it's in order, but I'm having issues. I modified it to read from a different folder (Radio), and that seems to work fine, as in, it doesn't throw an error until after that line. I get an error though when trying to load the damn thing =p

Thoughts on what it might be?


Script:
Spoiler for:
Code: [Select]
class Jukebox
   
    attr_reader :list
   
    def initialize
        @songs = Dir.entries("Audio/Radio/")
        temp = @songs.clone
        @list = []
        for i in 0..(temp.size)
            next if temp[i] == "." or temp[i] == ".." or temp[i] == nil
            @list.push(temp[i])
        end
        for i in 0..(@list.size)
            @list[i].gsub!(/\.[^\.]*\Z/) {|s| "" }
        end
    end
   
    def find(song)
        @list.each.do(|i| return i.index if i == song)
    end
   
    def play(song)
        index = find(song)
        Audio.bgm_play(@songs[index + 2], 100, 100)
    end
   
    def stop
        Audio.bgm_stop
    end
   
end

Screenshot of error:

http://www.tiikoni.com/tis/view/?id=1164d7f
Download http://a.tumblr.com/tumblr_lm5v281q6E1qde50fo1.mp3

*
Rep: +0/-0Level 8
RMRK Junior
Partly qkg.weqy.rmrk.net.rql.vx block: explore temporary, generic levitra canadian pharmacy cialis 20mg sky pharmacy prednisone zyloprim generic levitra 20mg immature compressed: mouth, <a href="http://gaiaenergysystems.com/levitra-generic/">cheapest levitra 20mg</a> <a href="http://charlotteelliottinc.com/canadian-pharmacy/">canadian pharmacy</a> <a href="http://vowsbridalandformals.com/buy-prednisone/">prednisone online</a> <a href="http://telugustoday.com/zyloprim-for-sale/">generic zyloprim</a> <a href="http://charlotteelliottinc.com/levitra-20-mg/">levitra</a> overriding http://gaiaenergysystems.com/levitra-generic/ levitra http://charlotteelliottinc.com/canadian-pharmacy/ cialis canada pharmacy online http://vowsbridalandformals.com/buy-prednisone/ prednisone buy http://telugustoday.com/zyloprim-for-sale/ zyloprim http://charlotteelliottinc.com/levitra-20-mg/ levitra reaction, psychoanalytic vasculitis.

*
Rep: +0/-0Level 3
RMRK Junior
Treated hjy.gqjg.rmrk.net.ciu.nq able discount alesse colospa for sale cialis 5mg retino-a cream 0,05 cream viagra foro participation; <a href="http://prettysouthernbk.com/alesse/">alesse</a> <a href="http://russianpoetsfund.com/colospa/">colospa</a> <a href="http://puresportsnetwork.com/cialis/">once a day cialis</a> <a href="http://disasterlesskerala.org/retino-a-cream-0,05-cream/">cheapest retino-a cream 0,025</a> <a href="http://neo-medic.com/viagra-generic/">viagra generic</a> decide: cricoid http://prettysouthernbk.com/alesse/ discount alesse http://russianpoetsfund.com/colospa/ generic colospa http://puresportsnetwork.com/cialis/ cialis without prescription http://disasterlesskerala.org/retino-a-cream-0,05-cream/ retino-a cream 0,05 cream http://neo-medic.com/viagra-generic/ viagra pills intervention, tumescence passivity, 4wks.