Lamphrey 2 Posted August 11, 2016 (edited) Okay, so there's this great little script by Napoleon and Yami. (LINK is to latest version of script I know of, actually really hard to find this, as most of Napoleon's links are down.) http://pastebin.com/Nc324C1m What it does is when you select a character face next to the text box, it automatically takes the the face info, like, "actor1, from index 1" And then it looks in the folder "Busts" for a bust picture with the same name in this format "Actor1-1" and it replaces it with that bust of that name. I've tried a lot of bust scripts and this one is by far the most convenient. Saves a ton of time and work, awesome! It works great. But here's the problem: If you use a character's face that doesn't have a matching bust, it throws up an error that it can't find the bust and then crashes the game. That's no bueno, because while I've drawn whole busts for the important characters, the minor characters only have faces. I like drawing, but making busts for all the minor characters would be too much. So yeah, there's got to be some snippet to add to the script that if it doesn't find a bust picture for a face, to just skip the process, rather than freak out and crash the game. I've found the part that handles the search for the bust, and it's lines 190-197. If anyone just wants a glance: def draw_bust(face_name, face_index) @bust_sprite.mirror = false if face_name && face_name != "" folder = $game_message.bust_folder name = "#{face_name}-#{face_index + 1}" @bust_sprite.bitmap = Cache.cache_extended(folder, name) else @bust_sprite.bitmap = nil Sooo, what can we add to that ^ to make it skip faces that have no corresponding busts? My coding skills are extremely minimal, and I've tried a a few solutions, but they always seem to end up jacking the script so that no busts or faces appear, lol T__T I would be deeply appreciative if anyone has a fix for this minor issue. Edited August 11, 2016 by Lamphrey Share this post Link to post Share on other sites
Kaneshon 10 Posted August 11, 2016 (edited) You can Turn OFF Switch 9, or whatever switch you've set up so it can use normal facesets. Turn it ON again to activate busts again. Edited August 11, 2016 by Kaneshon 1 Lamphrey reacted to this Share this post Link to post Share on other sites
Lamphrey 2 Posted August 11, 2016 True, but if such a thing were to be used, I would have to include a "Switch 9=off" above most lines of minor character text, and since it's likely the main character speaking with them, I would have to insert a "Switch 9=on" before every line of dialogue she speaks so her bust would appear, and then I'd have to add another "Switch 9=off" when they speak again, and so on and so forth. To be honest that's almost the same as just doing the tedious "show picture, erase picture" command for every character's bust, and would kinda defeat the purpose of this script which conveniently automatically assigns pictures to certain faces... Yes, I know, I'm a convenience-seeking jerkbutt haha Truthfully I ran into this problem about a week ago and since then I've been reading up on ruby a bit, and I'm trying to figure out what I can add to that one script passage I included in my first post to make it skip trying to find busts for faces without them... -It's this part that tries to get the bust and therefore crashes the game if there isn't one: @bust_sprite.bitmap = Cache.cache_extended(folder, name) -This they use if there is no face at all, the text box just apears as it would if there were no script : @bust_sprite.bitmap = nil Possible solution #1: I'm thinking maybe using the term 'elsif' , which basically runs an extra check. Would there be a way to check the folder for the bust, and if it's not there, do that piece of code that sets it to nil? Possible solution #2: Or maybe have it check if the "face name" includes the string "actor" (all my characters with busts have indexes called Actor1, Actor2, etc, all the characters without busts are under People1, People2, etc) if it includes the string "people" set it to nil. Problem is I'm not really sure how to type the code for either solution... it's like not being fluent in a language -I know what I want to say, but I have no idea how to form the sentence. And If I make any grammar/syntax mistakes (which I will) the whole thing doesn't work. So I'm not sure if those ideas won't work because I don't have the knowledge to implement them, or because maybe I'm going about it in the wrong way... Any ideas? And thanks for taking the time so far! Share this post Link to post Share on other sites
+ Asharonapaul 276 Posted August 11, 2016 if you try to read a file or load a file that is not existing, it will return nil by default. File.exist?('image.png') you could do it as one line of code. so have for instance, @bust_sprite.bitmap = Cache.cache_extended(folder, name) unless File.exist? == nil, or even unless nil 1 Lamphrey reacted to this Share this post Link to post Share on other sites
Lamphrey 2 Posted August 11, 2016 if you try to read a file or load a file that is not existing, it will return nil by default. File.exist?('image.png') you could do it as one line of code. so have for instance, @bust_sprite.bitmap = Cache.cache_extended(folder, name) unless File.exist? == nil, or even unless nil Wow, I'm excited! Okay, so I commented out the old: @bust_sprite.bitmap = Cache.cache_extended(folder, name) and added in your: @bust_sprite.bitmap = Cache.cache_extended(folder, name) unless File.exist? == nil But now it gives me a 'wrong number of arguments error' Here's a screen shot of the script area I put your piece into, did I put it in the wrong place, or am I missing something? Also, I included the error message picture. Oh, and I wondered if maybe I was supposed to put the: unless File.exist? == nil into a new line, so I tried that as well, but when I do it gives me a 'unexpected $end' error. Leave it to me to burn water like this haha ; Share this post Link to post Share on other sites
+ Asharonapaul 276 Posted August 11, 2016 (edited) no, unless File.exists?('image.png') == nil where you replace image.png with the name of the file. So like '/Graphics/Faces/Some_Faceset.png' or whatever file extension you are using. sorry, I did not write everything in the example in prior message also, in your condition for face name, you have it check that face name && face name are not empty, did you mean face index? Edited August 11, 2016 by chungsie Share this post Link to post Share on other sites
Lamphrey 2 Posted August 11, 2016 Okay, okay, my stupid brain and I are having a bit of trouble understanding, so here is a screencap of how my faces are going to be named and organized. I wrote it on the picture attachment all nice and pretty, but I'll say it here too: Main1, Main2, Main3, Main4, etc do have matching busts in the 'Busts' folder. People1, People2, Supernatural, etc don't have busts, only faces. All are .png, I have learned of the evil that is .jpg lol "also, in your condition for face name, you have it check that face name && face name are not empty, did you mean face index?" If you're talking about seeing that in the script, I didn't write that, the script author did, I'm sure I'm using an unaltered, clean copy that is free of my horrific experiments from the past week... haha Okay, so, what can I put in here: unless File.exists?('___.png') == nil so that Main1, Main2, Main3, Main4, etc have busts and People1, People2, Supernatural, etc won't crash the game for not having busts? I apologize for being slow to understand this, thank you for taking the time to help me! Share this post Link to post Share on other sites
+ Asharonapaul 276 Posted August 11, 2016 ya, the file name of the image goess before .png. So if you wanted the Old man with white Beard, it would be /Graphics/Faces/Spiritual.png 1 Lamphrey reacted to this Share this post Link to post Share on other sites
Lamphrey 2 Posted August 11, 2016 Hmm, just tried it. 1. I put this in the script: unless File.exists?('Spiritual.png') == nil (picture attachment 1) 2. I put put a text box with the face of the old beard guy from Spiritual. (picture attachment 2) 3. Still gives me an error "Unable to find file: Graphics/Busts/Spiritual-8" Huh.. Share this post Link to post Share on other sites
+ Asharonapaul 276 Posted August 12, 2016 Hmm, just tried it. 1. I put this in the script: unless File.exists?('Spiritual.png') == nil (picture attachment 1) 2. I put put a text box with the face of the old beard guy from Spiritual. (picture attachment 2) 3. Still gives me an error "Unable to find file: Graphics/Busts/Spiritual-8" Huh.. unless File.exists?('/Graphics/Faces/Spiritual.png') == nil that is assuming you have not renamed the folder with the facesets for characters. You have to include the folders in the file paths. I'm not sure why it is giving an error. Oh... You should have the above line ammended to the same line as the assignment of the bust. Sorry, I need to step away, I'm getting frustrated now. Share this post Link to post Share on other sites
Ragnos 122 Posted August 12, 2016 Or you can create generic civilian busts two males two female bust that you can use again and again to symbolize a Civilian male or female. Just make it to where the face is hidden or perhaps just a silhouette of one. Share this post Link to post Share on other sites
Lamphrey 2 Posted August 12, 2016 @Ragnos Unfortunately that isn't much of a fix. This project is more of a horror mystery game set in an isolated mountain town, with a little bit of commentary on the current state of the social service system thrown in. It's dialogue and story heavy, so the faces and emo-sets I make matter very much. Ignoring the main characters there'll probably be a couple dozen characters that have facesets alone. I don't suck too much as an artist, and I can pop out a couple every day in my off-time, so it's not a problem. I actually quite enjoy making faces. -Just began today and I'm already about a quarter of the way done with the females. http://uploadpie.com/ho8A5 Just the rough composites for now, the faceset is pretty much just to make my point. So you see, I have no reason to make generic faces. For characters that really don't matter or have just 1 line of dialogue I would just have it be text without a face anyway -many rpgs do that. What I am looking for is just some simple script add-on/snippet that can be added to the Bust Script, to make it skip faces that do not have a matching bust, rather than freaking out and crashing. That's it. So, here is a very simple demo with a clean copy of the bust script. It has one bust that matches a face, and another face that has no bust and unless fixed would crash the game when talked to. Hopefully someone that wants to rise to the challenge will be able to look at that script and figure it out. For anyone still unclear, I also spell it out and give examples in the demo. DEMO.zip Link: https://www.dropbox.com/sh/xz3d74562yt7orj/AAA4UHB3a9bRwmwj1rXf7bkTa?dl=0 Much appreciated. Share this post Link to post Share on other sites
+ Asharonapaul 276 Posted August 12, 2016 ENABLED_SWITCH = 9 # The game_switch that will be used to enable/disable # the busts. Busts are enabled by default. ok, just disabled switch #9, set it false/turn it off in the event before you show a face with no bust. 1 Lamphrey reacted to this Share this post Link to post Share on other sites
Kaneshon 10 Posted August 12, 2016 (edited) @chungsie, I think the OP is aware of this and wants to have the script show normal faces if it can't find the Bust for convenience. tbh its troublesome as well as confusing, in switching on and off if the Bust character is in heavy dialog with a minor character. I'll try my hand in checking out the script and finding an edit, hopefully this will be a good exercise. Edited August 12, 2016 by Kaneshon 1 Lamphrey reacted to this Share this post Link to post Share on other sites
+ Asharonapaul 276 Posted August 12, 2016 it is already set for switch 9... but you could modify the unless methods to be if the File does not exist. the only issue I'm seeing, is that he did not tell me he had a separate folder for the busts. def draw_face(face_name, face_index, x, y, enabled = true) return draw_bust(face_name, face_index) if $game_message.bust_enabled? yamibusts_draw_face(face_name, face_index, x, y, enabled) modify return function... if $File.exists?('/Graphics/Busts/#{face_name}') I would think would work. 1 Lamphrey reacted to this Share this post Link to post Share on other sites
Lamphrey 2 Posted August 12, 2016 the only issue I'm seeing, is that he did not tell me he had a separate folder for the busts. I've specified the Busts folder in almost every post, especially the first post. See quote below. What it does is when you select a character face next to the text box, it automatically takes the the face info, like, "actor1, from index 1" And then it looks in the folder "Busts" for a bust picture with the same name in this format "Actor1-1" and it replaces it with that bust of that name. I've tried a lot of bust scripts and this one is by far the most convenient. Saves a ton of time and work, awesome! I'm not sure how anyone could miss them unless they just didn't read most of my posts or look at any of my attachments. Did you look at that neat little explanation picture I drew just for you like 5 posts back? here, I'll post it again. -__- Please look at it this time? I've taken serious effort to post all the relevant info, details, and then some. I know it can be frustrating to try and help someone and they only give you a vague problem with no details so you have to guess what's wrong. So, I followed your directions and I went to this chunk of script: alias yamibusts_draw_face draw_face def draw_face(face_name, face_index, x, y, enabled = true) return draw_bust(face_name, face_index) if $game_message.bust_enabled? yamibusts_draw_face(face_name, face_index, x, y, enabled) end I "modified the return function" like you said so it is now: alias yamibusts_draw_face draw_face def draw_face(face_name, face_index, x, y, enabled = true) return draw_bust(face_name, face_index) if $File.exists?('/Graphics/Busts/#{face_name}') yamibusts_draw_face(face_name, face_index, x, y, enabled) end But this causes and error when speaking to anything, "undefined method 'exists?' for nil:NilClass" Either I'm making a mistake implementing your piece of code or this might not be it.. Have you been able to get this to work on clean script in the demo? @Kaneshon thanks for sticking around. This is proving to be a little more challenging than the 'face to name' script huh? lol Share this post Link to post Share on other sites
Kaneshon 10 Posted August 13, 2016 (edited) Sorry solution was not working.,, I forgot that I had a switch turning on and off at a particular event during testing lol. Nevermind that.. Still working on it.... Okay try this: It replaces the following methods: draw_face draw bust and adds a new method: check_bust Copy the following and paste it to your Bust script Starting From line 184... alias yamibusts_draw_face draw_face def draw_face(face_name, face_index, x, y, enabled = true) check_bust(face_name, face_index) return draw_bust(face_name, face_index) if $game_message.bust_enabled? yamibusts_draw_face(face_name, face_index, x, y, enabled) end def check_bust(face_name, face_index) @bust_sprite.mirror = false if face_name && face_name != "" folder = $game_message.bust_folder name = "#{face_name}-#{face_index + 1}" if File.exist?("Graphics/#{folder}/#{name}.png") $game_switches[YamiBusts::ENABLED_SWITCH] = true @bust_sprite.bitmap = Cache.cache_extended(folder, name) else $game_switches[YamiBusts::ENABLED_SWITCH] = false end else @bust_sprite.bitmap = nil $game_switches[YamiBusts::ENABLED_SWITCH] = true end end def draw_bust(face_name, face_index) off_x = YamiBusts::WINDOW_TYPE_OFFSET_X[@background] off_x = $game_message.bust_mirror ? -off_x : off_x off_y = YamiBusts::WINDOW_TYPE_OFFSET_Y[@background] @bust_sprite.x = self.x + off_x @bust_sprite.x += self.width - @bust_sprite.width if $game_message.bust_mirror || Window_Message.auto_mirror(face_name) @bust_sprite.mirror = true if $game_message.bust_mirror && YamiBusts::SHOW_BUST_MIRROR || Window_Message.auto_mirror(face_name) @bust_sprite.y = self.y + off_y - @bust_sprite.height @bust_sprite.z = YamiBusts::BUST_Z_INDEX $game_message.face_name = face_name # for addon script end Tried it and it works, credits to Chungsie!! Edited August 13, 2016 by Kaneshon 1 Lamphrey reacted to this Share this post Link to post Share on other sites
Lamphrey 2 Posted August 13, 2016 (edited) Wow, it works, it really does work. Replacing the original lines 184-208 with that does the trick 100% This turned out to be more challenging than a simple 'check if bust exists' kinda solution I thought it would need. So for the ruby-illiterate like my self, what did you guys do to make it work? Something about a switch? So much awesome-sauce... Edited August 13, 2016 by Lamphrey Share this post Link to post Share on other sites
Kaneshon 10 Posted August 13, 2016 (edited) The original script only checks whether a switch is on or not, but doesn't check if a bust exists or not. I seperated the conditional contents of the Draw_Bust, and inserted it to a new method check_bust. Thanks to Chungsie's suggestion using exist? I used this as a condition to check first if a bust exists or not, then flip the switch used by the script according to the result. Glad to see it works, I didn't test if manually flipping the switches on/off would ruin the script, you can try it but I'd advise keeping it dormant lol. Edited August 13, 2016 by Kaneshon Share this post Link to post Share on other sites
Lamphrey 2 Posted August 13, 2016 Wow, you guys are serious pros. Likes for everybody! Good idea not to mess with the switch. No reason to even touch the switch now when the script doesn't crash anymore though ahah. Welp, if anyone wants to go to the original script page and post this fix, great. If not I'll do it when I wake up, with credits to Chungsie and Kaneshon. Thanks to everybody for the help! Share this post Link to post Share on other sites
Rikifive 3,319 Posted August 13, 2016 This thread is closed, due to being solved. If for some reason anybody would like to re-open this thread, just send me a PM or report the thread. (= Share this post Link to post Share on other sites
Rikifive 3,319 Posted August 14, 2016 This thread is reopened at member's request. ~ Share this post Link to post Share on other sites
+ Asharonapaul 276 Posted August 14, 2016 sorry, I forgot the File method names for doing things. It happens, should have used google Ok closeded the thread 1 Lamphrey reacted to this Share this post Link to post Share on other sites
Rikifive 3,319 Posted August 14, 2016 Um.. If you believe that's all, then okay~ This thread is closed, due to being solved. If for some reason anybody would like to re-open this thread, just send me a PM or report the thread. (= 1 Lamphrey reacted to this Share this post Link to post Share on other sites