Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################################################################################
- # Gamepedia 1.0
- # By: Ixfuru
- ################################################################################
- ################################################################################
- #
- # This script creates a scene of selectable windows that can display
- # information that you supply it. It would be ideal for creating a how to guide,
- # or a good place to put credits. You can basically use it as you wish, but I
- # created it as a personal need to provide an 'encyclopedia' for my project,
- # where one can look up and reference abbreviations, controls and other such
- # items that the player may need without the aid of an instruction manual.
- # Follow the instructions in each section within the "CUSTOMIZATION SECTION"s to
- # set up what you want displayed. I'll be using not only layman's terms for
- # those who want to 'use' the script, but I'll try to add some scripting info
- # as well so that someone who wants to add on to it, or get an idea from it, will
- # understand how I did the things I did.
- #
- # To call the scene, you just use the 'script' command on the third page inside
- # an event and enter:
- #
- # $scene = Scene_Gamepedia.new
- #
- ################################################################################
- #
- ################################################################################
- # THIS SCRIPT REQUIRES ModernAlgebra's ParagraphFormatter Script, which
- # can be found here:
- #
- # http://rmrk.net/index.php/topic,25129.0.html
- #
- # You must abide by the rules and license statement on this page if you use his
- # script in conjunction with this one.
- ################################################################################
- #*******************************************************************************
- #
- # You can use this script for free NON-COMMERCIALLY. If you intend to market
- # your project and want to include my script, please just give credit to IXFURU
- # somewhere in the game (Maybe in the Gamepedia) and contact me to discuss
- # if any compensation would be necessary.
- #
- #*******************************************************************************
- #*******************************************************************************
- # OTHER CREDITS:
- # LoganF was a great help with two of the lingering bugs in the script.
- # ThallionDarkshine, Heretic86 and Mangomight for offering their assistance on
- # the some bugs, as well.
- #
- # ModernAlgebra for his Paragraph Formatter script, without which, the Entries
- # window is not functional.
- #
- # A sample windowskin by Cassy was used to show the capability to show different
- # skins in the scene. If you use this skin in your project, you must credit her.
- #
- # Here is a link to her other skins:
- #
- # http://www.rpgmakervx.net/index.php?showtopic=7859
- #
- #*******************************************************************************
- module GAMEPEDIA
- ##############################################################################
- # CUSTOMIZATION SECTION START
- ##############################################################################
- #************* PHAZE 1 *********************
- # The first order of business is to add strings as "Subjects". These strings
- # will be visible as selectable options in the Gamepedia scene. Each 'Subject'
- # will have a number of child 'Topics' which you will set up later. For this
- # section, just add to the given array below with double-quoted (") words
- # (strings). The order in which these subjects are placed will not only be
- # important in the rest of the setup, but will be referenced as selectable
- # indexes in the scene.
- #*****************************************************************************
- SUBJECTS = ["ANIMALS", "FOOD", "SPORTS", "CREDITS"]
- #************* PHAZE 2 *********************
- # Next, you need to set up the 'Topics' in the below hash. You must use the
- # following formula to set it up:
- #
- # subject_position => [topic1, topic2, etc],
- #
- # subject_position:
- #
- # This is where you will reference the subjects in the first
- # array above. As all arrays start with 0, not 1, you'll need to use '0' as
- # your subject_position. The word position was given to show that you are in
- # essence taking the subject in the array above from the given position in the
- # array. The topics will change in the Gamepedia scene, according to which
- # subject is highlighted.
- #
- # topics:
- # You can place anything as the topics in the array, as long as they
- # are double-quoted. These will be the selectable options in the Topics
- # selectable window in the scene. Their order in the array will also be
- # the order in which they are displayed.
- #
- # It is important that you END EVERY ARRAY with a comma (,).
- #*****************************************************************************
- TOPICS = {#<<<Don't delete this!
- 0 => ["DOGS", "CATS", "CROWS", "SALAMANDERS", "FROGS"],
- 1 => ["APPLES", "ORANGES", "ICE CREAM"],
- 2 => ["FOOTBALL", "BASEBALL", "BOXING", "BASKETBALL", "BOWLING", "MARTIAL ARTS"],
- 3 => ["SCRIPT HELP", "MAD GENIUSES", "REQUIREMENTS"]
- }#<<<Don't delete this!
- #************* PHAZE 3 *********************
- # This section enables you to set up the displayable text (or information)
- # about the selected topic in the Gamepedia scene. In the hash, you need to
- # add a single string, which will then be shown in the large window. This
- # will be the guts of the Gamepedia scene, where you set up just what you want
- # to display. Though there is no limit to the amount of words or characters
- # one can use in the string, you'll need to remember, it must be double-quoted
- # and end in a comma, like before. In addition, the ids (number to the left of
- # the "=>"), should be in numerical order and all displayable text should be
- # kept in the order of the topics above. For instance, if you have the topic
- # set up as follows:
- #
- # 0 => [stuff, morestuff, scratches_head],
- # 1 => [people, chicks, more_chicks],
- #
- # You would then want to set up the ENTRIES in the same order. Like this:
- #
- # 0 => stuff about stuff
- # 1 => more stuff about more stuff
- # 2 => why are you scratching your head
- # 3 => talk about people
- # 4 => talking about chicks
- # 5 => chicks rule!
- #
- # This will make more sense in the next phaze. But this is VERY IMPORTANT.
- # Failure to follow these guidelines will cause displayed text to not match the
- # selected topic. It may wise to place commented divider lines between the
- # displays for each topic. So the above would look more like this:
- #
- # 0 => stuff about stuff
- # 1 => more stuff about more stuff
- # 2 => why are you scratching your head
- #--------------------2-----------------------
- # 3 => talk about people
- # 4 => talking about chicks
- # 5 => chicks rule!
- #
- # That way, you would be sure you were adding the displayable entires for section
- # 2 in the correct location.
- #*****************************************************************************
- ENTRIES = {#<<<Don't delete this!
- #---------------------ANIMAL TOPICS------------------------------------------
- 0 => "The first pet I can remember having when I was a kid was a dog named GYPSY. GYPSY helped me and my siblings escape a horse which was chasing us. Ultimately, GYPSY got really sick and died.",
- 1 => "We had a cat once named MOSES. It was an all-black cat. It had big green eyes. We named it MOSES, yet after several months, it became obvious, MOSES was a girl! We never considered changing her name.",
- 2 => "I've always liked Crows. As Poe was the Raven, I have always considered myself a vast pupil of his, and likened myself a crow. I even made a project once about a Red Crow.",
- 3 => "I found a salamander one day while termite treating a house. I took the salamader home. Me and my brother built a box to keep it in. I thought the light was too bright. Only a day after we made the box, he disappeared. Either he escaped, or fizzled away from the heat of the overhead light.",
- 4 => "I had a shirt once that said, Frogs are the birds of the night. They give it a voice. I've always liked frogs because of that. On a side note, never dump your grease from fried frog legs on a bush outside your home.",
- #---------------------FOOD TOPICS----------------------------------------
- 5 => "Apples are pretty good. However, whoever decided to couple them with cinamon, needs shot. There's no worse pop tart on the market, and no two flavors together have ever turned my taste buds inside out more.",
- 6 => "The best way to enjoy an orange is in drink form. The wife and I had screwdrivers on our honeymoon. But I forget what happened after that.",
- 7 => "Ice Cream is perhaps the greatest of all desserts. As long as it isn't Apple Cinamon.",
- #-------------------SPORTS TOPICS--------------------------------------------------
- 8 => "There's no sport better than American Football. There's no team I love more than the Cleveland Browns. One day, maybe we'll make it to the Superbowl. Then the rest of the league will quit ignoring us.",
- 9 => "When I was a kid, I loved to play baseball. I played everyday. I watched the Indians every night I could. And I played on the local little league teams during their seasons. I was a pitcher and a firstbaseman.",
- 10 => "Why is it that there are no good American Heavyweights anymore? Back in the day, you had Foreman, Tyson, Holyfield, Bowe and countless others. Now, The Europeans put out much better Heavyweights.",
- 11 => "I've never liked Basketball very much. I was never very good at it. And I think the games a little too simple for my taste.",
- 12 => "Is bowling even a sport? I dont know, but I sure love to bowl. I'm no good at it, but I love it just the same. I think my high score is like a 140-something.",
- 13 => "Martial Arts are cool. I like the UFC and MMA in general. What I don't like however, is when they just lay on each other for 15 minutes. That sucks!",
- #-----------------CREDITS TOPICS----------------------------------------------
- 45 => "Gotta give some credit to those who helped me with this script. Whether their assistance ended up being useful or not. Sometimes overlooked is the amount of time it takes just to TRY and help someone. I appreciate it LoganF, Mangomight, Heretic60, ThallionDarkshine and Hungrysnake.",
- 109 => "I've seen a lot of good VX scripts. I just want to mention a few of my favorites. One of whom's scripts is a necessity for this script. ModernAlgebra, Jet, Yanfly and ???noBody???",
- 16 => "I require many things. One of the things I require the most is Pepsi. I also require (though I wish I could quit) Camel Lights. RPGMaker is a bit of a requirement, too.",
- }#<<<Don't delete this!
- #************* PHAZE 4 *********************
- # In this phaze you will reference the subjects, by their positions, (just like
- # in the TOPICS hash, and you will then give a high and lo value following a
- # boolean (true or false). Now, if you've followed directions precisely, you
- # should be able to place 'true' as the boolean in the first position of all
- # the following inner-hash arrays. However, just because I know that some
- # may have made an error, or wish to add more entries later, I wanted to add
- # some type of solution to get you out of a jam without having to re-order
- # the entries above. Here's how this all comes together:
- #
- # subject_position => [boolean true, low, high] or
- # subject_position => [boolean false, entry1, entry2, entry3, etc.]
- #
- # You place the values just like you did in the topics, telling the system that
- # the entries in this range are to be shown when a topic in this subject is
- # selected.
- # Next, the boolean will be the answer to the following question for each
- # subject:
- # "Are the entries in the same order as their topics?"
- # If you answer the question, "yes", then you want to place true, if "no", you'll
- # put false.
- # Low and High are values between and including the entry ids above where the
- # system will search for the displayable text information. If you select true
- # for your boolean, then the system will display the text in numerical order
- # pertaining to which ever topic you have currently selected.
- # If by chance you used 'false' as your boolean, any following values will be
- # direct reference to specific entries. If this is your setup:
- #
- # credits => [false, 7, 12, 3, 5, 9],
- #
- # Then as you move the cursor down the selected topics, it will jump to the
- # values you provided dependent upon index. entry 7 will be displayed when
- # the cursor is in index position 0, entry 12 will be displayed when in index
- # 1, and so on...
- #
- #*****************************************************************************
- ENTRY_INDEXES = {#<<<Don't delete this!
- 0 => [true, 0, 4],
- 1 => [true, 5, 7],
- 2 => [true, 8, 13],
- 3 => [false, 45, 109, 16], # This line demonstrates that you don't have to have
- # the topics in any particular order.
- }#<<<Don't delete this
- #************* PHAZE 5 *********************
- # The last part of the customization just allows you to change trivial values
- # that will be used in deciding colors and text during the scene.
- #*****************************************************************************
- ENCYCLOPEDIA_TITLE = "GAMEPEDIA"
- TITLE_COLOR = 14
- TOPIC_HEADING_COLOR = 27
- NEW_WINDOWSKIN = true #Set to false if you just want to use the project's default skin
- GP_WINDOWSKIN = "CassyOldWoodSkin" #You MUST credit "Cassy" if you use this skin
- ##############################################################################
- # CUSTOMIZATION SECTION END
- # If you alter anything below this point, you risk screwing things up.
- ##############################################################################
- end
- ################################################################################
- # Gamepedia Class
- ################################################################################
- class Gamepedia
- include GAMEPEDIA
- attr_accessor :subjects
- attr_accessor :topics
- attr_accessor :entries
- def initialize
- @subjects = SUBJECTS
- @topics = TOPICS
- end
- def get_entries(subject) #receives the value from the current subject index.
- entdex = ENTRY_INDEXES
- entkeys = ENTRIES.keys
- subnow = subject
- tempent = []
- if entdex[subnow][0] == true
- lo = entdex[subnow][1]
- hi = entdex[subnow][2]
- for i in lo..hi
- tempent.push(i)
- end
- @entries = tempent
- @entries.sort
- else
- get_jumbled_entries(subnow)
- end
- end
- # This method retrieves displayable text from topics whose text is not in order
- def get_jumbled_entries(subject)
- entdex = ENTRY_INDEXES
- entkeys = ENTRIES.keys
- subnow = subject
- tempent = []
- for key in entkeys
- if entdex[subnow].include?(key)
- tempent.push(key)
- end
- end
- @entries = tempent
- end
- end
- ################################################################################
- # GAME TEMP
- ################################################################################
- class Game_Temp
- attr_accessor :last_pediasubject
- alias nqenc_gtemp_initialize initialize unless $@
- def initialize
- nqenc_gtemp_initialize
- @last_pediasubject = 0
- end
- end
- ################################################################################
- # WINDOW: SUBJECTS COMMANDS
- ################################################################################
- class Window_PediaSubjects < Window_Selectable
- include GAMEPEDIA
- def initialize(x, y)
- super(x, y, 120, 416)
- @item_max = $gamepedia.subjects.size
- @commands = $gamepedia.subjects
- if NEW_WINDOWSKIN
- self.windowskin = Cache.system(GP_WINDOWSKIN)
- end
- refresh
- self.index = $game_temp.last_pediasubject
- end
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- def draw_item(index, enabled = true)
- rect = item_rect(index)
- rect.x += 4
- rect.width -= 8
- self.contents.font.color = normal_color
- self.contents.font.size = 12
- self.contents.draw_text(rect, @commands[index])
- end
- end
- ################################################################################
- # WINDOW: TOPICS COMMANDS
- ################################################################################
- class Window_PediaTopics < Window_Selectable
- include GAMEPEDIA
- attr_writer :item_max
- attr_writer :commands
- def initialize(x, y)
- super(x, y, 120, 416)
- @item_max = $gamepedia.topics[$game_temp.last_pediasubject].size
- @commands = $gamepedia.topics[$game_temp.last_pediasubject]
- if NEW_WINDOWSKIN
- self.windowskin = Cache.system(GP_WINDOWSKIN)
- end
- refresh
- self.index = 0
- end
- def refresh
- create_contents
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- def change_commands(subject)
- @item_max = $gamepedia.topics[subject].size
- @commands = $gamepedia.topics[subject]
- end
- def draw_item(index, enabled = true)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- rect.x += 4
- rect.width -= 8
- self.contents.font.color = normal_color
- self.contents.font.size = 12
- self.contents.draw_text(rect, @commands[index])
- end
- end
- ################################################################################
- # WINDOW: VIEW TOPIC
- ################################################################################
- class Window_PediaViewTopic < Window_Base
- include GAMEPEDIA
- def initialize(x, y, heading, entry)
- super(x, y, 304, 346)
- @heading = heading
- @entry = entry
- if NEW_WINDOWSKIN
- self.windowskin = Cache.system(GP_WINDOWSKIN)
- end
- refresh
- end
- def refresh
- self.contents.clear
- self.contents.font.size = 14
- self.contents.font.color = text_color(TOPIC_HEADING_COLOR)
- self.contents.draw_text(-16, 0, self.width, WLH, @heading, 1)
- self.contents.font.size = 12
- self.contents.font.color = normal_color
- self.contents.draw_paragraph (0, WLH, self.width - 50, self.height, @entry)
- end
- def change_heading(heading)
- @heading = heading
- end
- def change_text(entry)
- @entry = entry
- end
- end
- ################################################################################
- # WINDOW: ENCYCLOPEDIA TITLE
- ################################################################################
- class Window_PediaTitle < Window_Base
- include GAMEPEDIA
- def initialize(x, y)
- super(x, y, 304, 70)
- if NEW_WINDOWSKIN
- self.windowskin = Cache.system(GP_WINDOWSKIN)
- end
- refresh
- end
- def refresh
- et = ENCYCLOPEDIA_TITLE
- self.contents.clear
- self.contents.font.color = text_color(TITLE_COLOR)
- self.contents.draw_text(-16, 0, self.width, WLH, et, 1)
- end
- end
- ################################################################################
- # SCENE: TITLE
- ################################################################################
- class Scene_Title < Scene_Base
- alias nq_st_create_game_objects create_game_objects
- def create_game_objects
- nq_st_create_game_objects
- $gamepedia = Gamepedia.new
- end
- end
- ################################################################################
- # SCENE: FILE
- ################################################################################
- class Scene_File < Scene_Base
- alias nq_sfile_write_save_data write_save_data
- def write_save_data(file)
- nq_sfile_write_save_data(file)
- Marshal.dump($gamepedia, file)
- end
- alias nq_sfile_read_save_data read_save_data
- def read_save_data(file)
- nq_sfile_read_save_data(file)
- $gamepedia = Marshal.load(file)
- end
- end
- ################################################################################
- # SCENE: ENCYCLOPEDIA
- ################################################################################
- class Scene_Gamepedia < Scene_Base
- include GAMEPEDIA
- def start
- super
- create_menu_background
- @win_title = Window_PediaTitle.new(241, 0)
- @win_subjects = Window_PediaSubjects.new(0, 0)
- @win_topics = Window_PediaTopics.new(121, 0)
- get_current_heading
- get_current_entry
- @win_viewtopic = Window_PediaViewTopic.new(241, 71, @cur_head, @cur_entry)
- @win_topics.active = false
- @win_subjects.active = true
- end
- #-----------------------------------------------------------------------------
- # Get Current Entry Heading
- #-----------------------------------------------------------------------------
- def get_current_heading
- @cur_head = $gamepedia.topics[@win_subjects.index][@win_topics.index]
- end
- #-----------------------------------------------------------------------------
- # Get Current Entry Text
- #-----------------------------------------------------------------------------
- def get_current_entry
- $gamepedia.get_entries(@win_subjects.index)
- @cur_entry = ENTRIES[$gamepedia.entries[@win_topics.index]]
- end
- #-----------------------------------------------------------------------------
- # Update
- #-----------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @win_title.refresh
- if @win_subjects.active
- @win_topics.change_commands(@win_subjects.index)
- @win_topics.refresh
- get_current_heading
- get_current_entry
- @win_viewtopic.change_heading(@cur_head)
- @win_viewtopic.change_text(@cur_entry)
- @win_viewtopic.refresh
- update_subject_selection
- elsif @win_topics.active
- @win_topics.refresh
- get_current_heading
- get_current_entry
- @win_viewtopic.change_heading(@cur_head)
- @win_viewtopic.change_text(@cur_entry)
- @win_viewtopic.refresh
- update_topic_selection
- end
- @win_subjects.update
- @win_topics.update
- end
- #-----------------------------------------------------------------------------
- # Activate Topics Window
- #-----------------------------------------------------------------------------
- def activate_topics
- @win_subjects.active = false
- $game_temp.last_pediasubject = @win_subjects.index
- @win_topics.active = true
- end
- #-----------------------------------------------------------------------------
- # Activate Subjects Window
- #-----------------------------------------------------------------------------
- def activate_subjects
- @win_topics.active = false
- @win_topics.index = 0
- @win_subjects.index = $game_temp.last_pediasubject
- @win_subjects.active = true
- end
- #-----------------------------------------------------------------------------
- # Update Subject Selection
- #-----------------------------------------------------------------------------
- def update_subject_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- $scene = Scene_Map.new
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- activate_topics
- end
- end
- #-----------------------------------------------------------------------------
- # Update Topic Selection
- #-----------------------------------------------------------------------------
- def update_topic_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- activate_subjects
- end
- end
- #-----------------------------------------------------------------------------
- # Terminate
- #-----------------------------------------------------------------------------
- def terminate
- @win_title.dispose
- @win_subjects.dispose
- @win_topics.dispose
- @win_viewtopic.dispose
- end
- end
Add Comment
Please, Sign In to add comment