Project1
标题:
如何判断指定XY坐标上的事件的ID
[打印本页]
作者:
刺夜之枪
时间:
2012-4-28 21:21
标题:
如何判断指定XY坐标上的事件的ID
本帖最后由 刺夜之枪 于 2012-4-28 21:21 编辑
$game_variables[变量id] = $game_map.check_event(x, y)这个脚本很好,但是不能判断指定XY上没有事件的情况! 寻一个脚本可以不但能判断指定XY坐标上的事件的ID,如果指定XY上没有事件就为返回0
{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:}{:2_269:} dsu_plus_rewardpost_czw
作者:
lanyaolove
时间:
2012-4-28 21:54
那你就用开关呗 如果某事件XY等于指定坐标 则开关打开 如果开关为关闭的时候 你可以进行某些事情
作者:
亿万星辰
时间:
2012-4-28 22:50
本帖最后由 亿万星辰 于 2012-7-7 07:49 编辑
自己加行 return 0 就行了
#--------------------------------------------------------------------------
# ● 获取指定位置的事件 ID
# x : X 坐标
# y : Y 坐标
#--------------------------------------------------------------------------
def check_event(x, y)
for event in $game_map.events.values
if event.x == x and event.y == y
return event.id
end
end
return 0
end
复制代码
$game_variables[变量id] = $game_map.check_event(x, y)
然后只要判断 $game_variables[变量id] 就能知道是不是没事件了~有事件的情况下是数字,没有的话是0。
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------
# ● 获取指定位置的事件 ID
# x : X 坐标
# y : Y 坐标
#--------------------------------------------------------------------------
def check_event(x, y)
result = []
for event in $game_map.events.values
if event.x == x and event.y == y
result.push(event.id)
end
end
return result
end
复制代码
$game_variables[变量id] = $game_map.check_event(x, y)
然后只要判断 $game_variables[变量id].empty? 就能知道是不是没事件了~false的情况下是有事件,没有的话是true。
要获取其中的元素可以用each或者其他的方法从数组里获取。
作者:
hys111111
时间:
2012-4-29 07:59
class Game_Map
#--------------------------------------------------------------------------
# ● 在x,y处是否存在事件
#--------------------------------------------------------------------------
def have_an_event?(x,y)
for event in $game_map.events.values
if event.x == x and event.y == y
return true
end
end
return false
end
end
复制代码
可以直接插入。先判断条件分歧:$game_map.have_an_event?(x,y)
然后满足条件了就在用$game_variables[变量id] = $game_map.check_event(x, y)的方法
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1