赞 | 3 |
VIP | 333 |
好人卡 | 91 |
积分 | 2 |
经验 | 55775 |
最后登录 | 2017-7-18 |
在线时间 | 2070 小时 |
Lv1.梦旅人 Mr.Gandum
- 梦石
- 0
- 星屑
- 226
- 在线时间
- 2070 小时
- 注册时间
- 2007-1-31
- 帖子
- 3039
|
好吧,又是我。- #=begin
- module StockItem
- STOCK =[]
- # 在这里制作初始箱内daoju
- # 格式:
- # STOCK[n] = [kind, id, number]
- # n 是在箱子里的第几个
- # kind 是种类
- # id 是物品的ID
- # number 是数量
- STOCK[1] = [2, 1, 5] # 在箱子里的第一格放5个恢复剂
-
-
- # 箱子的大小。实际大小会在这上头+1
- STOCKMAX = 40
-
- # 决定箱子大小的变量。注意,只能增加不能减少
- STOCK_VARIABLE = 27
-
- # 空格显示的字符
- NON_STOCK_WORD = " - EMPTY - "
-
- module_function
-
- def clear_stock
- for i in @stock
- if i[2] == 0
- i[0] = 0
- end
- end
- end
-
- def initialize_stock
- for i in 0...@stock_max
- if @stock[i] == nil
- @stock.push([0, 0, 0])
- end
- end
- end
-
- def make_stock
- @stock = []
- @stock = STOCK
- @stock_max = STOCKMAX
- initialize_stock
- end
-
- make_stock
- end
- class Window_StockItem < Window_Selectable
- def initialize
- x = 0
- y = 0
- width = 544 / 2
- height = 416
- super(x, y, width, height)
- @stock_max = StockItem::STOCKMAX
- initialize_stock
- refresh
- end
-
- def refresh
- @item_data =[]
- for i in 1...40
- if @stock[i][1] != 0
- case @stock[i][0]
- when 0 # 武器
- @item_data.push($data_weapons[@stock[i][1]])
- when 1 # 防具
- @item_data.push($data_armors[@stock[i][1]])
- when 2 # 道具
- @item_data.push($data_items[@stock[i][1]])
- end
- elsif @stock[i][1] = 0
- @item_data.push(nil)
- end
- end
- @item_max = @item_data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
-
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- item = @item_data[index]
- if item != nil
- for i in 0...@item_max
- if item.is_a?(RPG::Weapon)
- if item.id == @stock[i][1] and @stock[i][0] == 0
- @number = @stock[i][2]
- end
- elsif item.is_a?(RPG::Armor)
- if item.id == @stock[i][1] and @stock[i][0] == 1
- @number = @stock[i][2]
- end
- else
- if item.id == @stock[i][1] and @stock[i][0] == 2
- @number = @stock[i][2]
- end
- end
- end
- enabled = true
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enabled)
- self.contents.draw_text(rect, sprintf(":%2d", @number), 2)
- elsif item = nil
- number = ""
- enabled = true
- draw_empty_name(rect.x, rect.y)
- end
- end
-
- def draw_empty_name(x, y)
- self.contents.font.color = normal_color
- self.contents.draw_text(x + 24, y, 172, WLH, NON_STOCK_WORD)
- end
-
- def initialize_stock
- @stock =[]
- @stock = StockItem::STOCK
- for i in 0...@stock_max
- if @stock[i] == nil
- @stock.push([0, 0, 0])
- end
- end
- end
- end
- class Scene_StockItem < Scene_Base
-
- def initialize(menu_index = 0)
- @menu_index = menu_index
- end
-
- def start
- super
- @stock_item = Window_StockItem.new
- end
-
- def terminate
- @stock_item.dispose
- end
-
- def update
- @stock_item.update
- if Input.trigger?(Input::B) # 取消键按下时
- Sound.play_cancel # 播放取消音效
- $scene = Scene_Map.new # 回到菜单画面
- end
- end
-
- end
- #=end
复制代码 这个。
老是出现Undefined Method "[]" 在102行。
请多指教... |
|