#此脚本的关键之处已做了注释, #请务必仔细阅读 class Window_Information<Window_Base TEXTHEIGHT=24 #信息窗口中文字行高 def initialize(x,y,width,height) super(x,y,width,height) end def draw_text_bylines(lines,name) text_x=100 text_y=24 self.contents.clear self.contents.draw_text(150,0,354,24,name) for i in 0..lines.size-1 self.contents.draw_text(text_x,text_y,354,24,lines[i]) text_y+=24 end end end class Window_InforCommand<Window_Command def initialize(x,y,name_array,handbook,face,face_index) @name_array=name_array @handbook=handbook @face_visible=face @face_index=face_index @character_rect=Rect.new(0,0,96,250) @now_index=-1 p super(x,y) if @name_array==[] self.visible=false else @information_window=Window_Information.new(160,50,354,366) end end def make_command_list for i in [email]0..@name_array.size[/email]-1 add_command(@name_array[i],:command) end end def update super if @now_index!=self.index @now_index=self.index if @information_window!=nil if @name_array[self.index]!="未解锁" @information_window.draw_text_bylines(@handbook[@name_array[self.index]],@name_array[self.index]) if @face_index[self.index]!=9 @information_window.draw_face(@face_visible[self.index],@face_index[self.index],0,50) else @information_window.contents.blt(0,50,Cache.battler(@character[self.index],0),@character_rect) end else @information_window.contents.clear @information_window.draw_text(100,0,100,24,"未解锁") end end end end def set_character(character) @character=character end end class Window_MenuCommand def add_hand_book_command add_command("图鉴",:hand_book) end alias make_command_list_old make_command_list def make_command_list make_command_list_old add_hand_book_command end end class Scene_Menu alias create_command_window_old create_command_window def create_command_window create_command_window_old @command_window.set_handler(:hand_book, method(:command_hand_book)) end def command_hand_book SceneManager.call(Scene_Information) end end class Scene_Information<Scene_MenuBase MAX_ROW_WORDS=9 def initialize super() @pages=[] #-------------------------------------------------------------------------- # ●以下这是这个脚本关键,按说明填数组中的内容 #-------------------------------------------------------------------------- name_array=["影魔","剧毒术士","宙斯","幻影长矛手"] #说明上面一句是设置npc的名字,名字中不要换行 set_name_switches={0=>1,1=>2,2=>3,3=>4} #上面设置每个npc图鉴是否可见所对应的开关,比如把剧毒术士对应7号开关 #可以这样设置“ 1=>7”左边的1表示7号开关对应名字数组中的1号位置即数组中的 #第二项。因为数组的0号位置对应数组的第一项,说以以此类推这样设置。 @hand_book={"影魔"=>"我是影魔 我今天要横扫新手 场哈p哈哈哈哈","剧毒术士"=>"我是剧毒术士","宙斯"=>"我是宙斯","幻影长矛手"=>"我是幻影长矛手aaaaaa"} #以上数组是设置npc的介绍,里面可以换行,如果有英文字母p,则p以后的 #内容会令起一段。 face=["actor1","actor1","actor1","actor1"] #以上是设置npc的头像文件名,在actor文件夹下。可以自己更改 face_index=[0,1,2,9] #以上是设置每个对应头像的文件中具体头像的编号,应为每个头像文件包含 #8个头像,所以要设置一下。,如果你不想用默认头像,应自己的图像 character=["asura","bandit","captain","hero_m"] #设置人物半身像,半身像文件要放在ballters中,文件名填入以上数组 #注意半身像文件高度不要超过200,宽度不要超过96. #注意以上数组中的项数一定要相同,比如上面填写的数组每个都是4项。 #-------------------------------------------------------------------------- # ●以上这是这个脚本关键按说明填数组中的内容 #-------------------------------------------------------------------------- @face_visible=[] @face_index=[] @name_visible_array=[] @character_visible=[] for i in 0..set_name_switches.size-1 if $game_switches[set_name_switches[i]]==true @name_visible_array.push(name_array[i]) @face_visible.push(face[i]) @face_index.push(face_index[i]) @character_visible.push(character[i]) else @name_visible_array.push("未解锁") @face_visible.push("") @face_index.push(9) @character_visible.push("") end end @hand_book.each{|key,value|@hand_book[key]=hand_book_tolines(value)} end def start super create_title_window create_inforcommand_window end def create_title_window @title_window=Window_Base.new(0,0,544,50) @title_window.draw_text(220,0,100,24,"图鉴") end def create_inforcommand_window @inforcommand_window=Window_InforCommand.new(0,50,@name_visible_array, @hand_book,@face_visible,@face_index) @inforcommand_window.set_handler(:cancel, method(:return_scene)) @inforcommand_window.set_character(@character_visible) end #下面这个函数是脚本关键部分之一,不理解不影响脚本的使用 #这里说明一下:这个脚本的想法是把每个图鉴的字符串分按字数分为 #几个数组,每个数组会画成图鉴窗口的一行字符,9个字为一行, #所以这个有个问题,即每个图鉴中的文字最好不要超过60个字,否则多余的字会显示 #不出来。 def hand_book_tolines(string) @inforlines=[] inforline="" wordCount=0 lineCount=0 string.delete!("\n ") loop do c=string.slice!(/./m) if c==nil break end if c!="p" if wordCount<MAX_ROW_WORDS wordCount+=1 else @inforlines.push(inforline) wordCount=1 inforline="" end inforline+=c else @inforlines.push(inforline) wordCount=0 inforline="" end end @inforlines.push(inforline) return @inforlines end end
5QJGK%DN1)1@FOV`HMMGH4F.jpg (61.2 KB, 下载次数: 37)
2.3 KB, 下载次数: 353
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |