查看: 2529|回复: 3

[已经解决] 关于农场脚本出错

[复制链接]
梦石
0
星屑
240
在线时间
125 小时
注册时间
2013-12-20
回帖
44
发表于 2013-12-25 11:13:00 | 显示全部楼层 |阅读模式

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

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

×
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Window_KeyItem
  4. #------------------------------------------------------------------------------
  5. #  此視窗使用於事件指令中的“選擇物品”功能。
  6. #==============================================================================

  7. class Window_KeyItem < Window_ItemList
  8.   #--------------------------------------------------------------------------
  9.   # ● 查詢清單中是否含有此物品
  10.   #--------------------------------------------------------------------------
  11.   def include?(item)
  12.     if @category==:key_item
  13.       if ($game_variables[5000]!="")&&($game_variables[5000]!=0)
  14.         item.is_a?(RPG::Item) &&(item.read_note('itype_id')==$game_variables[5000])
  15.       else
  16.         item.is_a?(RPG::Item) &&item.key_item?
  17.       end
  18.     else
  19.       false
  20.     end
  21.    
  22.   end
  23. end
复制代码



这是和农场一起的 发现物品 脚本 就是他的第15行出错


  1. $time = {}
  2. code_time = Thread.new{
  3. loop do
  4.   $time.each do |k,v|
  5.     $time[k] = [v - 1,0].max
  6.   end
  7.   sleep 1
  8. end
  9. }
  10. class Sprite_time < Sprite_Base
  11.   attr_accessor   :ch
  12.   def initialize(view_port,ch)
  13.     super(view_port)
  14.     @ch = ch
  15.     @time = $time[[$game_map.map_id,@ch.id]]
  16.     @new = true
  17.     @item_inde=0
  18.     @plant_index=0
  19.     @plant_count=0
  20.     @plant_time=[]
  21.     @plant_name=[]
  22.     self.bitmap = Bitmap.new(96,36)
  23.   end
  24.   
  25.   def clear_self
  26.     if $time[[$game_map.map_id,@ch.id]] == 0
  27.       $time.delete([$game_map.map_id,@ch.id])
  28.       self.dispose
  29.       return true
  30.     else
  31.       return false
  32.     end
  33.   end
  34.   
  35.   def update
  36.       if @ch.name=~ /%(\d[,,])?(\d+[,,])(\d+[,,])(\d+)/
  37.         @item_index=$2.to_i
  38.         @plant_index=$3.to_i
  39.         @plant_count=$4.to_i
  40.         @plant_time=$data_items[@item_index].read_note('Plant_Time')
  41.         @plant_name=$data_items[@item_index].read_note('Plant_S')
  42.       end
  43.     if @time == nil
  44.         if @plant_count>0
  45.           @plant_index=@plant_time.length-1
  46.           @ch.name='%1,'+@item_index.to_s+','+@plant_index.to_s+','+@plant_count.to_s
  47.         end
  48.       $time[[$game_map.map_id,@ch.id]] =@plant_time[@plant_index]
  49.     end
  50.     if @time != $time[[$game_map.map_id,@ch.id]] || @new
  51.       @time = $time[[$game_map.map_id,@ch.id]]
  52.       @new = false
  53.       if @time != 0
  54.         ho = @time / 3600
  55.         mi = @time / 60 - ho * 60
  56.         se = @time % 60
  57.         string = sprintf("%02d:%02d:%02d", ho,mi,se) if ho >0
  58.         string = sprintf("%02d:%02d",mi,se) if ho == 0        
  59.       else
  60.         @plant_index+=1
  61.         @ch.name='%1,'+@item_index.to_s+','+@plant_index.to_s+','+@plant_count.to_s
  62.         if @plant_index>=@plant_time.length
  63.           string = "收获啦~"
  64.         else
  65.           $time[[$game_map.map_id,@ch.id]] =@plant_time[@plant_index]
  66.         end
  67.       end        
  68.       self.bitmap.clear
  69.       self.bitmap.font.size = 14
  70.       self.bitmap.draw_text(0,18,96,18,string,1)
  71.       self.bitmap.draw_text(0,0,96,18,@plant_name[@plant_index],1)
  72.     end
  73.     self.x = @ch.screen_x - 48
  74.     self.y = @ch.screen_y - 72
  75.   end
  76.   
  77. end

  78. class Game_Interpreter
  79.   
  80.   def add_self(item_index,count)
  81.     if $time[[$game_map.map_id,@event_id]] == nil
  82.       $game_map.events[@event_id].name='%1,'+item_index.to_s+",0,"+count.to_s#+($data_items[item_index].read_note('Plant_Time_First')).to_s
  83.       view_port = Viewport.new(0, 0, 544, 416)
  84.       sprite = Sprite_time.new(view_port,$game_map.events[@event_id])
  85.       SceneManager.scene.spriteset.character_sprites.push(sprite)
  86.       SceneManager.scene.spriteset.update
  87.     end
  88.   end
  89.   
  90.   def get_result
  91.     if $time[[$game_map.map_id,@event_id]] > 0
  92.       return false
  93.     elsif $time[[$game_map.map_id,@event_id]] == 0
  94.       SceneManager.scene.spriteset.clear_time($game_map.events[@event_id])
  95.       return true
  96.     end
  97.   end
  98.   
  99.   alias :iisnow_command_201 :command_201
  100.   def command_201
  101.     $flag = @params[0] == 0 ? @params[1] : $game_variables[@params[1]]
  102.     iisnow_command_201
  103.   end
  104. end

  105.    
  106. class Scene_Map < Scene_Base
  107.   attr_accessor :spriteset
  108.   
  109.   alias :iisnow_start :start
  110.   def start
  111.     $flag = $game_map.map_id
  112.     iisnow_start
  113.   end

  114. end
  115. class Spriteset_Map
  116.   attr_accessor :character_sprites
  117.   
  118.   alias :iisnow_update :update
  119.   def update
  120.     if $flag
  121.     $time.each do |k,v|
  122.       if k[0] == $flag && $flag == $game_map.map_id
  123.         view_port = Viewport.new(0, 0, 544, 416)
  124.         sprite = Sprite_time.new(view_port,$game_map.events[k[1]])
  125.         @character_sprites.push(sprite)
  126.       end
  127.     end
  128.     $flag = nil if $flag == $game_map.map_id
  129.     end
  130.     iisnow_update
  131.   end
  132.   
  133.   def clear_time(d)
  134.     @character_sprites.each do |s|
  135.       c = s.clear_self if s.is_a?(Sprite_time)&&s.ch==d
  136.       @character_sprites[@character_sprites.index(s)] = nil if c
  137.     end
  138.     @character_sprites.compact!
  139.   end
  140.   
  141. end
