设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 135|回复: 0

[转载发布] Window_Book v3.0 (First Standalone Public Release)

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-7-31 13:49:39 | 显示全部楼层 |阅读模式
    Window Book v3.0
    by Enelvon


    Introduction
    This script is essentially a scripter's resource, but it has been optimized for use by those with little-to-no experience in scripting. It provides a parent class for multi-page windows, with a focus on those used to display information (though it is also possible, with some additions, to include pages with selectable areas). Its write_page_text method draws text in a similar manner to the draw_text_ex method, allowing you to use any control character that you would normally use in game text (with the exception of those that control timing). Further down, I have included a tutorial on creating a basic guide to a game's controls as an example of a simple use of the script. By reading the tutorial, a non-scripter can learn how to easily create and call a book window. I had a non-scripter friend try it out, and within ten minutes they had written a functional battle guide. Try it out and see what you can make!

    Usage
    In most cases, this is just going to be a superclass for other scripts. If you are interested in learning how to use it to make something yourself, refer to the tutorial in the spoiler below.

    SpoilerThis script serves as a resource to create multi-page windows. I will use this space to give an example of how to make and display a simple book that contains the controls for the game.

    The first thing that we have to do is create a new window class. Let's call it Guide.
     

    class Guide < Window_BookOkay, so we've opened our class. Now we need to define our initialize method. It will contain our definition of @pagetext.
     

    class Guide < Window_Book  def initialize    @pagetext = {      2 => ["In this mini guide you will be given a basic introduction to playing the game. I hope it proves informative."],      3 => ["\\c[16]Button Controls:", "", "\\c[16]Movement:",              "Use the direction keys to move your character on the map, and your cursor when in menus. Hold down Shift to run. When you are in a character-related menu, you can use Q, W, PgDn, and PgUp to move between characters.",               "", "\\c[16]Opening the Menu:",               "Press X, 0 on the number pad, or Esc to open the menu when you are on the map.",               "", "\\c[16]Selection:",               "Press Z, Space or Enter to interact with characters and items on the map, or to make a selection when in a menu.",               "", "\\c[16]Cancelling:",               "Press X, 0 on the number pad, or Esc to go back in a menu or cancel a choice."],      4 => ["\\c[16]File Operations:", "", "\\c[16]Saving Your Game:",               "Select \\c[16]Save \\c[0]from the in-game menu and choose a slot in which to save your game.",               "", "\\c[16]Loading Your Game:",               "If you are currently in the game, return to the title screen. Select \\c[16]Load Game \\c[0]and choose the slot you want to load."],      5 => ["Have fun, and good luck!"]    }    super  endSorry about how long those text lines are, but going down to a new line and having indentations causes the formatting to be hideous when the text is drawn. Anyway, as you can see, we're able to use control characters from the game's message windows in our text. Always make sure to use two (rather than one) backslashes for the control character, and that it is attached to the first word/character that it is intended to affect. I skipped page 1 because we'll do that a little differently - we're going to center the text for it and place it near the top of the page, as it's the cover of the book.
     

    class Guide < Window_Book  def initialize    @pagetext = {      2 => ["In this mini guide you will be given a basic introduction to playing the game. I hope it proves informative."],      3 => ["\\c[16]Button Controls:", "", "\\c[16]Movement:",              "Use the direction keys to move your character on the map, and your cursor when in menus. Hold down Shift to run. When you are in a character-related menu, you can use Q, W, PgDn, and PgUp to move between characters.",               "", "\\c[16]Opening the Menu:",               "Press X, 0 on the number pad, or Esc to open the menu when you are on the map.",               "", "\\c[16]Selection:",               "Press Z, Space or Enter to interact with characters and items on the map, or to make a selection when in a menu.",               "", "\\c[16]Cancelling:",               "Press X, 0 on the number pad, or Esc to go back in a menu or cancel a choice."],      4 => ["\\c[16]File Operations:", "", "\\c[16]Saving Your Game:",               "Select \\c[16]Save \\c[0]from the in-game menu and choose a slot in which to save your game.",               "", "\\c[16]Loading Your Game:",               "If you are currently in the game, return to the title screen. Select \\c[16]Load Game \\c[0]and choose the slot you want to load."],      5 => ["Have fun, and good luck!"]    }    super  end   def draw_page1    x = (contents_width - text_size("Game Guide").width) / 2    y = (contents_height - line_height) / 4    draw_text_ex(x, y, "\\c[14]Game Guide")  endHere we find the center of the book page horizontally and 1/4 of the page vertically, then draw the text there. Now we have five pages in our book (four in the @pagetext hash and one defined explicitly), so the next thing we should do is define max_pages.
     

    class Guide < Window_Book  def initialize    @pagetext = {      2 => ["In this mini guide you will be given a basic introduction to playing the game. I hope it proves informative."],      3 => ["\\c[16]Button Controls:", "", "\\c[16]Movement:",              "Use the direction keys to move your character on the map, and your cursor when in menus. Hold down Shift to run. When you are in a character-related menu, you can use Q, W, PgDn, and PgUp to move between characters.",               "", "\\c[16]Opening the Menu:",               "Press X, 0 on the number pad, or Esc to open the menu when you are on the map.",               "", "\\c[16]Selection:",               "Press Z, Space or Enter to interact with characters and items on the map, or to make a selection when in a menu.",               "", "\\c[16]Cancelling:",               "Press X, 0 on the number pad, or Esc to go back in a menu or cancel a choice."],      4 => ["\\c[16]File Operations:", "", "\\c[16]Saving Your Game:",               "Select \\c[16]Save \\c[0]from the in-game menu and choose a slot in which to save your game.",               "", "\\c[16]Loading Your Game:",               "If you are currently in the game, return to the title screen. Select \\c[16]Load Game \\c[0]and choose the slot you want to load."],      5 => ["Have fun, and good luck!"]    }    super  end   def draw_page1    x = (contents_width - text_size("Game Guide").width) / 2    y = (contents_height - line_height) / 4    draw_text_ex(x, y, "\\c[14]Game Guide")  end  def max_pages; 5; endendThere we go! As you can see, I ended the Guide class after defining max_pages. Why? Because it's done! We created a five-page book in 20 lines, and 7 of those were used to define the contents of the pages! Isn't that easy?

    We're not quite done, though. We have one more task ahead of us: calling the window for display. Prior to version 1.3, this had to be done by creating a new class and calling that. 1.3 introduced the Scene_Book class, which simplified this for basic users - advanced books will still need their own classes if they're going to be used for anything but simple reading. To call the default book scene with the guide, put this in an event:
     

    show_book(Guide, Scene_Map)That will display the book, as I've added the show_book command to the Game Interpreter class. You could also use this:
     

    SceneManager.goto(Scene_Book)SceneManager.scene.set_book(Guide, Scene_Map)show_book is a little faster, though. You can replace Guide with the name of your book to show whatever you'd like - let's say we have a book window named Biology_Textbook. We would use this:
     

    show_book(Biology_Textbook, Scene_Map)Note that show_book will return to the scene that you enter as its second parameter when the book is closed. It defaults to Scene_Map if no scene is given - I simply included Scene_Map in the examples to show that you can designate a scene.

    That's it! Congratulations, you've created a guide! Your players will never have to puzzle over the controls again!

    Anyway, I hope you can see how easy it is to use this as a base to make your own books. I can't wait to see what you come up with - make sure to let me know if you use it! Feel free to read over the rest of the script if you're learning to write code or are simply curious - it's my most thoroughly commented to date and may be able to give you some pointers.



    Script
    This script is available from  SES VX Ace.

    Installation
    Place below Materials and above all other custom scripts, or with the Window_* classes if you want to keep things organized.

    Credit and Thanks

    • Enelvon
    Author's Notes
    This script is made available under the terms of the MIT Expat license. View this page for more information.

    Edit: Just noticed how hideous my tutorial became due to the formatting. Fixed that.


    本贴来自国际rpgmaker官方论坛作者:Enelvon处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/window_book-v3-0-first-standalone-public-release.29488/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 17:08 , Processed in 0.095232 second(s), 51 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表