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

Project1

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

[讨论] 这个脚本为什么会在读档和存档时出错

[复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
20 小时
注册时间
2012-4-6
帖子
30
跳转到指定楼层
1
发表于 2012-7-27 11:34:03 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 夜之荒芜 于 2012-7-27 11:35 编辑
  1. #_______________________________________________________________________________
  2. # MOG Scene File Ayumi V1.2           
  3. #_______________________________________________________________________________
  4. # By Moghunter  
  5. # [url]http://www.atelier-rgss.com[/url]
  6. #_______________________________________________________________________________
  7. #_Translated by Tabris Air.______________________________________________________________________________
  8. module MOG
  9. #渐变时间
  10. MSVT = 30
  11. #渐变图样
  12. MSVTT = "006-Stripe02"
  13. end
  14. $mogscript = {} if $mogscript == nil
  15. $mogscript["menu_ayumi"] = true
  16. ###############
  17. # Window_Base #
  18. ###############
  19. class Window_Base < Window
  20. def drw_win_file(x,y)
  21. dwf = RPG::Cache.picture("Win_File")
  22. cw = dwf.width
  23. ch = dwf.height
  24. src_rect = Rect.new(0, 0, cw, ch)
  25. self.contents.blt(x , y - ch, dwf, src_rect)   
  26. end   
  27. def nada
  28. face = RPG::Cache.picture("")
  29. end  
  30. def draw_heroface3(actor,x,y)
  31. face = RPG::Cache.picture(actor.name + "_fc3") rescue nada
  32. cw = face.width
  33. ch = face.height
  34. src_rect = Rect.new(0, 0, cw, ch)
  35. self.contents.blt(x , y - ch, face, src_rect)   
  36. end  
  37. def draw_actor_level6(actor, x, y)
  38. self.contents.font.color = Color.new(0,0,0,255)
  39. self.contents.draw_text(x + 1, y + 1, 32, 32, "Lv")  
  40. self.contents.font.color = system_color
  41. self.contents.draw_text(x, y, 32, 32, "Lv")
  42. self.contents.font.color = Color.new(0,0,0,255)
  43. self.contents.draw_text(x + 17, y + 1, 24, 32, actor.level.to_s, 2)
  44. self.contents.font.color = Color.new(255,255,255,255)
  45. self.contents.draw_text(x + 16, y, 24, 32, actor.level.to_s, 2)
  46. end
  47. def draw_actor_name6(actor, x, y)
  48. self.contents.font.color = Color.new(0,0,0,255)
  49. self.contents.draw_text(x + 1, y + 1, 100, 32, actor.name,1)  
  50. self.contents.font.color = normal_color
  51. self.contents.draw_text(x, y, 100, 32, actor.name,1)
  52. end
  53. end
  54. ############
  55. # Game_Map #
  56. ############
  57. class Game_Map
  58. def map_name
  59. @mapinfo = load_data("Data/MapInfos.rxdata") if @mapinfo == nil
  60. return @mapinfo[@map_id].name
  61. end
  62. end
  63. ###################
  64. # Window_SaveFile #
  65. ###################
  66. class Window_SaveFile < Window_Base
  67.   attr_reader   :filename               
  68.   attr_reader   :selected               
  69.   def initialize(file_index, filename)
  70.     super(0, 64 + file_index * 138, 640, 240)   
  71.     self.contents = Bitmap.new(width - 32, height - 32)  
  72.     self.opacity = 0
  73.     @file_index = file_index
  74.     @filename = "Save#{@file_index + 1}.rxdata"
  75.     @time_stamp = Time.at(0)
  76.     @file_exist = FileTest.exist?(@filename)
  77.     if @file_exist
  78.       file = File.open(@filename, "r")
  79.       @time_stamp = file.mtime
  80.       @characters = Marshal.load(file)
  81.       @frame_count = Marshal.load(file)
  82.       @game_system = Marshal.load(file)
  83.       @game_switches = Marshal.load(file)
  84.       @game_variables = Marshal.load(file)
  85.       @game_self_switches = Marshal.load(file)
  86.       @game_screen = Marshal.load(file)
  87.       @game_actors = Marshal.load(file)
  88.       @game_party = Marshal.load(file)
  89.       @game_troop = Marshal.load(file)
  90.       @game_map = Marshal.load(file)
  91.       @total_sec = @frame_count / Graphics.frame_rate
  92.       file.close
  93.     end
  94.     @wiref = 0
  95.     refresh
  96.     @selected = false
  97.   end  
  98.   def refresh
  99.     self.contents.clear
  100.     self.contents.font.name = (["黑体","MS PMincho","PMingLiU","新細明體","細明體","標楷體"])
  101.     drw_win_file(0,190)
  102.     name = "#{@file_index + 1}"
  103.     self.contents.font.color = Color.new(0,0,0,255)
  104.     self.contents.draw_text(161, 41, 600, 32, name)
  105.     self.contents.font.color = Color.new(255,255,255,255)
  106.     self.contents.draw_text(160, 40, 600, 32, name)   
  107.     @name_width = contents.text_size(name).width
  108.     if @file_exist
  109.       for i in [email][email protected][/email]
  110.         bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
  111.         cw = bitmap.rect.width / 4
  112.         ch = bitmap.rect.height / 4
  113.         src_rect = Rect.new(cw * @wiref + 1 , 0, cw, ch)
  114.         x = 300 - @characters.size + i * 64 - cw / 4
  115.         self.contents.blt(x - 10, 150 - ch, bitmap, src_rect)
  116.         x = 116
  117.         actors = @game_party.actors
  118.         for i in 0...[actors.size, 4].min
  119.         x     = i * 60
  120.         actor = actors[i]        
  121.         self.contents.font.size = 20
  122.         draw_actor_level6(actor, x + 280, 140)
  123.         actor = actors[0]     
  124.         draw_heroface3(actor,160,180)   
  125.         draw_actor_name6(actor, 160, 155)
  126.         self.contents.font.size = 22
  127.         end         
  128.       end      
  129.       hour = @total_sec / 60 / 60
  130.       min = @total_sec / 60 % 60
  131.       sec = @total_sec % 60
  132.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  133.       self.contents.font.color = Color.new(0,0,0,255)
  134.       self.contents.draw_text(5, 41, 450, 32, time_string, 2)
  135.       self.contents.draw_text(41 , 141, 120 , 32, @game_map.map_name.to_s)
  136.       self.contents.font.color = Color.new(255,255,255,255)
  137.       self.contents.draw_text(40 , 140, 120 , 32, @game_map.map_name.to_s)  
  138.       self.contents.draw_text(4, 40, 450, 32, time_string, 2)   
  139.    end
  140.   end
  141.   def selected=(selected)
  142.     @selected = selected
  143.   end
  144. end
  145. ##############
  146. # Scene_File #
  147. ##############
  148. class Scene_File
  149.   def initialize(help_text)
  150.     @help_text = help_text
  151.   end
  152.   def main
  153.     @mnback = Plane.new
  154.     @mnback.bitmap = RPG::Cache.picture("MN_BK")
  155.     @mnback.z = 1
  156.     @mnlay = Sprite.new
  157.     @mnlay.bitmap = RPG::Cache.picture("Lay_File.PNG")
  158.     @mnlay.z = 2
  159.     @help_window = Window_Help.new
  160.     @help_window.set_text(@help_text)
  161.     @help_window.opacity = 0
  162.     @savefile_windows = []
  163.     for i in 0..2
  164.       @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
  165.     end
  166.     @savefile_windows[0]
  167.     @file_index = $game_temp.last_file_index
  168.     @savefile_windows[@file_index].selected = true
  169.     @savefile_windows[0].y = 40   
  170.     @savefile_windows[1].y= 140
  171.     @savefile_windows[2].y= 240   
  172.     @win_move_time = 0
  173.     @win_move = 0
  174.     @win_dire = 0
  175.     @win_opac = 255
  176.     @win1_y = 0
  177.     @win2_y = 0
  178.     @win3_y = 0
  179.     Graphics.transition(MOG::MSVT, "Graphics/Transitions/" + MOG::MSVTT)
  180.     loop do
  181.       Graphics.update
  182.       Input.update
  183.       update
  184.       if $scene != self
  185.         break
  186.       end
  187.     end
  188.     for i in 0..50
  189.     @mnback.ox += 1
  190.     @savefile_windows[0].x += 10   
  191.     @savefile_windows[1].x -= 10
  192.     @savefile_windows[2].x += 10
  193.     for i in @savefile_windows
  194.     i.contents_opacity -= 5
  195.     end  
  196.     Graphics.update  
  197.     end      
  198.     Graphics.freeze
  199.     @help_window.dispose
  200.     @mnback.dispose
  201.     @mnlay.dispose
  202.     for i in @savefile_windows
  203.       i.dispose
  204.     end
  205.   end
  206.   def update
  207.     @mnback.ox += 1
  208.     @win_opac += 3
  209.     @win_move_time += 1   
  210.     if @win_opac > 254
  211.        @win_opac = 150
  212.     end         
  213.     if @win_move_time > 60
  214.     @win_dire += 1
  215.     @win_move_time = 0   
  216.     end
  217.     if @win_dire > 1
  218.        @win_dire = 0
  219.     end
  220.     if @win_dire == 0
  221.        @win_move += 1
  222.     else   
  223.        @win_move -= 1
  224.     end         
  225.     if @file_index == 0
  226.     @savefile_windows[0].z = 2  
  227.     @savefile_windows[1].z = 1
  228.     @savefile_windows[2].z = 0   
  229.     @savefile_windows[0].x = @win_move
  230.     @savefile_windows[1].x = 0
  231.     @savefile_windows[1].x= 0
  232.     @savefile_windows[2].x = 0   
  233.     @savefile_windows[0].contents_opacity = @win_opac
  234.     @savefile_windows[1].contents_opacity = 130
  235.     @savefile_windows[2].contents_opacity =  130   
  236.     elsif @file_index == 1
  237.     @savefile_windows[0].z = 1  
  238.     @savefile_windows[1].z = 2
  239.     @savefile_windows[2].z = 1   
  240.     @savefile_windows[0].x = 0
  241.     @savefile_windows[1].x = @win_move
  242.     @savefile_windows[2].x = 0     
  243.     @savefile_windows[0].contents_opacity =  130
  244.     @savefile_windows[1].contents_opacity = @win_opac
  245.     @savefile_windows[2].contents_opacity =  130
  246.     else
  247.     @savefile_windows[0].z = 0  
  248.     @savefile_windows[1].z = 1
  249.     @savefile_windows[2].z = 2      
  250.     @savefile_windows[0].x = 0
  251.     @savefile_windows[1].x = 0
  252.     @savefile_windows[2].x = @win_move  
  253.     @savefile_windows[0].contents_opacity = 130
  254.     @savefile_windows[1].contents_opacity = 130
  255.     @savefile_windows[2].contents_opacity = @win_opac   
  256.     end   
  257.     @help_window.update   
  258.     for i in @savefile_windows
  259.       i.update
  260.     end
  261.     if Input.trigger?(Input::C)
  262.       on_decision(make_filename(@file_index))
  263.       $game_temp.last_file_index = @file_index
  264.       return
  265.     end
  266.     if Input.trigger?(Input::B)
  267.       on_cancel
  268.       return
  269.     end
  270.     if Input.repeat?(Input::DOWN)
  271.       if Input.trigger?(Input::DOWN) or @file_index < 3
  272.         $game_system.se_play($data_system.cursor_se)
  273.         @savefile_windows[@file_index].selected = false
  274.         @file_index = (@file_index + 1) % 3
  275.         @savefile_windows[@file_index].selected = true
  276.         return
  277.       end
  278.     end
  279.     if Input.repeat?(Input::UP)
  280.       if Input.trigger?(Input::UP) or @file_index > 0
  281.         $game_system.se_play($data_system.cursor_se)
  282.         @savefile_windows[@file_index].selected = false
  283.         @file_index = (@file_index - 1) % 3
  284.         @savefile_windows[@file_index].selected = true
  285.         return
  286.       end
  287.     end
  288.   end
  289.   def make_filename(file_index)
  290.     return "Save#{file_index + 1}.rxdata"
  291.   end
  292. end
复制代码


第60行发生NoMethodError
undefined method name' for nil:NilClass

不管读档和存档都是跳出这个
这脚本是从别的游戏抠下来的~~
前几天测试时都可以用~~今天就这样~~

Lv1.梦旅人

梦石
0
星屑
39
在线时间
115 小时
注册时间
2012-1-23
帖子
103
2
发表于 2012-7-27 12:33:49 | 只看该作者
地图的问题。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
20 小时
注册时间
2012-4-6
帖子
30
3
 楼主| 发表于 2012-7-27 17:02:25 | 只看该作者
1587937102 发表于 2012-7-27 12:33
地图的问题。

麻烦具体点~~~要怎么修改~~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
465 小时
注册时间
2011-4-13
帖子
174
4
发表于 2012-7-27 17:30:08 | 只看该作者
我把脚本拷贝到新建的游戏中出现了其他很无语的问题(比如说109行循环语句的“...”),而且直接运行的话会出现其他问题(包括缺少图片),所以无法修改测试
建议在60行前面加上
  1. p @mapinfo[@map_id].name
复制代码
弹出的对话框中如果是"Nil",就是脚本问题,可以试着在存取画面的write_save_data方法中存入角色当前的地图名称,再在Window_SaveFile中读取
弹出的如果不是"Nil",而是地图名称,就是地图本身的问题了,不知道你最近有没有修改过其他的地方,请把它改回来
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
20 小时
注册时间
2012-4-6
帖子
30
5
 楼主| 发表于 2012-7-28 10:29:06 | 只看该作者
heiwang1997 发表于 2012-7-27 17:30
我把脚本拷贝到新建的游戏中出现了其他很无语的问题(比如说109行循环语句的“...”),而且直接运行的话会 ...

确实是要很多图片~
那段代码加了后就多弹2个框还是一样不行
后来我自己改成这样(我完全没学过这语言)
不会弹框了,就是地图名在读档存档时不显示~~
游戏还是可以凑合着用{:2_254:}
  1. class Game_Map
  2. def map_name
  3. @mapinfo = load_data("Data/MapInfos.rxdata")
  4. if @mapinfo == nil
  5. @mapinfo[@map_id].name
  6. end
  7. end
  8. end
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-30 05:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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