Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MapTemplate
- attr_accessor :id
- attr_accessor :width
- attr_accessor :height
- attr_accessor :map
- def initialize(id, width, height)
- @id = id
- @width = width
- @height = height
- readTemplate()
- end
- def readTemplate()
- @map = load_data(sprintf("Data/Map%03d.rxdata",@id))
- end
- end
- #Fusiona los arrays de dos mapas
- def mergeMapArrays(a, b, x, y)
- tp = b.map
- x_limit = b.width
- y_limit = b.height
- for j in y..y_limit+y
- for k in x..x_limit+x
- for l in 0..2
- begin
- if tp.data[k-x,j-y,l] != 0 && tp.data[k-x,j-y,l] != nil
- a.data[k,j,l] = tp.data[k-x,j-y,l]
- end
- rescue => exception
- #p exception
- end
- end
- end
- end
- #return a
- end
- #Coloca permanentemente una plantilla en un mapa con origen en las coordenadas x,y
- def placeOnMap(template, x, y, mapid)
- map_info = load_data(sprintf("Data/Map%03d.rxdata",mapid))
- mergeMapArrays(map_info, template, x, y)
- save_data(map_info, sprintf("Data/Map%03d.rxdata", mapid))
- end
- #Cambiar temporalmente el tile situado en las coordenadas x,y,z en el mapa actual
- def setMapTile(id, x,y,z)
- $game_map.map.data[x,y,z] = id
- $game_map.refresh
- end
- #Ejemplo de como colocar una plantilla en un mapa
- def placeTest()
- t = MapTemplate.new(4, 8, 4)
- placeOnMap(t, 3, 4, 2)
- end
Add Comment
Please, Sign In to add comment