设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1387|回复: 0
打印 上一主题 下一主题

[已经过期] RMXP MTV 脚本出错问题

[复制链接]

Lv4.逐梦者

梦石
3
星屑
2769
在线时间
186 小时
注册时间
2015-8-18
帖子
51

开拓者

跳转到指定楼层
1
发表于 2015-11-19 12:34:41 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 1262917464 于 2015-11-19 21:12 编辑

{:2_276:}在拿到MTV脚本后,在范例上歌词的支持效果很好。可是自己改上自己歌词时就傻了,不能按X,按下去出现这个



求哪个脚本大大修改下,谢谢了

MTV本体脚本:

RUBY 代码复制
  1. #=================================================================
  2. # MTV 脚本,by 66RPG_柳柳
  3. #=================================================================
  4. module MTV  
  5.   #===============================================================
  6.   # 读取文件。文件相对地址:Audio/BGM
  7.   # file_name:文件名;length:MTV长度,按照.1秒为单位记数
  8.   #===============================================================
  9.   def self.load(file_name,length = 0)
  10.     $mtv_time = []
  11.     $mtv_text = []
  12.     $game_system.mtv_length = length
  13.     #=============================================================
  14.     # 打开文件并且读取之
  15.     #=============================================================
  16.     file =  File.open("Audio/BGM/"+file_name)
  17.     #=============================================================
  18.     # 读取歌词
  19.     #=============================================================
  20.     for line in file.readlines
  21.       #===========================================================
  22.       # 转为UTF-8编码
  23.       #===========================================================
  24.       line = EasyConv.s2u(line)
  25.       #===========================================================
  26.       # 寻找本行歌词
  27.       #===========================================================
  28.       this_line_text = line[line.scan(/\]/).size*10,line.size]
  29.       #===========================================================
  30.       # 把读取的行分存成时间与文字
  31.       #===========================================================
  32.       for i in 0...line.scan(/\]/).size
  33.         temp_b = line[i*10+1,8]
  34.         temp_c = temp_b.split(/:/)[0]
  35.         mmsecond = 600 * temp_c.to_i
  36.         temp_c = temp_b.split(/:/)[1]
  37.         mmsecond += 10 * temp_c.to_f
  38.         $mtv_time.push(mmsecond.to_i)
  39.         $mtv_text.push(this_line_text)
  40.       end
  41.     end
  42.     file.close
  43.   end
  44.   #===============================================================
  45.   # 开始MTV字幕
  46.   #===============================================================
  47.   def self.mtv_begin
  48.     $game_system.mtv_now = true
  49.     $game_system.mtv_begin_time = $sys_timer.now()
  50.     $lrc_text = ""
  51.     return
  52.   end
  53.   #===============================================================
  54.   # 结束MTV字幕
  55.   #===============================================================
  56.   def self.stop
  57.     $game_system.mtv_now = false
  58.     return
  59.   end
  60.   #===============================================================
  61.   # 测试MTV是否播放
  62.   #===============================================================
  63.   def self.mtv?
  64.     return $game_system.mtv_now
  65.   end
  66.   #===============================================================
  67.   # 获取MTV字幕
  68.   #===============================================================
  69.   def self.new_text
  70.     if $game_system.mtv_now
  71.       #===========================================================
  72.       # 求出已经经过的时间
  73.       #===========================================================
  74.       nt = $sys_timer.now()
  75.       nt -= $game_system.mtv_begin_time
  76.       nt = nt.to_i
  77.       nt /= 100      
  78.       #===========================================================
  79.       # 制作循环
  80.       #===========================================================
  81.       if $game_system.mtv_length>0 and nt > $game_system.mtv_length
  82.         nt -= $game_system.mtv_length
  83.       end
  84.       #===========================================================
  85.       # 放出字幕
  86.       #===========================================================
  87.       for tm in 0...$mtv_time.size
  88.         if $mtv_time[tm] == nt
  89.           $lrc_text = $mtv_text[tm]
  90.           break
  91.         end
  92.       end
  93.     else
  94.       $lrc_text = ""
  95.     end
  96.   end
  97. end
  98. #==============================================================================
  99. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  100. #==============================================================================
  101. # ------------------------------------------------------------------------
  102. # 高精度计时器 by FantasyDR
  103. # ------------------------------------------------------------------------
  104. # E-mail: [email][email protected][/email]
  105. # ------------------------------------------------------------------------
  106. # 2005.10.18
  107. # ------------------------------------------------------------------------
  108. # 该类已经被定义为全局变量 $sys_timer
  109. # 如果只需要精确到毫秒,请设置初始化参数为true
  110. # decimal属性设置返回时间值的小数位数。
  111. # ------------------------------------------------------------------------
  112. # 下面是一些有用的方法列表,调用时写:$sys_timer.方法名
  113. # 例如 $sys_timer.clear()
  114. # ------------------------------------------------------------------------
  115. # clear() :计时器清零
  116. # now() :获取当前经过的时间,单位毫秒
  117. # now_s() :获取当前经过的时间,单位秒
  118. # ------------------------------------------------------------------------
  119. class SystemTimer
  120. attr_accessor:decimal #小数位数设定,默认为3
  121.  
  122. def initialize(use_GetTime=false)
  123. # 初始化,根据系统选择不同精度计时器
  124. @qpFrequency = Win32API.new("kernel32","QueryPerformanceFrequency",'p','L')
  125. @qpCounter = Win32API.new("kernel32","QueryPerformanceCounter",'p','L')
  126. @tGetTime = Win32API.new("winmm","timeGetTime",'','L')
  127.  
  128. @decimal=3
  129. @perf_cnt=" " * 8
  130. @time_start=" " * 8
  131. @time_now=" " * 8
  132.  
  133. result = @qpFrequency.call(@perf_cnt)
  134.  
  135. if use_GetTime
  136. result = 0
  137. end
  138.  
  139. if result!=0
  140. @perf_flag=true
  141. else
  142. @perf_flag=false
  143. @perf_cnt=[1000,0].pack('LL')
  144. end
  145.  
  146. #设置时间比例因数
  147. @time_scale=@perf_cnt.unpack('LL')
  148. @time_scale[0] /= 1000.0
  149. @time_scale[1] /= 1000.0
  150.  
  151. #起始时间清零
  152. self.clear()
  153. end
  154.  
  155. #-=====================-#
  156. # 计时器清零
  157. #-=====================-#
  158. def clear()
  159. if @perf_flag
  160. @qpCounter.call(@time_start)
  161. else
  162. @time_start=[@tGetTime.call(),0].pack('LL')
  163. end
  164. end
  165.  
  166. #-==============================-#
  167. # 获取当前经过的时间,单位毫秒
  168. #-==============================-#
  169. def now()
  170. now_time = 0.0e1
  171. now_time += self.timer() - self.start()
  172. now_time /= self.scale()
  173. return self.debug(now_time)
  174. end
  175.  
  176. #-==============================-#
  177. # 获取当前经过的时间,单位秒
  178. #-==============================-#
  179. def now_s()
  180. now_time = 0.0e1
  181. now_time += self.timer() - self.start()
  182. now_time /= (self.scale()*1000)
  183. return self.debug(now_time)
  184. end
  185.  
  186. #-==============================-#
  187. # 帧错...
  188. #-==============================-#
  189. def debug(now_time)
  190. if @decimal>0
  191. now_time = (now_time * (10**@decimal)).floor/(10.0**@decimal)
  192. else
  193. now_time = now_time.floor
  194. end
  195. return now_time
  196.  
  197. #以下用于debug模式
  198. if now_time < 0
  199. p "Timer Wrong!! Clear...",now_time,\
  200. @perf_flag,@qpCounter,@tGetTime,
  201. @time_now.unpack('LL')[0],@time_now.unpack('LL')[1],
  202. @time_start.unpack('LL')[0],@time_start.unpack('LL')[1]
  203. self.clear()
  204. return 0.0
  205. else
  206. return now_time
  207. end
  208. end
  209.  
  210. #-=====================-#
  211. # 获取时间比例因数
  212. #-=====================-#
  213. def scale()
  214. return @time_scale[0]+\
  215. @time_scale[1]*0xffffffff
  216. end
  217.  
  218. #-=====================-#
  219. # 获取起始滴答数
  220. #-=====================-#
  221. def start()
  222. return @time_start.unpack('LL')[0]+\
  223. @time_start.unpack('LL')[1]*0xffffffff
  224. end
  225.  
  226. #-=====================-#
  227. # 获取当前的嘀哒数
  228. #-=====================-#
  229. def timer()
  230. if @perf_flag
  231. @qpCounter.call(@time_now)
  232. else
  233. @time_now=[@tGetTime.call(),0].pack('LL')
  234. end
  235. return @time_now.unpack('LL')[0]+\
  236. @time_now.unpack('LL')[1]*0xffffffff
  237. end
  238. end
  239. #-------------------------------------#
  240. # 初始化自身成一个全局变量
  241. #-------------------------------------#
  242. $sys_timer=SystemTimer.new()
  243. #-------------------------------------#
  244.  
  245.  
  246.  
  247.  
  248. #==============================================================================
  249. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  250. #==============================================================================
  251.  
  252.  
  253. #==============================================================================
  254. # 仭 EasyConv module - Ver 0.90
  255. #------------------------------------------------------------------------------
  256. # Moonlight INN
  257. # [url]http://cgi.members.interq.or.jp/aquarius/rasetsu/[/url]
  258. # RaTTiE
  259. # [email][email protected][/email]
  260. #------------------------------------------------------------
  261. # EasyConv::s2u(text) : S-JIS -> UTF-8
  262. # EasyConv::u2s(text) : UTF-8 -> S-JIS
  263. #==============================================================================
  264. module EasyConv
  265. # API梡掕悢掕媊
  266.    CP_ACP = 0
  267.    CP_UTF8 = 65001
  268.  
  269. #--------------------------------------------------------------------------
  270. # 仠 S-JIS -> UTF-8
  271. #--------------------------------------------------------------------------
  272. def s2u(text)
  273. # API掕媊
  274.    m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  275.    w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  276.  
  277. # S-JIS -> Unicode
  278.    len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
  279.    buf = "\0" * (len*2)
  280.    m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);
  281.  
  282. # Unicode -> UTF-8
  283.    len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  284.    ret = "\0" * len
  285.    w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  286.  
  287.    return ret
  288. end
  289. # module_function偲偟偰岞奐
  290. module_function :s2u
  291. #--------------------------------------------------------------------------
  292. # 仠 UTF-8 -> S-JIS
  293. #--------------------------------------------------------------------------
  294. def u2s(text)
  295. # API掕媊
  296.    m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  297.    w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  298.  
  299. # UTF-8 -> Unicode
  300.    len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
  301.    buf = "\0" * (len*2)
  302.    m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);
  303.  
  304. # Unicode -> S-JIS
  305.    len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
  306.    ret = "\0" * len
  307.    w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);
  308.  
  309.    return ret
  310. end
  311. # module_function偲偟偰岞奐
  312. module_function :u2s
  313. end
  314.  
  315.  
  316. #==============================================================================
  317. # ■ Game_System
  318. #------------------------------------------------------------------------------
  319. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  320. # $game_system 。
  321. #==============================================================================
  322. class Game_System
  323.   #--------------------------------------------------------------------------
  324.   # ● 定义实例变量
  325.   #--------------------------------------------------------------------------
  326.   attr_accessor :mtv_begin_time
  327.   attr_accessor :mtv_now
  328.   attr_accessor :mtv_length
  329.   #--------------------------------------------------------------------------
  330.   # ● 初始化对像
  331.   #--------------------------------------------------------------------------
  332.   alias mtv_gamesystem_initialize initialize
  333.   def initialize
  334.     mtv_gamesystem_initialize
  335.     @mtv_begin_time = $sys_timer.now()
  336.     @mtv_now = false
  337.     @mtv_length = 0
  338.   end
  339. end  
  340.  
  341. #==============================================================================
  342. # ■ Scene_Map
  343. #------------------------------------------------------------------------------
  344. #  处理地图画面的类。
  345. #==============================================================================
  346. class Scene_Map
  347.   #--------------------------------------------------------------------------
  348.   # ● 刷新画面
  349.   #--------------------------------------------------------------------------
  350.   alias mtv_scenemap_update update
  351.   def update
  352.     @mtv_window.refresh
  353.     mtv_scenemap_update
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 主处理
  357.   #--------------------------------------------------------------------------
  358.   alias mtv_scenemap_main main
  359.   def main
  360.     @mtv_window = Window_MTV.new
  361.     mtv_scenemap_main
  362.     @mtv_window.dispose
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 调用战斗 (调整自动切换BGM)
  366.   #--------------------------------------------------------------------------
  367.   def call_battle
  368.     # 清除战斗调用标志
  369.     $game_temp.battle_calling = false
  370.     # 清除菜单调用标志
  371.     $game_temp.menu_calling = false
  372.     $game_temp.menu_beep = false
  373.     # 生成遇敌计数
  374.     $game_player.make_encounter_count
  375.     # 记忆地图 BGM 、停止 BGM
  376.     $game_temp.map_bgm = $game_system.playing_bgm
  377.     unless MTV.mtv?      
  378.       $game_system.bgm_play($game_system.battle_bgm)
  379.       # 演奏战斗开始 SE
  380.       $game_system.se_play($data_system.battle_start_se)
  381.     end
  382.     # 矫正主角姿势
  383.     $game_player.straighten
  384.     # 切换到战斗画面
  385.     $scene = Scene_Battle.new
  386.   end
  387. end
  388.  
  389. #==============================================================================
  390. # ■ Scene_Battle
  391. #------------------------------------------------------------------------------
  392. #  处理战斗的类。
  393. #==============================================================================
  394. class Scene_Battle
  395.   #--------------------------------------------------------------------------
  396.   # ● 刷新画面
  397.   #--------------------------------------------------------------------------
  398.   alias mtv_scenebattle_update update
  399.   def update
  400.     @mtv_window.refresh
  401.     mtv_scenebattle_update
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # ● 主处理
  405.   #--------------------------------------------------------------------------
  406.   alias mtv_scenebattle_main main
  407.   def main
  408.     @mtv_window = Window_MTV.new
  409.     mtv_scenebattle_main
  410.     @mtv_window.dispose
  411.   end
  412. end
  413.  
  414. #==============================================================================
  415. # ■ Window_MTV
  416. #------------------------------------------------------------------------------
  417. #  显示MTV字幕的窗口。
  418. #==============================================================================
  419.  
  420. class Window_MTV < Window_Base
  421.   #--------------------------------------------------------------------------
  422.   # ● 初始化窗口
  423.   #--------------------------------------------------------------------------
  424.   def initialize
  425.     super(0, 416, 640, 64)
  426.     self.contents = Bitmap.new(width - 32, height - 32)
  427.     $lrc_text = ""
  428.     self.z = 9999
  429.     refresh
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   # ● 刷新
  433.   #--------------------------------------------------------------------------
  434.   def refresh(text = "")
  435.     MTV.new_text
  436.     self.contents.clear   
  437.     if $game_temp.in_battle
  438.       self.opacity = 120
  439.     else
  440.       self.opacity = 0
  441.     end
  442.     self.contents.font.color = Color.new(0,0,0,255)
  443.     self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)   
  444.     self.contents.font.color = Color.new(255,255,255,255)
  445.     self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)   
  446.   end
  447. end


出错脚本(出错位置已使用“#”备注):

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_MenuStatus
  3. #------------------------------------------------------------------------------
  4. #  显示菜单画面和同伴状态的窗口。
  5. #==============================================================================
  6.  
  7. class Window_MenuStatus < Window_Selectable
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化目标
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(0, 0, 480, 480)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     self.contents.font.size = 16
  15.     refresh
  16.     self.active = false
  17.     self.index = -1
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 刷新
  21.   #--------------------------------------------------------------------------
  22.   def refresh
  23.     self.contents.clear
  24.     i = 16
  25.     for li in 0...$mtv_time.size     #有时出错这里
  26.       self.contents.draw_text(0,i,640,32,$mtv_time[li].to_s+"  :"+$mtv_text[li])       #有时又出错这里
  27.       i += 18
  28.     end
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● 刷新光标矩形
  32.   #--------------------------------------------------------------------------
  33.   def update_cursor_rect
  34.     if @index < 0
  35.       self.cursor_rect.empty
  36.     else
  37.       self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
  38.     end
  39.   end
  40. end

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-23 01:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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