Sujet n°14016
Posté par Moy le 26 Juil - 09:58 (2014)
Titre : [RESOLU][PSP OG] Unlimited_Terrain_Tag
Je me suis fait un tileset avec dedans juste les tiles utile pour ma map, sauf que quand je lance la map avec ce tileset j'ai ce message d'erreur:
Message d'erreur

Et ce log :
Log
---------- Erreur de script : Unlimited_Terrain_Tags ----------
----- Type
NoMethodError

----- Message
- ARGS - [0]
undefined method `>' for nil:NilClass

----- Position dans Unlimited_Terrain_Tags
Ligne 120

----- Backtrace
Script : Unlimited_Terrain_Tags | Ligne : 120 | Méthode : in `terrain_tag'
Script : Unlimited_Terrain_Tags | Ligne : 113 | Méthode : in `each'
Script : Unlimited_Terrain_Tags | Ligne : 113 | Méthode : in `terrain_tag'
Script : MapData | Ligne : 461 | Méthode : in `initialize'
Script : MapData | Ligne : 457 | Méthode : in `each'
Script : MapData | Ligne : 457 | Méthode : in `initialize'
Script : MapData | Ligne : 456 | Méthode : in `each'
Script : MapData | Ligne : 456 | Méthode : in `initialize'
Script : ConcreteEngine1 | Ligne : 265 | Méthode : in `new'
Script : ConcreteEngine1 | Ligne : 265 | Méthode : in `get_map_data'
Script : Game_Zone | Ligne : 82 | Méthode : in `setup'
Script : Game_Map | Ligne : 136 | Méthode : in `setup'
Script : Scene_Title | Ligne : 498 | Méthode : in `command_new_game'
Script : Scene_Title | Ligne : 382 | Méthode : in `update'
Script : Scene_Title | Ligne : 343 | Méthode : in `main'
Script : Scene_Title | Ligne : 340 | Méthode : in `loop'
Script : Scene_Title | Ligne : 347 | Méthode : in `main'
Script : Main | Ligne : 49

Par contre que je change de tileset je n'ai pas ce bug.

Posté par Nuri Yuri le 26 Juil - 10:03 (2014)
Tu peux mettre le script dans une balise code contenu dans une balise quote ? ([quote][code] script [/code][/quote])

Posté par Moy le 26 Juil - 10:06 (2014)
Citation:
Code:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= 
# Unlimited Terrain Tags Script by Nathmatt 
# Version: 1.00 
# Type: Add On 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= 
#   
#  This work is protected by the following license: 
# #---------------------------------------------------------------------------- 
# #   
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported 
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ ) 
# #   
# #  You are free: 
# #   
# #  to Share - to copy, distribute and transmit the work 
# #  to Remix - to adapt the work 
# #   
# #  Under the following conditions: 
# #   
# #  Attribution. You must attribute the work in the manner specified by the 
# #  author or licensor (but not in any way that suggests that they endorse you 
# #  or your use of the work). 
# #   
# #  Noncommercial. You may not use this work for commercial purposes. 
# #   
# #  Share alike. If you alter, transform, or build upon this work, you may 
# #  distribute the resulting work only under the same or similar license to 
# #  this one. 
# #   
# #  - For any reuse or distribution, you must make clear to others the license 
# #    terms of this work. The best way to do this is with a link to this web 
# #    page. 
# #   
# #  - Any of the above conditions can be waived if you get permission from the 
# #    copyright holder. 
# #   
# #  - Nothing in this license impairs or restricts the author's moral rights. 
# #   
# #---------------------------------------------------------------------------- 

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= 
# Instrutions: 
#  Scroll down to the config and add terrain_tags by adding these to the config 
#  module (Unlimited_Terrain_Tags.add_terrains(tileset_id,x,y,terrain_tag)) 

#   tileset_id  - is the tilsets id 
#   x,y         - is the location on the tile set 
#   terrain_tag - is the terrain_tag for that tile 

# To get the x and y think of the tilset as the map and the x and y are each block 
# dont count the auto tiles. 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= 
module Unlimited_Terrain_Tags 
   
# dont touch any of this 
   
  $terrains = [] 
   
  class Terrains 
     
    attr_reader   :tileset_id,:tile_id,:terrain_tag 
     
    def initialize(tileset_id,tile_id,terrain_tag) 
      @tileset_id,@tile_id,@terrain_tag = tileset_id,tile_id,terrain_tag 
    end 
     
  end 
   
  def self.get_tile_id(x,y) 
    return((y*8)+x)+384 
  end 
   
  def self.add_terrains(tileset_id,x,y,terrain_tag) 
    $terrains.push(Terrains.new(tileset_id,self.get_tile_id(x,y),terrain_tag)) 
  end   
   
  #============================================================================ 
  # MCES::Config 
  #---------------------------------------------------------------------------- 
  #  The configuration for Unlimited Terrain Tags 
  #============================================================================ 
  module Config 
    # add terrain tags here 
    #Unlimited_Terrain_Tags.add_terrains(tileset_id,x,y,terrain_tag) 
   
    Unlimited_Terrain_Tags.add_terrains(1,5,21,8) # Muret Bas
    Unlimited_Terrain_Tags.add_terrains(1,4,23,8)
    Unlimited_Terrain_Tags.add_terrains(1,5,22,8)
   
    Unlimited_Terrain_Tags.add_terrains(1,7,21,8) # Muret Droite
    Unlimited_Terrain_Tags.add_terrains(1,7,22,8)
    Unlimited_Terrain_Tags.add_terrains(1,7,23,8)
   
    Unlimited_Terrain_Tags.add_terrains(1,6,21,9) # Muret Gauche
    Unlimited_Terrain_Tags.add_terrains(1,6,22,9)
    Unlimited_Terrain_Tags.add_terrains(1,6,23,9)
  end 
   
  def self.get_terrain_tag(tileset_id,tile_id) 
    $terrains.each {|terrain| 
    if [tileset_id,tile_id] == [terrain.tileset_id,terrain.tile_id] 
      return terrain.terrain_tag 
    end} 
    return 0 
  end 
   
end 
   
class Game_Map 
   
  def terrain_tag(x, y) 
    if @map_id != 0 
      [2, 1, 0].each{|i| 
      tile_id = data[x, y, i] 
      if tile_id == nil 
        return 0 
      else 
        t = Unlimited_Terrain_Tags.get_terrain_tag(@map.tileset_id,tile_id) 
        return t if t > 0 
        return @terrain_tags[tile_id] if @terrain_tags[tile_id] > 0
      end} 
    end 
    return 0 
  end 
   
end

Voilà le script.

Posté par Nuri Yuri le 26 Juil - 10:12 (2014)
Cet éternel problème des tiles sur la map qui n'existent pas dans le tileset, ça existe aussi pour PSP OG xD
Alors, ligne 120, tu remplace : return @terrain_tags[tile_id] if @terrain_tags[tile_id] > 0 par return @terrain_tags[tile_id] if @terrain_tags[tile_id].to_i > 0

Posté par Moy le 26 Juil - 10:21 (2014)
Merci Yuri, ça fonctionne nickel !

Posté par Ku'rei le 26 Juil - 17:14 (2014)
Pour ma défense : j'ai intégrer le script sans vérifier ses limites Imbécile heureux J'ajoute la correction au SK Imbécile heureux Merci Yuri

Posté par Nuri Yuri le 26 Juil - 17:37 (2014)
C'est pas de ta faute Ku'rei. Les scripts d'RMXP de base auraient chié la même erreur :p