例子2.PNG (31.94 KB, 下载次数: 19)
temp.jpg (46.97 KB, 下载次数: 20)
灯笼菜刀王 发表于 2022-5-31 09:43
n = 0
$game_party.instance_variable_get(:@items).each{|a,b| n += b if $game_items[a].description.sp ...
taeckle 发表于 2022-6-2 07:06
大神请问下为什么我在那个class Game_Party里面没有找到这个instance_variable_get方法呢? ...
module RPG class Item def desc desc = @description.split(/@/)[1] return desc != nil ? desc : "普通物品" end end end
灯笼菜刀王 发表于 2022-5-31 09:43
n = 0
$game_party.instance_variable_get(:@items).each{|a,b| n += b if $game_items[a].description.sp ...
module RPG class Item def desc @description.split("@")[1] || "普通物品" end @@idx = {} #直接设定默认值的话可以 @@idx = Hash.new{|hsh, key| hsh[key] = []} data_items = load_data("Data/Items.rxdata") data_items[1..-1].each do |item| (@@idx[item.desc] ||= []) << item.id end def self.idx @@idx end end end class Game_Party def item_des_number(descr_para = "") (RPG::Item.idx[descr_para] || []).inject{|sum, id|sum += @items[id] || 0} end end
temp.png (41.3 KB, 下载次数: 22)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |