Tenoukii 0 Report post Posted April 16, 2011 (edited) Hello (: I need a script that adds to the after battle stats to say "Earned 1 TP" and increase a variable by 1 after each battle (If that makes sense?) If you need elaboration, just ask :D Thanks ^_^ EDIT: It would also be cool if there was a box on the menu to replace the Steps Window that says how much TP a player has? And another question/request! Can this script: http://forum.chaos-project.com/index.php?topic=7404.0 be made so that there are 2 separate screens? I want to make 'Glossary' and 'Tutorials' sections in the menu, but so they are in separate windows (if again, that makes sense?) That's about it for now :D Thanks Edited April 16, 2011 by Tenoukii Share this post Link to post Share on other sites
Descendant of Orr 1 Report post Posted April 16, 2011 Ok, so - I have a couple of questions about what you need. 1) Will you earn 1 TP after EVERY BATTLE in the game? Will some battle award none, will bosses award more? 2) Is TP a party wide shared currency, like gold? If your answers to 1a and 2 are yes then the following should work for you: class Window_BattleResult TP = 1 alias battleRefresh refresh def refresh battleRefresh x = contents.text_size(@exp.to_s + "EXP" + @gold.to_s + $data_system.words.gold).width + 44 self.contents.font.color = normal_color cx = contents.text_size(TP.to_s).width self.contents.draw_text(x, 0, cx, 32, TP.to_s) x += cx + 4 self.contents.font.color = system_color cx = contents.text_size("TP").width self.contents.draw_text(x, 0, cx, 32, "TP") $game_variables[1] += 1 end end class Window_Steps < Window_Base def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 44, 32, "TP") self.contents.font.color = normal_color self.contents.draw_text(4, 32, 120, 32, $game_variables[1].to_s, 2) end end Just note that this is code would not fall under best program practices...it would be more like fewest lines possible. I would not recommend overwriting Windows_Steps if you are changing its purpose, I would simply create a new class. I also would not put any calculation in the Window class like I did. However, not knowing what battle system you are using, and if you are using a custom menu system or not, I did not want to inadvertently hose both of those! Also, I will look at the script you linked and get back to you! Share this post Link to post Share on other sites
Tenoukii 0 Report post Posted April 16, 2011 First Question = Yep, after every battle just 1. Second Question = It's like gold, but its called Trade Points (TP) and you go to a special place (ooo! sfx xD) and you trade them for limited items. Third bit about the Steps window = :S lol... the only bit I understood was from 'What battle system' onwards :D I'm using the Default menu system, and Paradog's ATB. For the script = Thank you :D it works good so far with the display thingy. For the other script = Thank you again, much appreciated ^_^ Share this post Link to post Share on other sites
Tenoukii 0 Report post Posted April 19, 2011 -Bump(Without the intention of sounding pushy ofc :D ) Share this post Link to post Share on other sites
kellessdee 48 Report post Posted April 19, 2011 It took me a second to figure out what you still needed help with :P so is it just with the book script? And if so, it can definitely be done, however how do you want it to work...first you pick tutorials/glossary, then you pick the book? If so would it look the same or do you want like a separate menu layout to pick which type then it transfers you to pick which book...If you would like a specific layout or style post it up what you are looking for. Either way, so you know, it definitely can be done Share this post Link to post Share on other sites
Tenoukii 0 Report post Posted April 20, 2011 That's awesome :D Yeah, you pick which one you want first (tutorials/glossary) from the menu, then you choose the book (so basically how it works now but two separate things) Share this post Link to post Share on other sites
kellessdee 48 Report post Posted April 21, 2011 Cool I should be able to fix something up easily...Yesterday was my celebration day so I was non-existent and didn't do anything productive hehehe; tonight after work I will probably be staying up doing nothing so I will try to get the done for ye. Share this post Link to post Share on other sites
kellessdee 48 Report post Posted April 22, 2011 Hate to double post but BOOK SCRIPT # Book Script # by kellessdee #--------------- =begin * Script reads text from book files and displays them * Each book is separated into types ----------------- * CONFIGURATION * ----------------- * The script reads from game_folder/data/books/type * TYPES : The array holding "categories" of books. If empty the script will * simply look in the books folder * EXT : The file type read from. If you do not want players to read ahead or be able to edit books, save them as .dat files and change this value to '.dat' * ----------------- =end #------------------------------------------- # ** Books Module - contains config options #------------------------------------------- module Books TYPES = ['Glossary', 'Tutorials'] EXT = '.txt' BOOKS = [] #------------------------------ # Refreshes books from folders #------------------------------ def self.refresh # clear books array BOOKS.clear # if there are more than one category of book if TYPES != [] # Split books array for each category TYPES.each_index {|i| dir = 'data/books/' + TYPES[i] + '/' BOOKS.push([]) # get each book title Dir.foreach(dir) {|book| if book != '.' && book != '..' BOOKS[i].push(book.chomp(File.extname(book))) end } } else # get each book title Dir.foreach('data/books/') {|book| if book != '.' && book != '..' BOOKS.push(book.chomp(File.extname(book))) end } end end #---------------------------- # Unlock specific book title #---------------------------- def self.unlock(title) unless $game_party.books.include?(title) $game_party.books.push(title) end end end #------------------------------------------------------ # ** Game Party Class - added unlocked books attribute #------------------------------------------------------ class Game_Party # Books array contains unlocked books attr_accessor :books # Alias initialize method to create books array alias :new_books_array_init :initialize def initialize @books = [] new_books_array_init end end #========================# # *** Window Classes *** # #========================# #------------------------------------------ # ** Window_Type - For selecting book type #------------------------------------------ class Window_Type < Window_Selectable #------------------- # Initialize Object #------------------- def initialize(x, y, commands) super(x, y, 200, commands.size * 32 + 32) self.contents = Bitmap.new(self.width - 32, commands.size * 32) self.index = 0 self.active = true @item_max = commands.size commands.each_index {|i| $game_party.books.each {|book| if Books::BOOKS[i].include?(book) self.contents.font.color = normal_color break else self.contents.font.color = disabled_color end } self.contents.draw_text(4, i * 32, self.contents.width, 32, commands[i]) } end #-------------------- # Update Help Window #-------------------- def update_help self.help_window.set_text('Select Book Category.') end end #------------------------------------- # ** Window_Book - For Selecting book #------------------------------------- class Window_Book < Window_Selectable #------------------- # Initialize Object #------------------- def initialize(x, y, books) super(x, y, 200, books.size * 32 + 32) self.contents = Bitmap.new(self.width - 32, books.size * 32) self.index = 0 self.active = true @books = books @item_max = @books.size @books.each_index {|i| self.contents.draw_text(4, i * 32, self.contents.width, 32, @books[i]) } end #------------------- # Get Selected Book #------------------- def book return @books[self.index] end #-------------------- # Update Help Window #-------------------- def update_help self.help_window.set_text('Select which book you would like to read.') end end #--------------------------------------------- # ** Window_Book_Content - Displays Book text #--------------------------------------------- class Window_Book_Content < Window_Base #----------------------- # Object Initialization #----------------------- def initialize(book, category=nil) super(0, 64, 640, 416) @text = [] dir = category == nil ? 'data/books/' : 'data/books/' + category + '/' filename = dir + book + Books::EXT file = File.open(filename, 'r') file.each_line {|line| @text.push(line)} self.contents = Bitmap.new(self.width - 32, self.height - 32) self.active = true draw_text(book) end #----------- # Draw Text #----------- def draw_text(book) # Draw Content lines = [] cur_line = '' @text.each_index {|i| words = @text[i].split words.each{|word| if (self.contents.text_size(cur_line + word).width < self.contents.width) cur_line += word cur_line += ' ' else lines.push(cur_line) cur_line = word + ' ' end } lines.push(cur_line) cur_line = '' } self.contents.dispose self.contents = Bitmap.new(self.width - 32, lines.size * 32 + 32) # Draw Title self.contents.font.bold = true self.contents.font.size = 28 self.contents.draw_text(4, 0, self.contents.width, 32, book) self.contents.font.bold = false self.contents.font.size = Font.default_size lines.each_index {|i| self.contents.draw_text(4, i * 32 + 32, self.contents.width, 32, lines[i]) } end #-------------- # Update Frame #-------------- def update # If entire book isn't displayed if self.contents.height > self.height # If down is pressed if Input.repeat?(Input::DOWN) && (self.contents.height - self.oy) >= self.height # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Scroll Window self.oy += 32 end # If up is pressed if Input.repeat?(Input::UP) && (self.oy > 0) # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Scroll Window self.oy -= 32 end # If L is pressed scroll to top if Input.trigger?(Input::L) && (self.oy > 0) # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Scroll to top of Window self.oy = 0 end # If R is pressed scroll to bottom if Input.trigger?(Input::R) && (self.contents.height - self.oy) >= self.height # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Scroll to bottom of window self.oy = self.contents.height - self.height + 32 end end end #------------- # Help Window #------------- def help_window=(help_window) @help_window = help_window # Update help text (update_help is defined by the subclasses) if self.active and @help_window != nil update_help end end #------------- # Update Help #------------- def update_help @help_window.set_text('Press Confirm/Cancel Key to Return') end end #====================# # *** Scene_Book *** # #====================# class Scene_Book #----------- # Constants #----------- TYPE = 0 BOOK = 1 READ = 2 #----------------------- # Main Processing #----------------------- def main Books.refresh # If There are categories @types_exist = Books::TYPES != [] @phase = @types_exist ? 0 : 1 # Create help window @help_window = Window_Help.new # Execute Transition Graphics.transition # Main loop loop { # Update Graphics Graphics.update # Update Input Input.update # Update scene update # if Scene has changed if $scene != self break end } # Prepare Transition Graphics.freeze @help_window.dispose end #-------------- # Update Scene #-------------- def update case @phase when TYPE if @type_window == nil start_type else update_type end return when BOOK if @book_window == nil start_book else update_book end return when READ if @text_window == nil start_read else update_read end return end end #------------------- # Start Type Select #------------------- def start_type @type_window = Window_Type.new(0, 64, Books::TYPES) @type_window.help_window = @help_window end #-------------------- # Update Type Select #-------------------- def update_type @type_window.active = true unless @type_window.active @type_window.update # If C button is pressed if Input.trigger?(Input::C) included = false # If there are any books unlocked of selected type $game_party.books.each {|book| if Books::BOOKS[@type_window.index].include?(book) included = true break end } if !included # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to book selection @phase = BOOK @type = @type_window.index @type_window.active = false return end # If B button is pressed if Input.trigger?(Input::B) # Play Cancel SE $game_system.se_play($data_system.cancel_se) # Dispose Window @type_window.dispose # Return to map $scene = Scene_Map.new return end end #------------------- # Start Book Select #------------------- def start_book books = [] if @types_exist $game_party.books.each {|book| if Books::BOOKS[@type].include?(book) books.push(book) end } else books = $game_party.books end @book_window = Window_Book.new(0, 64, books) @book_window.z += 100 @book_window.help_window = @help_window end #-------------------- # Update Book Select #-------------------- def update_book @book_window.active = true unless @book_window.active @book_window.update # if C button is pressed if Input.trigger?(Input::C) # play Decision SE $game_system.se_play($data_system.decision_se) # read book @phase = READ @book_window.active = false return end # if B button is pressed if Input.trigger?(Input::B) # play cancel SE $game_system.se_play($data_system.cancel_se) # if types exist if @types_exist # return to type menu @phase = TYPE @book_window.dispose @book_window = nil return else # return to Map scene @book_window.dispose $scene = Scene_Map.new return end end end #-------------------- # Start Book Reading #-------------------- def start_read if @types_exist @text_window = Window_Book_Content.new(@book_window.book, Books::TYPES[@type]) else @text_window = Window_Book_Content.new(@book_window.book) end @text_window.z += 200 @text_window.help_window = @help_window end #--------------------- # Update Book Reading #--------------------- def update_read @text_window.update # if B button is pressed if Input.trigger?(Input::B) || Input.trigger?(Input::C) # Play cancel SE $game_system.se_play($data_system.cancel_se) # return to book selection @phase = BOOK @text_window.dispose @text_window = nil return end end end I made my own script, I think I made it a little easier to use; simply copy and paste above main. To use it simply go to the game folder, go into data and create a folder called Books and in that folder create one folder called Glossary and one folder called Tutorials. Then just create your glossary text files and tutorial text files, and place them in the corresponding folders (the script will read the files in these folders by name and display them if they are unlocked) To call the script, just use $scene = Scene_Book.new to unlock books, use Books.unlock('name') name is the name of the file without the extension (keep the name within single-quotes) Also, I added the ability (if you would like to) to use different file types...so for example say you didn't want players reading ahead, you can write the book text then save as a .dat file. then within the first part of the script change EXT = '.txt' to EXT = '.dat' and it will read the dat files rather than txt files. NOTE: The files won't be truly encrypted...players will still be able to reconvert the files to .txt, but most players will probably not realize it is that simple and just won't try to mess with the files. Tell me if there's any changes you need done Share this post Link to post Share on other sites
Tenoukii 0 Report post Posted May 2, 2011 This is a bit late :sweatdrop: but oh well (: The script is awesome functionally, but could you possibly change it visually? So it looks like this: http://s1199.photobucket.com/albums/aa476/bluecrystalis94/?action=view¤t=menudiag.png (It won't let me put the picture here... sorry :( ) (The powers of paint ^_^ ) The text in the long menu doesn't appear until you've chosen to book to read, and the text on the title bar thing changes from "Select Book to read" to "Select Chapter" (not what it says on the picture :P ) And all of the 4 windows stay open through the whole thing. Thats all the changes I would like (: Thank you! P.s: Has there been any development on the junctioning script? :sweatdrop: Share this post Link to post Share on other sites
kellessdee 48 Report post Posted May 2, 2011 I can modify it easily! It's a simple fix. I was just playin with a layout lol. And about the junctioning script; I am REALLY sorry, I actually forgot about that :sweatdrop: I'll message you once I get that done Share this post Link to post Share on other sites
Tenoukii 0 Report post Posted May 2, 2011 Ha.. its okay (: I found a really good one that was basically identical and would only need the mods so that it only applied to the two characters, but it was for VX D: But no rush (: I'm trying to work a bit more on the actual game rather than the scripts atm (: Share this post Link to post Share on other sites
kellessdee 48 Report post Posted May 5, 2011 # Book Script # by kellessdee #--------------- =begin * Script reads text from book files and displays them * Each book is separated into types ----------------- * CONFIGURATION * ----------------- * The script reads from game_folder/data/books/type * TYPES : The array holding "categories" of books. * EXT : The file type read from. If you do not want players to read ahead or be able to edit books, save them as .dat files and change this value to '.dat' * ----------------- =end #------------------------------------------- # ** Books Module - contains config options #------------------------------------------- module Books TYPES = ['Glossary', 'Tutorials'] EXT = '.dat' BOOKS = [] #------------------------------ # Refreshes books from folders #------------------------------ def self.refresh # clear books array BOOKS.clear # if there are more than one category of book if TYPES != [] # Split books array for each category TYPES.each_index {|i| dir = 'data/books/' + TYPES[i] + '/' BOOKS.push([]) # get each book title Dir.foreach(dir) {|book| if book != '.' && book != '..' BOOKS[i].push(book.chomp(File.extname(book))) end } } else # get each book title Dir.foreach('data/books/') {|book| if book != '.' && book != '..' BOOKS.push(book.chomp(File.extname(book))) end } end end #---------------------------- # Unlock specific book title #---------------------------- def self.unlock(title) unless $game_party.books.include?(title) $game_party.books.push(title) end end end #------------------------------------------------------ # ** Game Party Class - added unlocked books attribute #------------------------------------------------------ class Game_Party # Books array contains unlocked books attr_accessor :books # Alias initialize method to create books array alias :new_books_array_init :initialize def initialize @books = [] new_books_array_init end end #========================# # *** Window Classes *** # #========================# #------------------------------------------ # ** Window_Type - For selecting book type #------------------------------------------ class Window_Type < Window_Selectable #------------------- # Initialize Object #------------------- def initialize(x, y, commands) super(x, y, 200, 96) self.contents = Bitmap.new(self.width - 32, commands.size * 32) self.index = 0 self.active = true @item_max = commands.size commands.each_index {|i| $game_party.books.each {|book| if Books::BOOKS[i].include?(book) self.contents.font.color = normal_color break else self.contents.font.color = disabled_color end } self.contents.draw_text(4, i * 32, self.contents.width, 32, commands[i]) } end #-------------------- # Update Help Window #-------------------- def update_help self.help_window.set_text('Select Book to Read') end end #------------------------------------- # ** Window_Book - For Selecting book #------------------------------------- class Window_Book < Window_Selectable #------------------- # Initialize Object #------------------- def initialize(x, y, books) super(x, y, 200, 320) self.contents = Bitmap.new(self.width - 32, books.size * 32) self.index = 0 self.active = true @books = books @item_max = @books.size @books.each_index {|i| self.contents.draw_text(4, i * 32, self.contents.width, 32, @books[i]) } end #------------------- # Get Selected Book #------------------- def book return @books[self.index] end #-------------------- # Update Help Window #-------------------- def update_help self.help_window.set_text('Select Chapter') end end #--------------------------------------------- # ** Window_Book_Content - Displays Book text #--------------------------------------------- class Window_Book_Content < Window_Base #----------------------- # Object Initialization #----------------------- def initialize(book, category=nil) super(200, 64, 440, 416) @text = [] dir = category == nil ? 'data/books/' : 'data/books/' + category + '/' filename = dir + book + Books::EXT file = File.open(filename, 'r') file.each_line {|line| @text.push(line)} self.contents = Bitmap.new(self.width - 32, self.height - 32) self.active = true draw_text(book) end #----------- # Draw Text #----------- def draw_text(book) # Draw Content lines = [] cur_line = '' @text.each_index {|i| words = @text[i].split words.each{|word| if (self.contents.text_size(cur_line + word).width < self.contents.width) cur_line += word cur_line += ' ' else lines.push(cur_line) cur_line = word + ' ' end } lines.push(cur_line) cur_line = '' } self.contents.dispose self.contents = Bitmap.new(self.width - 32, lines.size * 32 + 32) # Draw Title self.contents.font.bold = true self.contents.font.size = 28 self.contents.draw_text(4, 0, self.contents.width, 32, book) self.contents.font.bold = false self.contents.font.size = Font.default_size lines.each_index {|i| self.contents.draw_text(4, i * 32 + 32, self.contents.width, 32, lines[i]) } end #-------------- # Update Frame #-------------- def update # If entire book isn't displayed if self.contents.height > self.height # If down is pressed if Input.repeat?(Input::DOWN) && (self.contents.height - self.oy) >= self.height # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Scroll Window self.oy += 32 end # If up is pressed if Input.repeat?(Input::UP) && (self.oy > 0) # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Scroll Window self.oy -= 32 end # If L is pressed scroll to top if Input.trigger?(Input::L) && (self.oy > 0) # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Scroll to top of Window self.oy = 0 end # If R is pressed scroll to bottom if Input.trigger?(Input::R) && (self.contents.height - self.oy) >= self.height # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Scroll to bottom of window self.oy = self.contents.height - self.height + 32 end end end #------------- # Help Window #------------- def help_window=(help_window) @help_window = help_window # Update help text (update_help is defined by the subclasses) if self.active and @help_window != nil update_help end end #------------- # Update Help #------------- def update_help @help_window.set_text('Press Confirm/Cancel Key to Return') end end #====================# # *** Scene_Book *** # #====================# class Scene_Book #----------------------- # Main Processing #----------------------- def main Books.refresh # Create help window @help_window = Window_Help.new # Create all windows @type_window = Window_Type.new(0, 64, Books::TYPES) @book_window = Window_Base.new(0, 160, 200, 320) @text_window = Window_Base.new(200, 64, 440, 416) @type_window.active = true @book_window.active = false @text_window.active = false @type_window.help_window = @help_window # Execute Transition Graphics.transition # Main loop loop { # Update Graphics Graphics.update # Update Input Input.update # Update scene update # if Scene has changed break if $scene != self } # Prepare Transition Graphics.freeze @help_window.dispose @type_window.dispose @text_window.dispose @book_window.dispose end #-------------- # Update Scene #-------------- def update if @type_window.active @type_window.update update_type return elsif @book_window.active @book_window.update update_book return elsif @text_window.active @text_window.update update_read return end end #-------------------- # Update Type Select #-------------------- def update_type # If C button is pressed if Input.trigger?(Input::C) included = false # If there are any books unlocked of selected type $game_party.books.each {|book| if Books::BOOKS[@type_window.index].include?(book) included = true break end } if !included # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) @type = @type_window.index @type_window.active = false start_book return end # If B button is pressed if Input.trigger?(Input::B) # Play Cancel SE $game_system.se_play($data_system.cancel_se) # Return to map $scene = Scene_Map.new return end end #------------------- # Start Book Select #------------------- def start_book books = [] $game_party.books.each {|book| if Books::BOOKS[@type].include?(book) books.push(book) end } @book_window.dispose @book_window = Window_Book.new(0, 160, books) @book_window.active = true @book_window.help_window = @help_window end #-------------------- # Update Book Select #-------------------- def update_book # if C button is pressed if Input.trigger?(Input::C) # play Decision SE $game_system.se_play($data_system.decision_se) @book_window.active = false start_read return end # if B button is pressed if Input.trigger?(Input::B) # play cancel SE $game_system.se_play($data_system.cancel_se) # Return to type window @type_window.active = true @book_window.active = false @type_window.help_window = @help_window @book_window.contents.clear @book_window.cursor_rect.empty return end end #-------------------- # Start Book Reading #-------------------- def start_read @text_window.dispose @text_window = Window_Book_Content.new(@book_window.book, Books::TYPES[@type]) @text_window.active = true @text_window.help_window = @help_window end #--------------------- # Update Book Reading #--------------------- def update_read # if B button is pressed if Input.trigger?(Input::B) || Input.trigger?(Input::C) # Play cancel SE $game_system.se_play($data_system.cancel_se) @text_window.dispose @text_window = Window_Base.new(200, 64, 440, 416) @text_window.active = false @book_window.active = true @book_window.help_window = @help_window return end end end fixed the layout! Lemme know if you need any changes. I will PM you about the junction script for specifications Share this post Link to post Share on other sites