| 
一个并行事件里写了这么一段脚本,希望达到的效果是:在1~10号事件中自动计算与角色最近距离的事件,并提取编号赋予$target 变量,当这些事件中有独立开关D打开或者没有行走图的就排除在外
x
加入我们,或者,欢迎回来。您需要 登录 才可以下载或查看,没有帐号?注册会员  问题是:当1~10号事件中某个事件与角色距离最近而独立开关D被打开,被提取的$target 依然是该事件的编号,没有被排除在外,而当某个事件与角色距离最近而没有行走图,$target 就变成了nil
 
 
 
 x = $game_player.xy = $game_player.ya=[];for i in 1..10a[i]=($game_map.events[i].x-x).abs+($game_map.events[i].y-y).absend;for i in 1..10next if $game_self_switches[[$game_map.map_id,i,"D"]]==true or $game_map.events[i].character_name == ""if a.min == a[i]  $target = iend;end
x = $game_player.x 
y = $game_player.y 
a=[];for i in 1..10 
a[i]=($game_map.events[i].x-x).abs+ 
($game_map.events[i].y-y).abs 
end;for i in 1..10 
next if $game_self_switches[[ 
$game_map.map_id,i,"D"]]==true or  
$game_map.events[i].character_name == "" 
if a.min == a[i] 
  $target = i 
end;end 
 |