Project1

标题: 如何在地图事件上停止脚本? [打印本页]

作者: 耗子和老鼠    时间: 2011-7-22 12:34
标题: 如何在地图事件上停止脚本?
在脚本里已经设定了一种计算方式,能不能在事件上关闭脚本或者停止?

或者用另外一个脚本来替换原来的。要在事件上弄,好像上面有个脚本什么,我都没动过。。。dsu_plus_rewardpost_czw
作者: 精灵使者    时间: 2011-7-22 12:38
if $game_switches[A]
...
end
当A号开关打开以后才开始工作
作者: 耗子和老鼠    时间: 2011-7-22 12:53
精灵使者 发表于 2011-7-22 12:38
if $game_switches[A]
...
end

好像不是这样。能不能具体点,我只是要用事件把脚本关掉或删掉
作者: 精灵使者    时间: 2011-7-22 13:02
本帖最后由 精灵使者 于 2011-7-22 13:02 编辑

把你的执行的部分写在那个条件分歧里面,A换成你需要的开关号——
只有那个开关号的开关打开的时候,才执行你的那个脚本
给我一下那个脚本是什么。
作者: 耗子和老鼠    时间: 2011-7-22 13:15
。。。。。复制上去的脚本好像都乱了。。。
作者: 南宫爱    时间: 2011-7-22 14:01
本帖最后由 南宫爱 于 2011-7-22 14:03 编辑

应该是在脚本编辑器里,把你的脚本写在if $game_switches[A]与end之间
就是:
  1. if $game_switches[A]
  2. XXX
  3. XXX
  4. XXX
  5. end
复制代码
���
然后关闭A开关,就可以达到效果
作者: 耗子和老鼠    时间: 2011-7-22 14:25
南宫爱 发表于 2011-7-22 14:01
应该是在脚本编辑器里,把你的脚本写在if $game_switches[A]与end之间
就是:���
然后关闭A开关,就可以 ...

好像不行。。。。
作者: 南宫爱    时间: 2011-7-22 14:56
本帖最后由 南宫爱 于 2011-7-22 14:57 编辑

就像是这样:(此为鼠标脚本的一段)是当按下单击(左键)的时候执行的。就把执行的内容用if $game_switches[A]...end 框起来。不能放在脚本开头,否则会出错= =,所以说,要找到执行的地方...把脚本发上来= =
  1. if Mouse.press?(Mouse::LEFT)
  2.       if $game_switches[3]
  3.       last_moving = moving?
  4.       last_direction = @direction
  5.       unless moving? or $game_system.map_interpreter.running? or
  6.              @move_route_forcing or $game_temp.message_window_showing
  7.         last_x = @x
  8.         if @last_move_x
  9.           @last_move_x = false
  10.         elsif mouse_x > screen_x + 16
  11.           move_right
  12.         elsif mouse_x < screen_x - 16
  13.           move_left
  14.         end
  15.         last_y = @y
  16.         if last_x != @x
  17.           @last_move_x = true
  18.         elsif mouse_y > screen_y
  19.           move_down
  20.         elsif mouse_y < screen_y - 32
  21.           move_up
  22.         end
  23.         if last_y != @y
  24.           @last_move_x = false
  25.         elsif not @last_move_x
  26.           case last_direction
  27.       when 2
  28.         move_down
  29.       when 4
  30.         move_left
  31.       when 6
  32.         move_right
  33.       when 8
  34.         move_up
  35.           end
  36.         end
  37.       end
  38.     end
  39.    end
复制代码
���
作者: 耗子和老鼠    时间: 2011-7-23 13:57
南宫爱 发表于 2011-7-22 14:56
就像是这样:(此为鼠标脚本的一段)是当按下单击(左键)的时候执行的。就把执行的内容用if $game_switche ...
  1. class Window_MapVar < Window_Base
  2.   def initialize
  3.     super(0,420,160,60)
  4.     self.opacity=200
  5.     self.back_opacity=200
  6.     self.contents_opacity=255
  7.     self.contents = Bitmap.new(width - 32, height - 32)
  8.     @var_value_old = -1
  9.     @var_icon = Bitmap.new("Graphics/Icons/纳尼2")
  10.    
  11.     refresh
  12.   end
  13.   def refresh
  14.     if @var_value_old==$game_variables[1] then
  15.       return
  16.     end
  17.     self.contents.clear
  18.     cx = contents.text_size($data_system.words.gold).width
  19.     self.contents.font.color = Color.new(255,255,255)
  20.     self.contents.draw_text(24, 0, 104-cx, 28, $game_variables[1].to_s, 2)
  21.     self.contents.font.color = Color.new(255,255,0)
  22.     self.contents.draw_text(128-cx, 0, cx, 28, "无语")
  23.     self.contents.blt(0, 2, @var_icon, Rect.new(0, 0, 24, 24))
  24.   end
  25. end
复制代码

作者: 南宫爱    时间: 2011-7-23 15:29
本帖最后由 南宫爱 于 2011-7-23 15:39 编辑