复制代码


这是农场脚本

而作者发的范例使用起来就没问题

我觉得不是脚本冲突问题 因为我新创建的工程也是这个错误

是不是作者在某个脚本里添加了什么被我忽略了

脚本盲 只会照猫画虎 求大神笼罩

这是出错的截图
360截图20131225110833549.jpg

梦石
1
星屑
23371
在线时间
9572 小时
注册时间
2012-6-19
回帖
7021

开拓者短篇九导演组冠军

发表于 2013-12-25 12:43:45 | 显示全部楼层
范例工程里面应该有个读取备注栏脚本吧,那个也复制到你的工程中去

点评

或者,插入这个脚本到那两个脚本之上 http://bbs.66rpg.com/thread-99474-1-1.html  发表于 2013-12-25 12:45

评分

参与人数 1星屑 +100 收起 理由
Sion + 100 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
240
在线时间
125 小时
注册时间
2013-12-20
回帖
44
 楼主| 发表于 2013-12-25 17:01:37 | 显示全部楼层
喵呜喵5 发表于 2013-12-25 12:43
范例工程里面应该有个读取备注栏脚本吧,那个也复制到你的工程中去

第一个脚本不就是读取备注栏脚本吗?
范例里只有这2个脚本啊
回复

使用道具 举报

梦石
0
星屑
240
在线时间
125 小时
注册时间
2013-12-20
回帖
44
 楼主| 发表于 2013-12-25 17:12:56 | 显示全部楼层
喵呜喵5 发表于 2013-12-25 12:43
范例工程里面应该有个读取备注栏脚本吧,那个也复制到你的工程中去

多谢大神指导,问题果然出在你说的脚本上 只是作者太欺负新人了把脚本藏的太隐秘了!呵呵

再次感谢!!!
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部