Galera é o seguinte to com esse script de mineração aki que achei mas nao tinha informaçoes de uso e eu tbm nao consegui entender alguem pode me ajudar a entender como ele funciona
- Código:
#==============================================================================
# Window_Mine
#------------------------------------------------------------------------------
# The Window with the mine in it
#==============================================================================
class Window_Mine < Window_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize(d, items, rarity, w, h)
width = (24 * w) + 32
height = (24 * h) + 32
super(320 - (width / 2), 240 - (height / 2), width, height)
self.contents = Bitmap.new(width - 32, height - 32)
@items = []
@rocks = []
for i in 0...w
@rocks.push([])
@items.push([])
for j in 0...h
@rocks[i][j] = (rand(d) + 1)
@items[i][j] = 0
end
end
temp = []
for i in 0...w
temp.push(0)
for j in 0...h
if rand(100) < rarity
temp[i] += 1
end
if temp[i] > 0
for j in 0..temp[i]
@items[i][(h - 1) - j] = items[rand(items.size)]
end
end
end
end
@w = w
@h = h
@x = 0
@y = 0
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
types = ["", "043-Item12", "039-Item08", "061-Coal", "062-Bronze", "036-Item05", "037-Item06", "038-Item07",
"040-Item09", "041-Item10", "042-Item11"] #You might want to change this part, it's the icons representing rocks.
for column in 0...@w
for row in 0...@h
bitmap = RPG::Cache.icon(types[@rocks[column][row]])
if @rocks[column][row] == 0 and @items[column][row] != 0
id = @items[column][row][1]
case @items[column][row][0]
when 0
bitmap = RPG::Cache.icon($data_items[id].icon_name)
when 1
bitmap = RPG::Cache.icon($data_weapons[id].icon_name)
when 2
bitmap = RPG::Cache.icon($data_armors[id].icon_name)
end
end
self.contents.blt(column * 24, row * 24, bitmap, Rect.new(0, 0, 24, 24))
end
end
end
#--------------------------------------------------------------------------
# Remove
#--------------------------------------------------------------------------
def remove
if @rocks[@x][@y] == 0 or nonearby(@x, @y)
if @rocks[@x][@y] == 0 and @items[@x][@y] != 0
$game_system.se_play($data_system.equip_se)
id = @items[@x][@y][1]
case @items[@x][@y][0]
when 0
$game_party.gain_item(id, 1)
when 1
$game_party.gain_weapon(id, 1)
when 2
$game_party.gain_armor(id, 1)
end
@items[@x][@y] = 0
refresh
return
end
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
for i in grtr
@rocks[i[0]][i[1]] = 0
end
cleanup
refresh
end
#--------------------------------------------------------------------------
# No Nearby
#--------------------------------------------------------------------------
def nonearby(x, y)
type = @rocks[x][y]
if x > 0
return false if @rocks[x - 1][y] == type
end
if x < (@w - 1)
return false if @rocks[x + 1][y] == type
end
if y > 0
return false if @rocks[x][y - 1] == type
end
if y < (@h - 1)
return false if @rocks[x][y + 1] == type
end
return true
end
#--------------------------------------------------------------------------
# Clean up
#--------------------------------------------------------------------------
def cleanup
for x in 0...@w
for i in 0...@h
for y in 0...@h
if @rocks[x][y + 1] == 0
@rocks[x][y + 1] = @rocks[x][y]
@rocks[x][y] = 0
end
end
end
end
end
#--------------------------------------------------------------------------
# Get Rocks to Remove
#--------------------------------------------------------------------------
def grtr
rtr = [[@x, @y]]
checked = []
for x in 0...@w
checked.push([])
for y in 0...@h
checked[x].push(false)
end
end
for i in 0..50
for x in 0...@w
for y in 0...@h
if rtr.include?([x, y]) and !checked[x][y]
checked[x][y] = true
if x > 0
if @rocks[x][y] == @rocks[x - 1][y] and !rtr.include?([x - 1, y])
rtr.push([x - 1, y])
end
end
if x < (@w - 1)
if @rocks[x][y] == @rocks[x + 1][y] and !rtr.include?([x + 1, y])
rtr.push([x + 1, y])
end
end
if y > 0
if @rocks[x][y] == @rocks[x][y - 1] and !rtr.include?([x, y - 1])
rtr.push([x, y - 1])
end
end
if y < (@h - 1)
if @rocks[x][y] == @rocks[x][y + 1] and !rtr.include?([x, y + 1])
rtr.push([x, y + 1])
end
end
end
end
end
end
return rtr
end
#--------------------------------------------------------------------------
# Update Cursor Rect
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(@x * 24, @y * 24, 24, 24)
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
super
if self.active
if Input.repeat?(Input::DOWN)
if @y < (@h - 1)
@y += 1
$game_system.se_play($data_system.cursor_se)
end
end
if Input.repeat?(Input::UP)
if @y > 0
@y -= 1
$game_system.se_play($data_system.cursor_se)
end
end
if Input.repeat?(Input::RIGHT)
if @x < (@w - 1)
@x += 1
$game_system.se_play($data_system.cursor_se)
end
end
if Input.repeat?(Input::LEFT)
if @x > 0
@x -= 1
$game_system.se_play($data_system.cursor_se)
end
end
end
update_cursor_rect
end
end