赞 | 1 |
VIP | 116 |
好人卡 | 40 |
积分 | 4 |
经验 | 19804 |
最后登录 | 2017-12-13 |
在线时间 | 4175 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 432
- 在线时间
- 4175 小时
- 注册时间
- 2010-6-26
- 帖子
- 6474
|
本帖最后由 eve592370698 于 2012-4-14 02:55 编辑
步兵中尉 发表于 2012-4-2 13:44
用这个脚本就可以了。如果没有添加其他脚本的话就直接打开5号开关就变成读书系统了;默认为8行字,也就是两 ...
我记得有个读取TXT文件的脚本是最原始的,《同福书局》就是根据它增强扩展而来的。- =begin
- 在脚本中输入 $scene = Scene_Read_NM.new 开启柳万岁爷的小图书馆脚本
- 在事件脚本中输入$scene = Scene_Read_SUPER.new可以运行柳大人的大图书馆脚本
- =end
- class Window_Reader < Window_Base
- attr_accessor :text
- def initialize(text, line)
- @text = text
- @line = line
- super(50, 15, 540, 450)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.size = 20
- refresh
- end
- =begin
- ❀刷新
- =end
- def refresh
- self.contents.clear
- self.contents.font.size = 20
- self.contents.font.color = normal_color
- j = 0
- for i in @line..[@text.size - 1, @line + 14].min
- self.contents.draw_text(0, 28 * j, 540 - 32, 28, @text[i])
- j += 1
- end
- self.contents.font.size = 12
- self.contents.font.color = Color.new(255,255,0,255)
- self.contents.draw_text(0, 408, 540 - 32, 12, @line.to_s + "/" + (@text.size-1).to_s , 2)
- end
-
- def add_1
- @line += 1
- @line = [@text.size - 1, @line].min
- refresh
- end
-
- def minus_1
- @line -= 1
- @line = [0, @line].max
- refresh
- end
-
- def page_add
- @line += 13
- @line = [@text.size - 1, @line].min
- refresh
- end
-
- def page_back
- @line -= 13
- @line = [0, @line].max
- refresh
- end
-
- def renew(text, line)
- @text = text
- @line = line
- refresh
- end
-
-
- end
- class Window_Command < Window_Selectable
- attr_reader :commands
- end
- =begin =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- ■ Scene_Read
-
- 柳万岁爷的小图书馆脚本
- =end # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- class Scene_Read_NM
- #-----------------------------------------
- # ● 主处理
- #-----------------------------------------
- def main
- sp = Spriteset_Map.new
- #↓调用读书的窗口
- @read_window = Window_Reader.new([""], 0)
- @read_window.opacity = 230
- @read_window.z = 900
- text = Dir["txt/*"]
- @text = []
- for tx in text
- @text.push (tx.split(/\//)[1].split(/.txt/)[0])
- end
- @command_window = Window_Command.new(180, @text)
- @command_window.y = (480 - @command_window.height)/2
- @command_window.opacity = 230
- @command_window.z = 999
- @doing = 1
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- @command_window.dispose if !@command_window.disposed?
- @read_window.dispose
- sp.dispose
- end
-
- def update
- case @doing
- when 1 #选书
- update_1
- when 2 #读书
- update_2
- end
- end
-
- def update_1
- @command_window.update
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- filename = "txt/" + @command_window.commands[@command_window.index] + ".txt"
- file = File.open(filename, "r")
- r = file.readlines
- @real_text = []
- for i in 0...r.size
- temp_story = r[i].split(/\n/)[0]
- temp_story.gsub!(/,/) {","} if temp_story != nil
- temp_story.gsub!(/\./) {"。"} if temp_story != nil
- temp_story.gsub!(/ /) {" "} if temp_story != nil
- while(temp_story != nil)
- text = ""
- if temp_story.length > 75
- text = temp_story.slice!(0,75)
- else
- text = temp_story
- temp_story = nil
- end
- @real_text.push(text)
- end
- end
- file.close
- @read_window.renew(@real_text, 0)
- @command_window.visible = false
- @command_window.active = false
- @doing = 2
- end
- end
-
-
- def update_2
- @read_window.update
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @command_window.visible = true
- @command_window.active = true
- @doing = 1
- end
- if Input.trigger?(Input::UP)
- $game_system.se_play($data_system.cursor_se)
- @read_window.minus_1
- end
- if Input.trigger?(Input::DOWN)
- $game_system.se_play($data_system.cursor_se)
- @read_window.add_1
- end
- if Input.trigger?(Input::L) or Input.trigger?(Input::LEFT)
- $game_system.se_play($data_system.cursor_se)
- @read_window.page_back
- end
- if Input.trigger?(Input::R) or Input.trigger?(Input::RIGHT)
- $game_system.se_play($data_system.cursor_se)
- @read_window.page_add
- end
- end
-
- end
- =begin
- # ■ Scene_Read
- =end
- class Scene_Read_SUPER
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- sp = Spriteset_Map.new
- @read_window = Window_Reader.new([""], 0)
- @read_window.opacity = 230
- @read_window.z = 900
- @command_window = Window_Command.new(180, ["选音乐","选书阅读"])
- @command_window.y = (480 - @command_window.height)/2
- @command_window.opacity = 230
- @command_window.z = 999
- @doing = 0
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- @command_window.dispose if !@command_window.disposed?
- @read_window.dispose
- sp.dispose
- end
-
- def update
- case @doing
- when 0 #选项
- update_0
- when 1 #选书
- update_1
- when 2 #读书
- update_2
- when 3 #选音乐
- update_3
- end
- end
-
- def update_0
- @command_window.update
- if Input.trigger?(Input::C)
- case @command_window.index
- when 0
- $game_system.se_play($data_system.decision_se)
- text = Dir["Audio/BGM/*"]
- @text = []
- for tx in text
- @text.push(tx.split(/BGM\//)[1])
- end
- @command_window.dispose
- @command_window = Window_Command.new(180, @text)
- @command_window.y = (480 - @command_window.height)/2
- @command_window.opacity = 230
- @command_window.z = 999
- @doing = 3
- when 1
- $game_system.se_play($data_system.decision_se)
- text = Dir["txt/*"]
- @text = []
- for tx in text
- @text.push (tx.split(/\//)[1].split(/.txt/)[0])
- end
- @command_window.dispose
- @command_window = Window_Command.new(180, @text)
- @command_window.y = (480 - @command_window.height)/2
- @command_window.opacity = 230
- @command_window.z = 999
- @doing = 1
- when 2
- $game_system.se_play($data_system.decision_se)
- @command_window.visible = false
- @command_window.active = false
- @doing = 2
- end
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_Map.new
- end
- end
-
- def update_1
- @command_window.update
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @doing = 0
- @command_window.dispose
- if @read_window.text != [""]
- @command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
- else
- @command_window = Window_Command.new(180, ["选音乐","选书阅读"])
- end
- @command_window.y = (480 - @command_window.height)/2
- @command_window.opacity = 230
- @command_window.z = 999
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- filename = "txt/" + @command_window.commands[@command_window.index] + ".txt"
- file = File.open(filename, "r")
- r = file.readlines
- @real_text = []
- for i in 0...r.size
- temp_story = r[i].split(/\n/)[0]
- temp_story.gsub!(/,/) {","} if temp_story != nil
- temp_story.gsub!(/\./) {"。"} if temp_story != nil
- temp_story.gsub!(/ /) {" "} if temp_story != nil
- while(temp_story != nil)
- text = ""
- if temp_story.length > 75
- text = temp_story.slice!(0,75)
- else
- text = temp_story
- temp_story = nil
- end
- @real_text.push(text)
- end
- end
- file.close
- @read_window.renew(@real_text, 0)
- @command_window.visible = false
- @command_window.active = false
- @doing = 2
- end
- end
-
-
- def update_2
- @read_window.update
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.decision_se)
- @doing = 0
- @command_window.dispose
- if @read_window.text != [""]
- @command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
- else
- @command_window = Window_Command.new(180, ["选音乐","选书阅读"])
- end
- @command_window.y = (480 - @command_window.height)/2
- @command_window.opacity = 230
- @command_window.z = 999
- @doing = 0
- end
- if Input.trigger?(Input::UP)
- $game_system.se_play($data_system.cursor_se)
- @read_window.minus_1
- end
- if Input.trigger?(Input::DOWN)
- $game_system.se_play($data_system.cursor_se)
- @read_window.add_1
- end
- if Input.trigger?(Input::L) or Input.trigger?(Input::LEFT)
- $game_system.se_play($data_system.cursor_se)
- @read_window.page_back
- end
- if Input.trigger?(Input::R) or Input.trigger?(Input::RIGHT)
- $game_system.se_play($data_system.cursor_se)
- @read_window.page_add
- end
- end
-
- def update_3
- @command_window.update
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- filename = "Audio/BGM/" + @command_window.commands[@command_window.index]
- Audio.bgm_play(filename, 100, 100)
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @doing = 0
- @command_window.dispose
- if @read_window.text != [""]
- @command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
- else
- @command_window = Window_Command.new(180, ["选音乐","选书阅读"])
- end
- @command_window.y = (480 - @command_window.height)/2
- @command_window.opacity = 230
- @command_window.z = 999
- end
- end
-
-
- end
复制代码 您的这个智能合并脚本挺不错。
不过我一般是用FUKI对话框,要输入大段文章我都是在事件中输入- $game_temp.message_text = "半角双引号内是文章内容"
复制代码 另外可以参考我的86版FUKI对话框。 |
|