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

Project1

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

[已经解决] 1个脚本有问题求解 1个脚本需要略修改

[复制链接]

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
1
发表于 2014-6-25 16:24:29 | 显示全部楼层
刺夜之枪 发表于 2014-6-28 13:16
【我把全部给了】

不过我觉得可能看着很费眼,,内容多

纯理论脚本,有效与否请自行验证
  1. Spriteset_Map.instance_eval do
  2.         alias org_init_4_arrow initialize
  3.         alias org_update_4_arrow update
  4.         alias org_dispose_4_arrow update
  5.         def initialize
  6.                 @point_arrow_object = []
  7.                 org_init_4_arrow
  8.                 display_point_arrow_team
  9.         end
  10.         def update
  11.                 @point_arrow_object.each{|a|a.update}
  12.                 org_update_4_arrow
  13.         end
  14.         def dispose
  15.                 for a in @point_arrow_object
  16.                         a.delete
  17.                         a.dispose
  18.                 end
  19.                 org_dispose_4_arrow
  20.         end
  21.         def display_point_arrow_team
  22.                 for team in $Team_Fighter
  23.                         next if team.is_a?(Game_Player)
  24.                         @point_arrow_object.push(EFS_Point_Arrow.new(@viewport3))
  25.                         @point_arrow_object[-1].display(team)
  26.                 end
  27.         end
  28. end
复制代码
使用前先把截图中的那段先注释掉,顺便吐槽那脚本怎么用了这么多全局变量=w=
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
2
发表于 2014-6-26 17:24:30 | 显示全部楼层
本帖最后由 英顺的马甲 于 2014-6-26 17:26 编辑

第一个问题有多种可能,单凭一个脚本难以鉴定
第二个问题简单,但需要花点时间来改脚本

p/s:第二个问题需要你对你的要求的详细说明
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
3
发表于 2014-6-27 01:01:00 | 显示全部楼层
本帖最后由 英顺的马甲 于 2014-6-27 16:45 编辑

