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

Project1

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

[已经解决] 怎么可以在某个地图里关闭某个脚本,然后离开后又打开?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
203
在线时间
42 小时
注册时间
2017-5-30
帖子
42
跳转到指定楼层
1
发表于 2018-5-4 21:22:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
20星屑
怎么可以在某个地图里关闭某个脚本,然后离开后又打开?

最佳答案

查看完整内容

想起了以前6R有大佬在讨论能不能把整个class都塞到一个开关里...... 记得最后得到的结果是“可以”~ 嘛,楼主想要给什么脚本加开关,直接发脚本比较快

Lv5.捕梦者

梦石
0
星屑
37759
在线时间
5385 小时
注册时间
2006-11-10
帖子
6545
2
发表于 2018-5-4 21:22:29 | 只看该作者
想起了以前6R有大佬在讨论能不能把整个class都塞到一个开关里......

记得最后得到的结果是“可以”~

嘛,楼主想要给什么脚本加开关,直接发脚本比较快

点评

不用开关用全局变量或许可以?不太清楚..  发表于 2018-5-5 10:41
回复

使用道具 举报

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

3
发表于 2018-5-4 21:28:09 | 只看该作者
几乎做不到,通常的效果应该是“脚本的相关功能会根据地图ID来变化”

点评

要根据具体的脚本来做,一般也不难,没有通用的办法~  发表于 2018-5-4 21:33
或者为脚本做个开关,比如当年困扰我很久的重力脚本,就是因为原作者没做开关,造成各种烦显示异常,关上以后完全不影响正常运行了。  发表于 2018-5-4 21:30

评分

参与人数 1+1 收起 理由
xp兔子徒弟 + 1 我很赞同

查看全部评分

熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2125
在线时间
234 小时
注册时间
2018-3-23
帖子
100
4
发表于 2018-5-4 21:33:06 | 只看该作者

利用条件分歧语句就可以达成
在需要的脚本前添加if $game_switches[1]==on #如果1号开关打开
                             需要执行的脚本
                          end
只有1号开关打开才会执行这一段,如果1号开关处于关闭状态就不会执行
利用地图事件控制这个开关即可#同理可以使用变量控制 就看你的喜好了

点评

当然可以,利用这个做加伤或者减伤特效。但是战斗中开关变量不好操作,用状态比较好  发表于 2018-5-5 17:46
大佬这个开关控制可以用到技能公式里面吗  发表于 2018-5-5 04:51
受教了  发表于 2018-5-5 01:44
得看楼主的脚本什么时候开始执行,如果在开关初始化之前,$game_switches没定义是不能用的  发表于 2018-5-5 00:00
RMXP天下第一!
回复

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

5
发表于 2018-5-4 21:36:59 | 只看该作者
没有的。
只是对脚本的功能加个开关,对脚本不能加开关的。
看情况。虽然做法都差不多,但是并不能通用。
回复

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
8498
在线时间
775 小时
注册时间
2017-11-10
帖子
1231
6
发表于 2018-5-4 22:29:36 | 只看该作者
无通用的方法...
想要关闭某个脚本的功能的话,必须先在该脚本设置个开关或者变量。
通过地图的事件调节变量开关。
一个只会简单事件的Rm新人,脚本完全不懂。只求做个简单的游戏完成自己的游戏之梦而已。
第一个游戏已经完成,等待各素材的完成和测试。
回复

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9275
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

7
发表于 2018-5-5 00:00:06 | 只看该作者
你只能在执行到的时候开关功能
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
203
在线时间
42 小时
注册时间
2017-5-30
帖子
42
8
 楼主| 发表于 2018-5-12 22:51:59 | 只看该作者
灯笼菜刀王 发表于 2018-5-5 10:10
想起了以前6R有大佬在讨论能不能把整个class都塞到一个开关里......

