- Joined
- Sep 26, 2012
- Messages
- 32
- Reaction score
- 4
- Primarily Uses
OK, so this is my first attempt at a script. The purpose of it is to display a picture from the item menu. This would allow you to pick up items like books, carry it around with you and view the contents whenever you want.
But I can't get it to work! I've been fiddling around with this for hours and I can't see what I'm doing wrong so I'm throwing it over to the community.
This is a rough "first draft" so forgive me if it's not well-written. Once I've got it working I'll make it nice and elegant (and probably add more functionality too).
class RPG::BaseItem def check_picture_tag? #method to check if there is a picture to be displayed. /picture/i =~ @note end def get_pictures_to_display # Method to get the filename of the picture to display. arr = [] n = /<(?
ICTURE|picture):[ ]*"(\S+)">/i @note.split(/[\r\n]+/).each { |line| case line when n p "match found OK" #get contents of note that comes between "..." $1.scan(/"(\W+)"/).each { |filename| p filename.to_s arr.push(filename.to_s) } #return as an array of strings so each can be displayed in order end p arr } return arr end end# define a new version of scene_item which calls the above when an item is usedclass Scene_Item < Scene_ItemBase def on_item_ok if item.check_picture_tag? pictures_to_display = item.get_pictures_to_display display_picture(pictures_to_display) else $game_party.last_item.object = item determine_item end end def display_picture (pictures_to_display) p pictures_to_display pictures_to_display.each { |pic| @pic = Sprite.new @pic.bitmap = Cache.picture(pic) #add in some way of pausing til user presses enter (refresh method) } end endTo get it to work, you're supposed to create an item from the manager and add the notetag <picture: "filename"> where filename is the name of an image in the game's picture folder. Once you possess the item you should be able to activate it from the item menu and it displays the picture. However, nothing is returned. As far as I can tell, the method get_pictures_to_display just returns an empty array.
If anyone can point me in the right direction I'd be very grateful!
But I can't get it to work! I've been fiddling around with this for hours and I can't see what I'm doing wrong so I'm throwing it over to the community.
This is a rough "first draft" so forgive me if it's not well-written. Once I've got it working I'll make it nice and elegant (and probably add more functionality too).
class RPG::BaseItem def check_picture_tag? #method to check if there is a picture to be displayed. /picture/i =~ @note end def get_pictures_to_display # Method to get the filename of the picture to display. arr = [] n = /<(?
If anyone can point me in the right direction I'd be very grateful!