RUBY 代码复制下载
  1. # 使用说明:
  2. # Notification.post(信息)          发一则提示
  3. # Notification.move(x,y,宽,高)     移动提示框位置(必须执行至少一次)
  4. # Notification.clear               清除所有提示
  5. # Notification.pause               为true期间post失效
  6. # Notification.delay               新提示发布后提示延迟消失的时间(秒)
  7. # Notification.opacity             不透明度,请配合pause一起使用
  8. # Notification.font                提示字体(包括大小及颜色)
  9. # Notification.limit               提示限制
  10.  
  11. Notification = Class.new do
  12.   attr_accessor :font, :msg
  13.   @@font = nil
  14.   @@sprite = Sprite.new
  15.   @@sprite.bitmap = Bitmap.new(1,1)
  16.   @@sprite.z = 999999
  17.   @@limit = 20
  18.   @@delay = 3
  19.   @@opacity = 0
  20.   @@pause = false
  21.   @@count = @@delay * 40
  22.   def self.move(x,y,width,height)
  23.     @@sprite.x = x
  24.     @@sprite.y = y
  25.     @@sprite.bitmap.dispose
  26.     @@sprite.bitmap = Bitmap.new(width, height)
  27.     self.redraw unless $game_system == nil
  28.   end
  29.   def self.limit=(max)
  30.     @@limit = max
  31.   end
  32.   def self.font
  33.     return @@font.nil? ? Font.new : @@font
  34.   end
  35.   def self.font=(fon)
  36.     @@font = fon
  37.   end
  38.   def self.post(msg)
  39.     return if @@pause
  40.     $game_system.notifications.push(new(msg))
  41.     while $game_system.notifications.size > 50
  42.       $game_system.notifications.delete_at(0)
  43.     end
  44.     self.redraw unless $game_system == nil
  45.     self.opacity = 255
  46.     @@count = @@delay * 40
  47.   end
  48.   def self.clear
  49.     $game_system.notifications = []
  50.     self.redraw
  51.   end
  52.   def self.redraw
  53.     b = @@sprite.bitmap
  54.     b.clear
  55.     b2 = Bitmap.new(b.width,640)
  56.     y = b.height
  57.     for n in $game_system.notifications.reverse[0,@@limit]
  58.       x = 0
  59.       y2 = 0
  60.       b2.font = n.font
  61.       h = b2.text_size(n.msg).height
  62.       n.msg.split('').each do |char|
  63.         if (x + b2.text_size(char).width) > b2.width
  64.           x = 0
  65.           y2 += h
  66.         end
  67.         b2.draw_text(x,y2,b2.width,h,char)
  68.         x += b2.text_size(char).width + 2
  69.       end
  70.       y -= (y2 + h)
  71.       b.blt(0,y,b2,Rect.new(0,0,b2.width,y2 + h))
  72.       b2.clear
  73.       y -= 4
  74.     end
  75.     b2.dispose
  76.   end
  77.   def self.update
  78.     return @@count -= 1 if @@count > 0
  79.     self.opacity -= 10 if self.opacity > 0
  80.   end
  81.   def initialize(msg)
  82.     @font = @@font.nil? ? Font.new : @@font.clone
  83.     @msg = msg
  84.   end
  85.   def self.show
  86.     @@sprite.visible = true
  87.   end
  88.   def self.hide
  89.     @@sprite.visible = false
  90.   end
  91.   def self.pause
  92.     return @@pause
  93.   end
  94.   def self.pause=(bool)
  95.     @@pause = true
  96.   end
  97.   def self.delay
  98.     return @@delay
  99.   end
  100.   def self.delay=(val)
  101.  
  102.     @@delay = val
  103.   end
  104.   def self.opacity
  105.     return @@sprite.opacity
  106.   end
  107.   def self.opacity=(val)
  108.     @@sprite.opacity = val
  109.   end
  110.   def _dump(limit)
  111.     bin = []
  112.     bin.push(@font.size)
  113.     bin.push((@font.bold ? 1 : 0) + (@font.italic ? 16 : 0))
  114.     bin.push(@font.color.red)
  115.     bin.push(@font.color.green)
  116.     bin.push(@font.color.blue)
  117.     bin.push(@font.color.alpha)
  118.     bin = bin.pack("C*")
  119.     @font.name = [@font.name] unless !@font.name.is_a?(Array)
  120.     bin += (@font.name + [@msg]).join("\000:\000")
  121.     return bin
  122.   end
  123.   def self._load(bin)
  124.     bin = bin.unpack("C*")
  125.     no = new("")
  126.     no.font.size = bin.delete_at(0)
  127.     no.font.bold = (bin[0] % 16 > 0)
  128.     no.font.italic = (bin.delete_at(0) / 16 > 0)
  129.     no.font.color = Color.new(*bin[0,4])
  130.     bin[0,4]=[]
  131.     strs = bin.pack("C*").split("\000:\000")
  132.     no.msg = strs.delete_at(-1)
  133.     no.font.name = strs
  134.     return no
  135.   end
  136. end
  137. Game_System.class_eval do
  138.   attr_accessor :notifications
  139.   OrgInitialize4Notf = instance_method('initialize')
  140.   def initialize(*args)
  141.     OrgInitialize4Notf.bind(self).call(*args)
  142.     @notifications = []
  143.   end
  144. end
  145. Scene_Map.class_eval do
  146.   OrgMain4Notf = instance_method('main')
  147.   OrgUpdate4Notf = instance_method('update')
  148.   def main(*args)
  149.     Notification.show
  150.     OrgMain4Notf.bind(self).call(*args)
  151.     Notification.hide
  152.   end
  153.   def update(*args)
  154.     Notification.update
  155.     OrgUpdate4Notf.bind(self).call(*args)
  156.   end
  157. end
  158. Scene_Load.class_eval do
  159.   OrgReadData4Notf = instance_method('read_save_data')
  160.   def read_save_data(*args)
  161.     OrgReadData4Notf.bind(self).call(*args)
  162.     Notification.redraw
  163.     Notification.opacity = 0
  164.   end
  165. end
  166. Game_Party.class_eval do
  167.   OrgMeth4Notf = {}
  168.   ["add_actor","remove_actor","gain_gold","gain_item","gain_weapon","gain_armor"].each do |meth|
  169.     OrgMeth4Notf[meth] = instance_method(meth)
  170.   end
  171.   def add_actor(id,*args)
  172.     actor = $game_actors[id]
  173.     if @actors.size < 4 and not @actors.include?(actor)
  174.       Notification.push(actor.name + "加入队伍!")
  175.     end
  176.     OrgMeth4Notf['add_actor'].bind(self).call(id,*args)
  177.   end
  178.   def remove_actor(id,*args)
  179.     actor = $game_actors[id]
  180.     if @actors.include?(actor)
  181.       Notification.push(actor.name + "离开队伍!")
  182.     end
  183.     OrgMeth4Notf['remove_actor'].bind(self).call(id,*args)
  184.   end
  185.   def gain_gold(*args)
  186.     gold_old = @gold
  187.     OrgMeth4Notf['gain_gold'].bind(self).call(*args)
  188.     if gold_old != @gold
  189.       value = @gold - gold_old
  190.       msg = "#{$game_party.actors[0].name}"+(value > 0 ? "得到" : "失去")+"了#{value.abs}#{$data_system.words.gold}"
  191.       Notification.post(msg)
  192.     end
  193.   end
  194.   def gain_item(id,*args)
  195.     num_old = item_number(id)
  196.     OrgMeth4Notf['gain_item'].bind(self).call(id,*args)
  197.     if num_old != item_number(id)
  198.       value = item_number(id) - num_old
  199.       msg = "#{$game_party.actors[0].name}"+(value > 0 ? "得到" : "失去")+"了#{value.abs}个#{$data_items[id].name}"
  200.       Notification.post(msg)
  201.     end
  202.   end
  203.   def gain_weapon(id,*args)
  204.     num_old = weapon_number(id)
  205.     OrgMeth4Notf['gain_weapon'].bind(self).call(id,*args)
  206.     if num_old != @gold
  207.       value = weapon_number(id) - num_old
  208.       msg = "#{$game_party.actors[0].name}"+(value > 0 ? "得到" : "失去")+"了#{value.abs}个#{$data_weapons[id].name}"
  209.       Notification.post(msg)
  210.     end
  211.   end
  212.   def gain_armor(id,*args)
  213.     num_old = armor_number(id)
  214.     OrgMeth4Notf['gain_armor'].bind(self).call(id,*args)
  215.     if num_old != @gold
  216.       value = armor_number(id) - num_old
  217.       msg = "#{$game_party.actors[0].name}"+(value > 0 ? "得到" : "失去")+"了#{value.abs}个#{$data_armors[id].name}"
  218.       Notification.post(msg)
  219.     end
  220.   end
  221. end
