| 赞 | 4 |
| VIP | |
| 好人卡 | |
| 积分 | 7 |
| 经验 | |
| 最后登录 | 2013-8-9 |
| 在线时间 | 184 小时 |
天仙
- 梦石
- 0
- 星屑
- 720
- 在线时间
- 184 小时
- 注册时间
- 2008-4-15
- 回帖
- 4872

|
发表于 2008-5-6 07:48:45
|
显示全部楼层
我知道了
是時間的問題
由於format_time(time)是一個方法
而time是一個時間物件,
並非是數值,因此是不斷運行中滴
雖然差沒多少
但是對於計算機來說一經有很大的差別了
這樣就沒問題了:
- def add_item(item_name, time)
- a = format_time(time)
- sort_item = [$game_variables[VAR_INDEX].to_i, item_name, a]
- p sort_item
- @data.push(sort_item)
- @data.sort!
- @data.reverse!
- @data.pop if @data.size > SORT_MAX
- # 以时间为次键再倒序
- for i in 0...@data.size
- for j in i+1...@data.size
- if @data[i][0] == @data[j][0] and @data[i][2] > @data[j][2]
- @data[i][2],@data[j][2] = @data[j][2],@data[i][2]
- end
- end
- end
- # 怪事 -.-b
- p sort_item
- @new_index = @data.index(sort_item)
- if @new_index == nil
- @new_index = -1
- else
- self.index = @new_index
- end
- save_data(@data, "Data/Sort.rvdata")
- #return @data
- end
复制代码
解法是formar_time返回的值帶入變量a
而不是再次調用format_time |
|