这样子:(注意是def initialize下面)
  1. class Window_MapVar < Window_Base
  2.   def initialize
  3. if $game_switches[1]
  4.     super(0,420,160,60)
  5.     self.opacity=200
  6.     self.back_opacity=200
  7.     self.contents_opacity=255
  8.     self.contents = Bitmap.new(width - 32, height - 32)
  9.     @var_value_old = -1
  10.     @var_icon = Bitmap.new("Graphics/Icons/纳尼2")
  11.    
  12.     refresh
  13.   end
  14.   def refresh
  15.     if @var_value_old==$game_variables[1] then
  16.       return
  17.     end
  18.     self.contents.clear
  19.     cx = contents.text_size($data_system.words.gold).width
  20.     self.contents.font.color = Color.new(255,255,255)
  21.     self.contents.draw_text(24, 0, 104-cx, 28, $game_variables[1].to_s, 2)
  22.     self.contents.font.color = Color.new(255,255,0)
  23.     self.contents.draw_text(128-cx, 0, cx, 28, "无语")
  24.     self.contents.blt(0, 2, @var_icon, Rect.new(0, 0, 24, 24))
  25.     end
  26. end
  27. end
复制代码


南宫爱于2011-7-23 19:30补充以下内容:
18行!?怎么可能!?


南宫爱于2011-7-23 19:30补充以下内容:
18行!?怎么可能!?


南宫爱于2011-7-24 11:11补充以下内容:
不可能的说,你把错误的截图发过来
作者: 耗子和老鼠    时间: 2011-7-24 14:40

作者: 南宫爱    时间: 2011-7-24 14:45
你把你整个脚本发上来...(你是不是用了.disposed。。。)
作者: 耗子和老鼠    时间: 2011-7-24 15:09
本帖最后由 耗子和老鼠 于 2011-7-24 15:10 编辑

disposed是什么?

zzz.png (4.22 KB, 下载次数: 0)

zzz.png

作者: 南宫爱    时间: 2011-7-24 15:22
你是不是用了XXX.disposed...释放窗口的东西..
作者: 耗子和老鼠    时间: 2011-7-24 15:32
南宫爱 发表于 2011-7-24 15:22
你是不是用了XXX.disposed...释放窗口的东西..

我也不知道发哪个
而且我怎么知道disposed是在哪里。似乎没有用。。。。我对脚本算是完全那个了。。。

如果没办法。我看算了。。。不用了。头都打了
作者: 南宫爱    时间: 2011-7-24 15:42
你把出错的脚本整一个发上来...
作者: 精灵使者    时间: 2011-7-24 18:23
本帖最后由 精灵使者 于 2011-7-24 18:26 编辑

很显然,你把开关设在了installize里面,dispose本来不存在的窗口肯定不行的啦。
至少也得规避一下吧。
  1. class Window_MapVar < Window_Base
  2.   def initialize
  3.     super(0,420,160,60)
  4.     self.opacity=200
  5.     self.back_opacity=200
  6.     self.contents_opacity=255
  7.     self.visible = $game_switches[3]
  8.     self.contents = Bitmap.new(width - 32, height - 32)
  9.     @var_value_old = -1
  10.     @var_icon = Bitmap.new("Graphics/Icons/纳尼2")
  11.     refresh
  12.   end
  13.   def refresh
  14.     if @var_value_old==$game_variables[1] or $game_switches[3]
  15.       return
  16.     end
  17.     self.contents.clear
  18.     cx = contents.text_size($data_system.words.gold).width
  19.     self.contents.font.color = Color.new(255,255,255)
  20.     self.contents.draw_text(24, 0, 104-cx, 28, $game_variables[1].to_s, 2)
  21.     self.contents.font.color = Color.new(255,255,0)
  22.     self.contents.draw_text(128-cx, 0, cx, 28, "无语")
  23.     self.contents.blt(0, 2, @var_icon, Rect.new(0, 0, 24, 24))
  24.     end
  25. end
  26. end
复制代码
应该这样做
作者: 忧雪の伤    时间: 2011-7-24 19:40
什么叫停止脚本?谁给我解释下。
作者: 南宫爱    时间: 2011-7-24 19:40
停止执行脚本...
作者: 忧雪の伤    时间: 2011-7-24 19:42
南宫爱 发表于 2011-7-24 19:40
停止执行脚本...

ruby没有此术语。
作者: 南宫爱    时间: 2011-7-24 19:43
本帖最后由 南宫爱 于 2011-7-24 19:44 编辑

所以说这不是术语..(= =要怎么解释...
作者: 耗子和老鼠    时间: 2011-7-24 21:45
精灵使者 发表于 2011-7-24 18:23
很显然,你把开关设在了installize里面,dispose本来不存在的窗口肯定不行的啦。
至少也得规避一下吧。应该 ...

神。。。不出错了 。但是- - 一开始就被关闭了好像我怎么样用事件关?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1