你给的脚本看似雷人,于是我重写了一个更雷人的,怎么用自己研究(反正你会脚本)
有图有真相:

如果懒惰改脚本的话就加上这句(我的脚本是自动换行,所以那blue啥sort的能全删了)
RUBY 代码复制
  1. trace_var :$am do |val|
  2.   Notification.post(val)
  3. end
p/s:第一个问题出现的原因的可能性有被释放,被遮挡,被隐藏和被清除

点评

顺便-A- 我的第一问题您会么  发表于 2014-6-27 17:52
终于成功了!辛苦您了。 其实刚才我就在纠结这个为什么不显示 研究了半天发现是Notification.move 的数值输得不对。 真心感谢了,用起来比原来的好  发表于 2014-6-27 17:51
求工程  发表于 2014-6-27 16:54
那么,,怎么才能用呢  发表于 2014-6-27 16:44
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
4
发表于 2014-6-27 23:01:07 | 显示全部楼层
本帖最后由 英顺的马甲 于 2014-6-27 23:02 编辑
刺夜之枪 发表于 2014-6-27 18:55
-A-
找不出来,可能跟我写的太烂然后就不知不觉错了
估计要重写了、、  


刚刚仔细看了你的截图,你试着把第48行的@viewport1换成@viewport2看看吧==
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
5
发表于 2014-6-28 11:41:18 | 显示全部楼层
你忘了释放了==
能给上完整脚本不?这样实在难以鉴定问题所在 OTZ

点评

求QQ,工程不方便放上来 QuQ  发表于 2014-6-28 12:43
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-11 03:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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