记得最后得到的结果是“可 ...

  1. # 本脚本来自www.66rpg.com,转载自www.phylomortis.com,转载请保留此信息
  2. # ————————————————————————————————————

  3. # ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
  4. # by fukuyama

  5. #
  6. # Train_Actor
  7. #
  8. # [email protected]
  9. # http://www4.big.or.jp/~fukuyama/rgss/Train_Actor.txt
  10. #

  11. module Train_Actor




  12. #是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX
  13. #开关打开,跟随的人物就消失了(其实只是变成透明而已)
  14. TRANSPARENT_SWITCH = true
  15. TRANSPARENT_SWITCHES_INDEX = 191
  16. #举例:第一个为true,第二个为20,则打开20号开关,后面的人都没了。





  17. #跟随人数的最大数目,可以更改为2、3什么的。
  18. TRAIN_ACTOR_SIZE_MAX = 5





  19. # 定数
  20. #Input::DOWN = 2
  21. #Input::LEFT = 4
  22. #Input::RIGHT = 6
  23. #Input::UP = 6
  24. DOWN_LEFT = 1
  25. DOWN_RIGHT = 3
  26. UP_LEFT = 7
  27. UP_RIGHT = 9
  28. JUMP = 5

  29. class Game_Party_Actor < Game_Character
  30.   def initialize
  31.     super()
  32.     @through = true
  33.   end
  34.   def setup(actor)
  35. # キャラクターのファイル名と色相を設定
  36.     if actor != nil
  37.       @character_name = actor.character_name
  38.       @character_hue = actor.character_hue
  39.     else
  40.       @character_name = ""
  41.       @character_hue = 0
  42.     end
  43. # 不透明度と合成方法を初期化
  44.     @opacity = 255
  45.     @blend_type = 0
  46.   end
  47.   
  48.   def screen_z(height = 0)
  49.     if $game_player.x == @x and $game_player.y == @y
  50.   
  51.     return $game_player.screen_z(height) - 1
  52.   end
  53.   

  54.   super(height)
  55. end
  56. #--------------------------------------------------------------------------
  57. # ● 下に移動
  58. # turn_enabled : その場での向き変更を許可するフラグ
  59. #--------------------------------------------------------------------------
  60. def move_down(turn_enabled = true)
  61.   if turn_enabled
  62.     turn_down
  63.   end
  64.   
  65.   if passable?(@x, @y, Input::DOWN)
  66.     turn_down
  67.     @y += 1
  68.   end
  69.   

  70. end

  71. #--------------------------------------------------------------------------
  72. # ● 左に移動
  73. # turn_enabled : その場での向き変更を許可するフラグ
  74. #--------------------------------------------------------------------------
  75.   def move_left(turn_enabled = true)
  76. # 左を向く
  77.     if turn_enabled
  78.       turn_left
  79.     end
  80. # 通行可能な場合
  81.    if passable?(@x, @y, Input::LEFT)
  82.   # 左を向く
  83.     turn_left
  84.     @x -= 1
  85.    end
  86. end

  87. #--------------------------------------------------------------------------
  88. # ● 右に移動
  89. # turn_enabled : その場での向き変更を許可するフラグ
  90. #--------------------------------------------------------------------------
  91.   def move_right(turn_enabled = true)
  92. # 右を向く
  93.     if turn_enabled
  94.       turn_right
  95.     end
  96.    
  97. # 通行可能な場合
  98.     if passable?(@x, @y, Input::RIGHT)
  99. # 右を向く
  100.       turn_right
  101. # 座標を更新
  102.       @x += 1
  103.     end
  104.   end
  105.   
  106. #--------------------------------------------------------------------------
  107. # ● 上に移動
  108. # turn_enabled : その場での向き変更を許可するフラグ
  109. #--------------------------------------------------------------------------
  110.   def move_up(turn_enabled = true)
  111. # 上を向く
  112.     if turn_enabled
  113.       turn_up
  114.     end
  115. # 通行可能な場合
  116.     if passable?(@x, @y, Input::UP)
  117. # 上を向く
  118.       turn_up
  119. # 座標を更新
  120.       @y -= 1
  121.     end
  122.    
  123.   end
  124.   
  125. #--------------------------------------------------------------------------
  126. # ● 左下に移動
  127. #--------------------------------------------------------------------------
  128.   def move_lower_left
  129. # 向き固定でない場合
  130.     unless @direction_fix
  131. # 右向きだった場合は左を、上向きだった場合は下を向く
  132.       @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  133.     end
  134.    
  135. # 下→左、左→下 のどちらかのコースが通行可能な場合
  136.   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  137.   (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  138. # 座標を更新
  139.     @x -= 1
  140.     @y += 1
  141.   end
  142.   
  143. end

  144. #--------------------------------------------------------------------------
  145. # ● 右下に移動
  146. #--------------------------------------------------------------------------
  147.   def move_lower_right
  148. # 向き固定でない場合
  149.     unless @direction_fix
  150. # 左向きだった場合は右を、上向きだった場合は下を向く
  151.       @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  152.     end
  153.    
  154. # 下→右、右→下 のどちらかのコースが通行可能な場合
  155.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  156.     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  157. # 座標を更新
  158.       @x += 1
  159.       @y += 1
  160.     end
  161.   end
  162.   
  163. #--------------------------------------------------------------------------
  164. # ● 左上に移動
  165. #--------------------------------------------------------------------------
  166.   def move_upper_left
  167. # 向き固定でない場合
  168.     unless @direction_fix
  169. # 右向きだった場合は左を、下向きだった場合は上を向く
  170.       @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  171.     end
  172.    
  173. # 上→左、左→上 のどちらかのコースが通行可能な場合
  174.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  175.     (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  176. # 座標を更新
  177.       @x -= 1
  178.       @y -= 1
  179.     end
  180.    
  181.   end
  182.   
  183. #--------------------------------------------------------------------------
  184. # ● 右上に移動
  185. #--------------------------------------------------------------------------
  186.   def move_upper_right
  187. # 向き固定でない場合
  188.     unless @direction_fix
  189. # 左向きだった場合は右を、下向きだった場合は上を向く
  190.       @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  191.     end
  192.    
  193. # 上→右、右→上 のどちらかのコースが通行可能な場合
  194.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  195.     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  196. # 座標を更新
  197.        @x += 1
  198.        @y -= 1
  199.      end     
  200.    end   
  201.   attr_writer :move_speed
  202.   attr_writer :step_anime
  203. end
  204. module Spriteset_Map_Module
  205.   def setup_actor_character_sprites?
  206.     return @setup_actor_character_sprites_flag != nil
  207.   end  
  208.   def setup_actor_character_sprites(characters)
  209.     if !setup_actor_character_sprites?
  210.       index_game_player = 0
  211.       @character_sprites.each_index do |i|
  212.         if @character_sprites[i].character.instance_of?(Game_Player)
  213.           index_game_player = i
  214.           break
  215.         end        
  216.       end
  217.       for character in characters.reverse
  218.         @character_sprites.unshift(Sprite_Character.new(@viewport1, character))
  219.       end
  220.      @setup_actor_character_sprites_flag = true
  221.    end
  222. end
  223. end
  224. module Scene_Map_Module
  225.   def setup_actor_character_sprites(characters)
  226.     @spriteset.setup_actor_character_sprites(characters)
  227.   end  
  228. end
  229. module Game_Party_Module
  230.   def set_transparent_actors(transparent)
  231.     @transparent = transparent
  232.   end
  233.   def setup_actor_character_sprites
  234.     if @characters == nil
  235.       @characters = []
  236.       for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  237.         @characters.push(Game_Party_Actor.new)
  238.       end
  239.     end
  240.     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  241.       @characters[i - 1].setup(actors[i])
  242.     end
  243.     if $scene.class.method_defined?('setup_actor_character_sprites')
  244.       $scene.setup_actor_character_sprites(@characters)
  245.     end   
  246.   end
  247.   def update_party_actors
  248.     setup_actor_character_sprites
  249.     transparent = $game_player.transparent
  250.     if transparent == false
  251.       if TRANSPARENT_SWITCH
  252.         transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  253.       end
  254.     end
  255.     for character in @characters
  256.       character.transparent = transparent
  257.       character.move_speed = $game_player.move_speed
  258.       character.step_anime = $game_player.step_anime
  259.       character.update
  260.     end
  261.   end  
  262.   def moveto_party_actors( x, y )
  263.     setup_actor_character_sprites
  264.     for character in @characters
  265.       character.moveto( x, y )
  266.     end
  267.     if @move_list == nil
  268.       @move_list = []
  269.     end
  270.     move_list_setup
  271.   end
  272.   def move_party_actors
  273.     if @move_list == nil
  274.       @move_list = []
  275.       move_list_setup
  276.     end
  277.     @move_list.each_index do |i|
  278.     if @characters[i] != nil
  279.       case @move_list[i].type
  280.       when Input::DOWN
  281.         @characters[i].move_down(@move_list[i].args[0])
  282.       when Input::LEFT
  283.         @characters[i].move_left(@move_list[i].args[0])
  284.       when Input::RIGHT
  285.         @characters[i].move_right(@move_list[i].args[0])
  286.       when Input::UP
  287.         @characters[i].move_up(@move_list[i].args[0])
  288.       when DOWN_LEFT
  289.         @characters[i].move_lower_left
  290.       when DOWN_RIGHT
  291.         @characters[i].move_lower_right
  292.       when UP_LEFT
  293.         @characters[i].move_upper_left
  294.       when UP_RIGHT
  295.         @characters[i].move_upper_right
  296.       when JUMP
  297.         @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  298.       end
  299.     end   
  300.   end
  301. end

  302. class Move_List_Element
  303.   def initialize(type,args)
  304.     @type = type
  305.     @args = args
  306.   end
  307.   def type() return @type end
  308.     def args() return @args end
  309.   end
  310.   def move_list_setup
  311.     for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  312.       @move_list[i] = nil
  313.     end   
  314.   end  
  315.   def add_move_list(type,*args)
  316.     @move_list.unshift(Move_List_Element.new(type,args)).pop
  317.   end
  318.   def move_down_party_actors(turn_enabled = true)
  319.     move_party_actors
  320.     add_move_list(Input::DOWN,turn_enabled)
  321.   end
  322.   
  323.   def move_left_party_actors(turn_enabled = true)
  324.     move_party_actors
  325.     add_move_list(Input::LEFT,turn_enabled)
  326.   end
  327.   def move_right_party_actors(turn_enabled = true)
  328.     move_party_actors
  329.     add_move_list(Input::RIGHT,turn_enabled)
  330.   end
  331.   def move_up_party_actors(turn_enabled = true)
  332.     move_party_actors
  333.     add_move_list(Input::UP,turn_enabled)
  334.   end
  335.   def move_lower_left_party_actors
  336.     move_party_actors
  337.     add_move_list(DOWN_LEFT)
  338.   end
  339.   def move_lower_right_party_actors
  340.     move_party_actors
  341.     add_move_list(DOWN_RIGHT)
  342.   end
  343.   def move_upper_left_party_actors
  344.     move_party_actors
  345.     add_move_list(UP_LEFT)
  346.   end
  347.   def move_upper_right_party_actors
  348.     move_party_actors
  349.     add_move_list(UP_RIGHT)
  350.   end
  351.   def jump_party_actors(x_plus, y_plus)
  352.     move_party_actors
  353.     add_move_list(JUMP,x_plus, y_plus)
  354.   end  
  355. end

  356. module Game_Player_Module
  357.   def update
  358.     $game_party.update_party_actors
  359.     super
  360.   end
  361.   def moveto( x, y )
  362.     $game_party.moveto_party_actors( x, y )
  363.     super( x, y )
  364.   end
  365.   def move_down(turn_enabled = true)
  366.     if passable?(@x, @y, Input::DOWN)
  367.       $game_party.move_down_party_actors(turn_enabled)
  368.     end
  369.     super(turn_enabled)
  370.   end
  371.   def move_left(turn_enabled = true)
  372.     if passable?(@x, @y, Input::LEFT)
  373.       $game_party.move_left_party_actors(turn_enabled)
  374.     end
  375.     super(turn_enabled)
  376.   end
  377.   def move_right(turn_enabled = true)
  378.     if passable?(@x, @y, Input::RIGHT)
  379.       $game_party.move_right_party_actors(turn_enabled)
  380.     end
  381.     super(turn_enabled)
  382.   end
  383.   def move_up(turn_enabled = true)
  384.     if passable?(@x, @y, Input::UP)
  385.       $game_party.move_up_party_actors(turn_enabled)
  386.     end
  387.     super(turn_enabled)
  388.   end
  389.   def move_lower_left
  390.     # 下→左、左→下 のどちらかのコースが通行可能な場合
  391.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  392.       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  393.       $game_party.move_lower_left_party_actors
  394.     end
  395.     super
  396.   end
  397.   def move_lower_right
  398.     # 下→右、右→下 のどちらかのコースが通行可能な場合
  399.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  400.       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  401.       $game_party.move_lower_right_party_actors
  402.     end
  403.     super
  404.   end
  405.   def move_upper_left
  406.     # 上→左、左→上 のどちらかのコースが通行可能な場合
  407.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  408.       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  409.       $game_party.move_upper_left_party_actors
  410.     end
  411.     super
  412.   end
  413.   def move_upper_right
  414.     # 上→右、右→上 のどちらかのコースが通行可能な場合
  415.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  416.       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  417.       $game_party.move_upper_right_party_actors
  418.     end
  419.     super
  420.   end
  421.   def jump(x_plus, y_plus)
  422.     # 新しい座標を計算
  423.     new_x = @x + x_plus
  424.     new_y = @y + y_plus
  425.     # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  426.     if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  427.       $game_party.jump_party_actors(x_plus, y_plus)
  428.     end
  429.     super(x_plus, y_plus)
  430.   end
  431.   
  432.   attr_reader :move_speed
  433.   attr_reader :step_anime
  434. end

  435. end # module Train_Actor
  436. class Game_Party
  437.   include Train_Actor::Game_Party_Module
  438. end
  439. class Game_Player
  440.   include Train_Actor::Game_Player_Module
  441. end
  442. class Spriteset_Map
  443.   include Train_Actor::Spriteset_Map_Module
  444. end
  445. class Scene_Map
  446.   include Train_Actor::Scene_Map_Module
  447. end
  448. class Sprite_Cursor
  449.     def method_missing name,*args
  450.         nil
  451.     end
  452. end
复制代码

点评

这个脚本已经有设置开关了, 默认是191号,打开的时候不跟随。不需要这个功能的地图,场所转移过去的时候打开开关,离开的时候关上开关就OK  发表于 2018-5-13 09:47
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
203
在线时间
42 小时
注册时间
2017-5-30
帖子
42
9
 楼主| 发表于 2018-5-25 21:21:45 | 只看该作者
回复

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6245
在线时间
558 小时
注册时间
2018-6-5
帖子
129
10
发表于 2018-6-10 16:42:23 | 只看该作者
不明觉厉
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 08:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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