Project1
标题: [已解決]如何跳过名字為空的项目? [打印本页]
作者: chanszeman1018 时间: 2020-4-21 22:08
提示: 作者被禁止或删除 内容自动屏蔽
作者: Cupidk爱呗茶 时间: 2020-4-21 23:05
本帖最后由 Cupidk爱呗茶 于 2020-4-21 23:47 编辑
只要判断一下当前要执行的物品name方法是否为空的字符串就行了
n = $data_armors.size - 1
n.times {|i| $game_party.gain_item($data_armors[i+1], 1) if
$data_armors[i+1].name!="" }
n = $data_armors.size - 1
n.times {|i| $game_party.gain_item($data_armors[i+1], 1) if
$data_armors[i+1].name!="" }
当name方法不等于""时 然后才执行
或者
n.times {|i| $game_party.gain_item($data_armors[i+1], 1) unless
$data_armors[i+1].name=="" }
n.times {|i| $game_party.gain_item($data_armors[i+1], 1) unless
$data_armors[i+1].name=="" }
同理
作者: KB.Driver 时间: 2020-4-22 18:16
本帖最后由 KB.Driver 于 2020-4-22 18:20 编辑
def all_item
block = ->(x) { x && !x.name.empty? && $game_party.gain_item(x, 99) }
$data_items.each(&block)
$data_weapons.each(&block)
$data_armors.each(&block)
end
def all_item
block = ->(x) { x && !x.name.empty? && $game_party.gain_item(x, 99) }
$data_items.each(&block)
$data_weapons.each(&block)
$data_armors.each(&block)
end
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |