Here is the demo for my Juke Box script
http://www.box.net/shared/qj5yr5zo50
I only have 1 problem with it, it takes 10sec to open the juke box. Try it out and fix it if you want credit for it.
Let me know what you think
Umm, well, it's not loading fast because you are drawing your window contents 36 times each :-\
see in your refresh method, you have:
for i in 0...@item_max
draw_item(i)
end
and it is proceeding to that method, but that method draws everything in the window. There are a few things I'd change about this. First:
From 22 onward, it is checking if it has the 22nd item in the inventory rather than their respective numbers (23,24,25,etc...)
Secondly, I would probably change the draw_item method so that it draws only one item at a time, and keep the for loop in refresh.
Third, I wouldn't use items I don't think, I think I would set up a boolean array, and then when you get a song, just change the appropriate index to true. That way, they won't clog up the inventory.
Oh, and also, you should use class variables in your scene, not globals. Instead of $help_window, @help_window.
Otherwise, it is a good script and it certainly functions properly, and that is the most important part of the script. If I were you though, I would definitely make it so that it doesn't draw the contents 36 times. All the other things are just suggestions, except maybe the global variables thing.
EDIT:
Oh, and it might be a good idea to get rid of the print message. It doesn't really fit in with an RPG setting to have a Windows Box appear. Maybe instead just draw those ones with a disabled color and play a buzzer if you try to select it.
Im not good at scripting yet, So how would i make it so it will draws only one item?
Well, in the context of using items, you could do it like this:
in refresh:
def refresh
self.contents.clear
for i in 1...@item_max
draw_item(i)
end
end
and then the draw_item method:
def draw_item(index)
if $game_party.item_number(index) > 0
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
self.contents.draw_text(4 + 216*(index%3), 32*(index/3), 128, 30, $data_items[index].name)
end
Thank you so much you will be put in the credits
Sory about the double post
how would i make it where it would only show certian items like only show item 3,5,8,etc...
Cause i have lots more to add than whats on there right now
well, first you should decrease the size of the window from 480 height to 414, and then all you have to do is increase @item_max in order to draw more. If you want to specify which items it should draw, then just do some modifications to the:
for i in 0...@item_max
draw_item (i)
end
For instance, one way you can do it is to store all the music you want to display in an array like this:
@music = ["001-Battle01", "002-Battle02", etc...]
@item_max = @music.size
for i in 0...@item_size
draw_item(i)
end
And then in draw_item, change this line:
self.contents.draw_text(4 + 216*(index%3), 32*(index/3), 128, 30, $data_items[index].name)
to this:
self.contents.draw_text(4 + 216*(index%3), 32*(index/3), 128, 30, @music[index])
This would also make the other part of the script much simpler because instead of the case statement you have, you could replace that entire thing with:
Audio.bgm_play("Audio/BGM/" + @music[@command_window.index],100, 100)
You would, of course have to find another way to check for whether the party has that song yet.
If you still want to have the songs as items, then maybe instead of that first line where I said:
@music = ["001-Battle01", "002-Battle02", etc...]
you could change it to
@music = [["001-Battle01", <item_number of that song>], ["002-Battle02",<item_number of that song>], etc...]
and then that line in your update method:
Audio.bgm_play("Audio/BGM/" + @music[@command_window.index],100, 100)
you could change to:
if $game_party.item_number (@music[@command_window.index][1]) > 0
Audio.bgm_play("Audio/BGM/" + @music[@command_window.index][0],100, 100)
end
In any case, if I were making a jukebox, I don't think I would do it with existing items, but that's just me. Try that stuff and if you don't understand, I'll make a demo.
i will try it and if i don't understand it i will let you know
Solved. You must change @music to $music in every case it appears.
Now the only problem that remains is finding out how RGSS can determine whether an audio file is a midi or an mp3.