Страница 48 из 147 ПерваяПервая ... 3846474849505898 ... ПоследняяПоследняя
Показано с 471 по 480 из 1470

Тема: Помощь с скриптами (RGSS)

  1. #471

    По умолчанию

    Цитата Сообщение от Рольф Посмотреть сообщение
    Там само попадание их в меню. Если это он имел виду, то ты прав.
    Чуть-чуть ошибся - не при попадании, а при перерисовке:
    Код:
    #--------------------------------------------------------------------------
      # * Draw Item
      #     index : item number
      #--------------------------------------------------------------------------
      def draw_item(index)
        rect = item_rect(index)
        self.contents.clear_rect(rect)
        item = @data[index]
        if item != nil
          number = $game_party.item_number(item)
          enabled = enable?(item)
          rect.width -= 4
          draw_item_name(item, rect.x, rect.y, enabled)
          self.contents.draw_text(rect, sprintf(":%2d", number), 2)
        end
      end
    Но это только раскрашивает недоступные айтемы в серый цвет.

    Сама же проверка, выдающая возмущенные BEEP'ы, происходит в каждой конкретной сцене по разному. В Scene_Item, например, так:
    Код:
    #--------------------------------------------------------------------------
      # * Update Item Selection
      #--------------------------------------------------------------------------
      def update_item_selection
        if Input.trigger?(Input::B)
          Sound.play_cancel
          return_scene
        elsif Input.trigger?(Input::C)
          @item = @item_window.item
          if @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item)
            Sound.play_decision
            determine_item
          else
            Sound.play_buzzer
          end
        end
      end

  2. #472
    Познающий Аватар для 100500
    Информация о пользователе
    Регистрация
    22.05.2011
    Сообщений
    351
    Записей в дневнике
    15
    Репутация: 28 Добавить или отнять репутацию

    По умолчанию

    Спойлер ошибка:
    ---------------------------
    Имя_Проекта
    ---------------------------
    Script 'Window_Selectable' line 100: NoMethodError occurred.

    undefined method `' for [nil, nil, nil, nil, nil, nil, nil, nil]:Array
    ---------------------------
    ОК
    ---------------------------


    А может кто-нибудь навскидку сказать, почему при вызове меню вылезает такая ошибка?
    зы ну то есть я знаю, почему - это из-за кучи скриптов в проекте. И при добавлении очередного стала появляться эта ошибка. А добавить я хотел бестиарий, вот этот
    Код:
    #-------------------------------------------------------------------------------
    #  * Munkis' Bestiary
    #  * V 1.1
    #  * Made by munkis
    #    ╔══════════╗
    #    ║ FEATURES ║
    #    ╚══════════╝
    #  * Pretty much self-explanitory; creates a bestiary that keeps track of what
    #    you've killed, how many different monsters you've collected data on, and
    #    total percentage of collected data.
    #  * Incompatible with other scripts that do the same thing.
    #  * You can add the following script call as a main menu or "script" event
    #    command: $scene = Munkis_Bestiary.new
    #  * V 1.0: Initial release
    #  * V 1.1: Fixed a minor bug that I just recently discovered where the monster
    #           data window wouldn't update properly when the user highlighted the
    #           index of a monster whose ID was in the NO_DATA_MONSTER array.  The
    #           messages now displayed can be changed from within the config module.
    #-------------------------------------------------------------------------------
    
    module MNK_Bestiary
    
      #Change the static text messages here.
      INFO_MESSAGE = ["'My First Animal Book'","Number Found:","Percent Completed:"]
    
      #Disable/Enable recording of monster data.
      NO_RECORD_SWITCH = 59
    
      #The data from these monsters will never be recorded.
      NO_DATA_MONSTER = [37]
    
      #Text to display on the index of a monster not being recorded in the bestiary.
      NO_RECORD_TEXT = ["Page Missing","This page is missing.  Where is it?"]
      
      #Shows a transparent box around the dropped items.
      SHOW_BOX = false
    
      #If the above is true, fill the box.
      FILL_BOX = true
    
      #Set the return destination here.
      RETURN_TO = Scene_Menu.new
    
    end
    
    #------------------------------------------------------------------------------
    #  * <Alias> Game_System
    #------------------------------------------------------------------------------
    class Game_System
      attr_accessor :bestiary
      alias :munkis_bestiary_ini :initialize
      def initialize
        munkis_bestiary_ini
        create_bestiary
      end
      def create_bestiary
        @bestiary ||= Array.new($data_enemies.size) {false}
      end
      def set_bestiary_complete
        @bestiary = Array.new($data_enemies.size) {true}
        @bestiary[0] = false
      end
      def reset_bestiary
        @bestiary = Array.new($data_enemies.size) {false}
      end
    end
    #------------------------------------------------------------------------------
    #  * <Alias> Game_Troop
    #------------------------------------------------------------------------------
    class Game_Troop < Game_Unit
      alias :munkis_bestiary_gamtroop_setup :setup
      def setup(*args)
        munkis_bestiary_gamtroop_setup(*args)
        $game_system.create_bestiary
        unless $game_switches[MNK_Bestiary::NO_RECORD_SWITCH]
          @enemies.each {|e| $game_system.bestiary[e.enemy_id] = true }
        end
      end
    end
    #------------------------------------------------------------------------------
    #  * This draws the Title bar.
    #------------------------------------------------------------------------------
    class Window_Bestiary_Title_Bar < Window_Base
      def initialize
        super(0, 0, 544, WLH + 32)
        contents.font.color = knockout_color
        contents.draw_text(0, 0, contents.width, WLH, MNK_Bestiary::INFO_MESSAGE[0])
      end
    end
    #------------------------------------------------------------------------------
    #  * This draws the monsters found bar.
    #------------------------------------------------------------------------------
    class Window_Bestiary_Data_Found_Bar < Window_Base
      def initialize
        super(0, WLH + 32, 272, WLH + 32)
        found_count = 0
        $game_system.bestiary.each {|e| found_count += 1 if e }
        found_text = found_count.to_s + '/' + ($data_enemies.size - 1).to_s
        right_text = MNK_Bestiary::INFO_MESSAGE[1] + found_text
        found_t_width = contents.text_size(MNK_Bestiary::INFO_MESSAGE[1]).width
        found_width = contents.text_size(found_text).width
        right_width = contents.text_size(right_text).width
        contents.font.color = normal_color
        contents.draw_text(contents.width - right_width, 0, contents.width, WLH, MNK_Bestiary::INFO_MESSAGE[1])
        contents.font.color = crisis_color
        contents.draw_text(contents.width - right_width + found_t_width, 0, contents.width, WLH, found_text)
      end
    end
    #------------------------------------------------------------------------------
    #  * This draws the percent completed bar.
    #------------------------------------------------------------------------------
    class Window_Bestiary_Data_Percent_Bar < Window_Base
      def initialize
        super(272, WLH + 32, 272, WLH + 32)
        found_count = 0
        $game_system.bestiary.each {|e| found_count += 1 if e }
        percent_count = (found_count * 100) / ($data_enemies.size - 1)
        percent_text = percent_count.to_s + '%'
        percent_t_width = contents.text_size(MNK_Bestiary::INFO_MESSAGE[2]).width
        right_text = MNK_Bestiary::INFO_MESSAGE[2] + percent_text
        right_width = contents.text_size(right_text).width
        contents.draw_text(contents.width - right_width, 0, contents.width, WLH, MNK_Bestiary::INFO_MESSAGE[2])
        contents.font.color = crisis_color
        contents.draw_text(contents.width - right_width + percent_t_width, 0, contents.width, WLH, percent_text)
      end
    end
    #------------------------------------------------------------------------------
    #  * This draws the monster data window.
    #------------------------------------------------------------------------------
    class Window_BestiaryDetail < Window_Base
      def initialize(window_temp)
        super(165, (WLH + 32) * 2, 380, 416 - ((WLH + 32) * 2))
        self.opacity = 255
        self.z = 1
        @last_enemy = 0
      end
      def write_detail(enemy_id)
        return if @last_enemy == enemy_id
        contents.clear
        @last_enemy = enemy_id
        data = $data_enemies[enemy_id]
        bitmap = Cache.battler(data.battler_name, data.battler_hue)
        bw = bitmap.width < 160 ? (160 - bitmap.width) / 2 : 0
        bh = contents.height - bitmap.height
        contents.blt(bw, bh, bitmap, bitmap.rect)
        bitmap.dispose
        contents.font.color = normal_color
        contents.draw_text(0, 0, contents.width, WLH,
        data.id.to_s + '.' + ' ' + data.name)
        hpx = 120
        draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH, hpx, 'hp')
        draw_enemy_stat(data, contents.width - hpx, WLH, hpx, 'mp')
        draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH * 2, hpx, 'atk')
        draw_enemy_stat(data, contents.width - hpx, WLH * 2, hpx, 'def')
        draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH * 3, hpx, 'spi')
        draw_enemy_stat(data, contents.width - hpx, WLH * 3, hpx, 'agi')
        draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH * 4, hpx, 'hit')
        draw_enemy_stat(data, contents.width - hpx, WLH * 4, hpx, 'eva')
        draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH * 5, hpx, 'exp')
        draw_enemy_stat(data, contents.width - hpx, WLH * 5, hpx, 'gold')
        if MNK_Bestiary::SHOW_BOX == true
          rect = Rect.new(contents.width - (hpx * 2)+36, (WLH * 8)-32, 204, (WLH * 4) + 16)
          contents.fill_rect(rect, Color.new(0,0,0,140)) if MNK_Bestiary::FILL_BOX == true
          lsize = 2
          lcolor = Color.new(255,255,255,160)
          contents.fill_rect(rect.x, rect.y, lsize, rect.height, lcolor)
          contents.fill_rect(rect.x, rect.y, rect.width, lsize, lcolor)
          contents.fill_rect(rect.x + rect.width - lsize, rect.y, lsize, rect.height, lcolor)
          contents.fill_rect(rect.x, rect.y + rect.height - lsize, rect.width, lsize, lcolor)
        end
        contents.font.color = system_color
        contents.draw_text(contents.width - (hpx * 2)+50, WLH * 6.8, 200, WLH, 'Drop Item 1')
        draw_enemy_drop(data, 1, contents.width - (hpx * 2)+50, WLH * 7.8)
        contents.font.color = system_color
        contents.draw_text(contents.width - (hpx * 2)+50, WLH * 8.8, 200, WLH, 'Drop Item 2')
        draw_enemy_drop(data, 2, contents.width - (hpx * 2)+50, WLH * 9.8)
      end
      def clear_detail
        @last_enemy = 0
        contents.clear
      end
      def draw_enemy_stat(actor, x, y, width, stat)
        color1 = system_color
        color2 = normal_color
        slash = false
          hactor = ($game_party.members.sort {|a,b| a.level <=> b.level })
          hactor = hactor[hactor.size - 1]
        case stat
        when 'hp'
          vocab = Vocab::hp
          number = actor.maxhp
          hnumber = hactor.maxhp
          slash = true
        when 'mp'
          vocab = Vocab::mp
          number = actor.maxmp
          hnumber = hactor.maxmp
          slash = true
        when 'atk'
          vocab = Vocab::atk
          number = actor.atk
          hnumber = hactor.atk
        when 'def'
          vocab = Vocab::def
          number = actor.def
          hnumber = hactor.def
        when 'spi'
          vocab = Vocab::spi
          number = actor.spi
          hnumber = hactor.spi
        when 'agi'
          vocab = Vocab::agi
          number = actor.agi
          hnumber = hactor.agi
        when 'hit'
          vocab = 'HIT'
          number = actor.hit
          hnumber = hactor.hit
        when 'eva'
          vocab = 'EVA'
          number = actor.eva
          hnumber = hactor.eva
        when 'exp'
          vocab = 'EXP'
          number = actor.exp
          color2 = crisis_color
        when 'gold'
          vocab = 'Gold'
          number = actor.gold
          color2 = crisis_color
        end
        if !hnumber.nil?
          if hnumber > number
            color2 = power_up_color
          elsif hnumber < number
            color2 = knockout_color
          elsif hnumber == number
            color2 = normal_color
          end
        end
        contents.font.color = color1
        contents.draw_text(x, y, 50, WLH, vocab)
        xr = x + width
        contents.font.color = color2
        if slash
          contents.draw_text(xr - 95, y, 40, WLH, number, 2)
          contents.draw_text(xr - 55, y, 11, WLH, '/', 2)
        end
        w_ava = slash ? 40 : 80
        contents.draw_text(xr - w_ava, y, w_ava, WLH, number, 2)
      end
      def draw_enemy_drop(actor, drop_id, x, y)
        drop = eval('actor.drop_item' + drop_id.to_s)
        if drop.kind.zero?
          contents.font.color = normal_color
          contents.draw_text(x, y, 200, WLH, "  ---------")
        else
          case drop.kind
          when 1; item = $data_items[drop.item_id]
          when 2; item = $data_weapons[drop.weapon_id]
          when 3; item = $data_armors[drop.armor_id]
          end
          draw_item_name(item, x, y)
        end
      end
    end
    #------------------------------------------------------------------------------
    #  * This draws the monster list window.
    #------------------------------------------------------------------------------
    class Munkis_Bestiary < Scene_Base
      #----------------------------------------------------------------------------
      # * Start processing
      #----------------------------------------------------------------------------
      def initialize(from_menu = false)
        @from_menu = from_menu
      end
      def start
        super
        create_menu_background
        $game_system.create_bestiary
        @window_title = Window_Bestiary_Title_Bar.new
        @window_data_found = Window_Bestiary_Data_Found_Bar.new
        @window_data_percent = Window_Bestiary_Data_Percent_Bar.new
        bestiary = []
        $game_system.bestiary.each_index do |i|
          next if i == 0
          if $game_system.bestiary[i] and !MNK_Bestiary::NO_DATA_MONSTER.include?(i)
            montext = i.to_s + '.' + ' ' + $data_enemies[i].name
          elsif MNK_Bestiary::NO_DATA_MONSTER.include?(i)
            montext = i.to_s + '.' + ' ' + MNK_Bestiary::NO_RECORD_TEXT[0]
          else
            montext = i.to_s + '.'
          end
          bestiary << montext
        end
        @window_bestiarylist = Window_Command.new(165, bestiary)
        @window_bestiarylist.y = @window_title.height + @window_data_found.height
        @window_bestiarylist.height = (Graphics.height - @window_title.height) - @window_data_found.height
        @window_bestiarydetail = Window_BestiaryDetail.new(@window_bestiarylist)
      end
      def update
        super
          @window_bestiarylist.update
          if !$game_system.bestiary[@window_bestiarylist.index + 1]
            @window_bestiarydetail.clear_detail
          end
          if $game_system.bestiary[@window_bestiarylist.index + 1] and !MNK_Bestiary::NO_DATA_MONSTER.include?(@window_bestiarylist.index + 1)
            @window_bestiarydetail.write_detail(@window_bestiarylist.index + 1)
          end
          if MNK_Bestiary::NO_DATA_MONSTER.include?(@window_bestiarylist.index + 1)
            @window_bestiarydetail.clear_detail
            @window_bestiarydetail.contents.draw_text(0, 0, @window_bestiarydetail.width, 32, MNK_Bestiary::NO_RECORD_TEXT[1])
          end
          if Input.trigger?(Input::B)
            Sound.play_cancel
            $scene = MNK_Bestiary::RETURN_TO
          end
      end
      def terminate
        super
        dispose_menu_background
        @window_title.dispose
        @window_data_found.dispose
        @window_data_percent.dispose
        @window_bestiarylist.dispose
        @window_bestiarydetail.dispose
      end
    end
    #------------------------------------------------------------------------------
    #  * This adds the entries to the monster list window.
    #------------------------------------------------------------------------------
    class Window_Command < Window_Selectable
      unless method_defined? :munkis_insert_command_ini
        alias munkis_insert_command_ini initialize
        alias munkis_insert_command_drawitem draw_item
      end
      #----------------------------------------------------------------------------
      # * <Alias> Initialize
      #----------------------------------------------------------------------------
      def initialize(*args)
        @disabled_commands = []
        munkis_insert_command_ini(*args)
      end
      #----------------------------------------------------------------------------
      # * <Alias> Draw_Item
      #----------------------------------------------------------------------------
      def draw_item(*args)
        munkis_insert_command_drawitem(*args)
        @disabled_commands[args[0]] = args[1].nil? || args[1] ? nil : true
      end
      #----------------------------------------------------------------------------
      # * Insert Command
      #----------------------------------------------------------------------------
      def ins_command(index, text)
        @commands.insert(index, text)
        @disabled_commands.insert(index, nil)
        old_disabled_commands = @disabled_commands.dup
        self.height = (@commands.size + @column_max - 1) / @column_max * WLH + 32
        @item_max = @commands.size
        create_contents
        refresh
        old_disabled_commands.each_index do |i|
          if !old_disabled_commands[i].nil?
            draw_item(i, false)
          end
        end
      end
      #----------------------------------------------------------------------------
      # * Add Command
      #----------------------------------------------------------------------------
      def add_command(text)
        ins_command(@commands.size, text)
      end
    end
    Но вроде бы он не вносит никаких изменений в коммандное окно...
    Последний раз редактировалось 100500; 08.08.2011 в 12:25.

  3. #473

    По умолчанию

    Правда не вносит?
    Код:
    class Window_Command < Window_Selectable
    unless method_defined? :munkis_insert_command_ini
    alias munkis_insert_command_ini initialize
    alias munkis_insert_command_drawitem draw_item
    end
    #----------------------------------------------------------------------------
    # * <Alias> Initialize
    #----------------------------------------------------------------------------
    def initialize(*args)
    @disabled_commands = []
    munkis_insert_command_ini(*args)
    end
    #----------------------------------------------------------------------------
    # * <Alias> Draw_Item
    #----------------------------------------------------------------------------
    def draw_item(*args)
    munkis_insert_command_drawitem(*args)
    @disabled_commands[args[0]] = args[1].nil? || args[1] ? nil : true
    end
    #----------------------------------------------------------------------------
    # * Insert Command
    #----------------------------------------------------------------------------
    def ins_command(index, text)
    @commands.insert(index, text)
    @disabled_commands.insert(index, nil)
    old_disabled_commands = @disabled_commands.dup
    self.height = (@commands.size + @column_max - 1) / @column_max * WLH + 32
    @item_max = @commands.size
    create_contents
    refresh
    old_disabled_commands.each_index do |i|
    if !old_disabled_commands[i].nil?
    draw_item(i, false)
    end
    end
    end
    #----------------------------------------------------------------------------
    # * Add Command
    #----------------------------------------------------------------------------
    def add_command(text)
    ins_command(@commands.size, text)
    end
    end
    Заключай код в теги CODE /CODE.
    И покажи - что у тебя там в Script 'Window_Selectable' line 100: NoMethodError occurred.

  4. #474
    Маститый Аватар для The Joker
    Информация о пользователе
    Регистрация
    16.06.2008
    Сообщений
    1,209
    Записей в дневнике
    11
    Репутация: 29 Добавить или отнять репутацию

    По умолчанию

    Код:
    #==============================================================================
    # ** RMXP Fog feature for RMVX
    #------------------------------------------------------------------------------
    # Allows you to display a fog on map. Brings back the "old" Fog feature from 
    # RPG Maker XP.
    # 08-03-2008 (dd-mm-yyyy) ?© Hevendor of rmxp.org
    # 09-03-2008 Edits/additions by Jirbytaylor
    # 09-03-2008 (dd-mm-yyyy) Edited by Hevendor
    # Version 1.2.3
    # Latest update: fixed bug where fog showed over pictures
    #==============================================================================
    
    module Fog_Map_Settings
      #============================================================================
      # * Configure Fog numbers -> names for setup timesaving. Format:
      # {fognumber => 'fogname.extension', ...}
      # where 'Fogname.extension' must be the name of a fog picture and its extension
      # located in the pictures folder
      #============================================================================
      Fog_names = {1 => '1.png',
                   2 => '2.png'}
      #============================================================================
      # * Set maps you wish to have fogs here. Format:
      # Fog_maps = {mapID => Fog number, mapID2 => Fog number, ...}
      #============================================================================
      Fog_maps = {002 => 1, 017 => 2, 018 => 2}
      #============================================================================
      # * Set up fog settings. Uses (fog number => setting, ...) format
      # - Opacity - Opacity of fog, ranging from 0 (invisible) to 255 (opaque)
      # - Zoom - size of fog. '1' is normal not '100'.
      # - Blend - 0 - Normal, 1 - Add, 2 - Subtract
      # - SxSy - Scroll settings. (fog number => [sx,sy] ...)
      #============================================================================
      Fog_opacity = {1 => 192, 2 => 192}
      Fog_zoom = {1 => 2, 2 => 2}
      Fog_blend = {1 => 2, 2 => 2}
      Fog_sxsy = {1 => [4, 4], 2 => [4, 4]}
    end
    
    class Game_Map
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      attr_reader :map_id                     # map ID
      attr_reader :fog_ox                     # fog oX
      attr_reader :fog_oy                     # fog oY
      #--------------------------------------------------------------------------
      # * Alias Definitions
      #--------------------------------------------------------------------------
      alias hev_fog_feature_map_update update
      alias hev_fog_feature_map_initialize initialize
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
        @fog_ox = 0
        @fog_oy = 0
        hev_fog_feature_map_initialize
      end
      #--------------------------------------------------------------------------
      # * Update Fog
      #--------------------------------------------------------------------------   
      def update_fog
        if Fog_Map_Settings::Fog_maps.include?($game_map.map_id)
          @fog_ox -= Fog_Map_Settings::Fog_sxsy[Fog_Map_Settings::Fog_maps[@map_id]][0] / 8.0
          @fog_oy -= Fog_Map_Settings::Fog_sxsy[Fog_Map_Settings::Fog_maps[@map_id]][1] / 8.0
        end
      end
      #--------------------------------------------------------------------------
      # * Frame Update
      #-------------------------------------------------------------------------- 
      def update
        hev_fog_feature_map_update
        update_fog
      end
    end
    
    class Spriteset_Map
      #--------------------------------------------------------------------------
      # * Alias Definitions
      #--------------------------------------------------------------------------
      alias hev_fog_feature_initialize initialize
      alias hev_fog_feature_create_viewports create_viewports
      alias hev_fog_feature_dispose dispose
      alias hev_fog_feature_update_viewports update_viewports
      alias hev_fog_feature_update update
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
        hev_fog_feature_initialize
        create_fog
      end
      #--------------------------------------------------------------------------
      # * Create Viewport
      #--------------------------------------------------------------------------
      def create_viewports
        @viewport4 = Viewport.new(0, 0, 544, 416)
        @viewport4.z = 9
        hev_fog_feature_create_viewports
      end
      #--------------------------------------------------------------------------
      # * Create Fog
      #-------------------------------------------------------------------------- 
      def create_fog
        @fog = Plane.new(@viewport4)
        if Fog_Map_Settings::Fog_maps.include?($game_map.map_id)
          fog_number = Fog_Map_Settings::Fog_maps[$game_map.map_id]
          update_fog
          @fog.bitmap = Cache.picture(Fog_Map_Settings::Fog_names[fog_number]) 
          @fog.opacity = Fog_Map_Settings::Fog_opacity[fog_number]
          @fog.zoom_x = @fog.zoom_y = Fog_Map_Settings::Fog_zoom[fog_number]
          @fog.blend_type = Fog_Map_Settings::Fog_blend[fog_number]
        end       
      end
      #--------------------------------------------------------------------------
      # * Update Fog Sprite
      #--------------------------------------------------------------------------
      def update_fog
        if @fog != nil
          @fog.ox = $game_map.display_x / 8 + $game_map.fog_ox
          @fog.oy = $game_map.display_y / 8 + $game_map.fog_oy
        end
      end
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        hev_fog_feature_update
        update_fog
      end
      #--------------------------------------------------------------------------
      # * Dispose of Fog Sprite
      #--------------------------------------------------------------------------
      def dispose_fog
        @fog.dispose
      end
      #--------------------------------------------------------------------------
      # * Dispose
      #--------------------------------------------------------------------------
      def dispose
        dispose_fog
        hev_fog_feature_dispose
      end
    end
    Вопрос. Скрипт, задающий фоги, работает на карте с ID002. Добавляю фог для карты ID017 - фог не работает, просто не отображается. А добавляю для восемнадцатой - выдает синтаксическую ошибку. На пол костьми ложусь, но ошибки в строчке 26
    Код:
      Fog_maps = {002 => 1, 017 => 2, 018 => 2}
    синтаксической ошибки не вижу. Это возможно исправить в скрипте, или же это ошибка из-за совместимости с каким-то другим скриптом? Но ошибка синтаксиса не должна появляться из-за других скриптов. Или я просто кретин?
    лол

  5. #475
    Познающий Аватар для 100500
    Информация о пользователе
    Регистрация
    22.05.2011
    Сообщений
    351
    Записей в дневнике
    15
    Репутация: 28 Добавить или отнять репутацию

    По умолчанию

    И покажи - что у тебя там в Script 'Window_Selectable' line 100: NoMethodError occurred.
    Вот.
    Код:
    def item_rect(index)
        rect = Rect.new(0, 0, 0, 0)
        rect.width = (contents.width + @spacing) / @column_max - @spacing
        rect.height = WLH
        rect.x = index % @column_max * (rect.width + @spacing)
        rect.y = index / @column_max * WLH
        return rect
      end
    Ошибку он видит в строке "rect.x = index % @column_max * (rect.width + @spacing)".

    зы меню стоит измененное, и там командное окно устроено в три столбца, по три строчки в каждом. Может оно каким-то образом причастно к этому недоразумению?

  6. #476

    По умолчанию

    The Joker
    Убери ведущие 0 в ID карт. Не 002, 017, 018, а 2, 17, 18. Уже была проблема из-за этого. Возможно, и у тебя из той же серии, тем паче, что они используются в словаре. Проверь, что 2.png сущесвует и в нем есть туман. Проект в студию (или в приват) - гляну.

    100500
    Вполне возможно. WLH существует? WLH = 32 перед первой rect = Rect.new(0, 0, 0, 0) ставить пробовал? Не поможет - проект в студию (или в приват).

  7. #477

    По умолчанию

    Чувствую себя идиотом и все же... как нарисовать круг заданного цвета?..
    И еще вопрос, поинтереснее. Можно ли заставить анимацию в бою прорисовываться под спрайтом баттлера? Если да, то как?
    ...sed semel insanivimus omnes...

  8. #478
    Познающий Аватар для 100500
    Информация о пользователе
    Регистрация
    22.05.2011
    Сообщений
    351
    Записей в дневнике
    15
    Репутация: 28 Добавить или отнять репутацию

    По умолчанию

    Каким-то непонятным образом прошляпил предыдущие посты, хотя тему вроде регулярно проверял. Очень очень странно.

    Equilibrium Keeper, я пока решил проблему, только вот не знаю, надолго ли))
    Отрезал от скрипта тот кусок, который вот этот
    Код:
    #------------------------------------------------------------------------------
    #  * This adds the entries to the monster list window.
    #------------------------------------------------------------------------------
    class Window_Command < Window_Selectable
      unless method_defined? :munkis_insert_command_ini
        alias munkis_insert_command_ini initialize
        alias munkis_insert_command_drawitem draw_item
      end
      #----------------------------------------------------------------------------
      # * <Alias> Initialize
      #----------------------------------------------------------------------------
      def initialize(*args)
        @disabled_commands = []
        munkis_insert_command_ini(*args)
      end
      #----------------------------------------------------------------------------
      # * <Alias> Draw_Item
      #----------------------------------------------------------------------------
      def draw_item(*args)
        munkis_insert_command_drawitem(*args)
        @disabled_commands[args[0]] = args[1].nil? || args[1] ? nil : true
      end
      #----------------------------------------------------------------------------
      # * Insert Command
      #----------------------------------------------------------------------------
      def ins_command(index, text)
        @commands.insert(index, text)
        @disabled_commands.insert(index, nil)
        old_disabled_commands = @disabled_commands.dup
        self.height = (@commands.size + @column_max - 1) / @column_max * WLH + 32
        @item_max = @commands.size
        create_contents
        refresh
        old_disabled_commands.each_index do |i|
          if !old_disabled_commands[i].nil?
            draw_item(i, false)
          end
        end
      end
      #----------------------------------------------------------------------------
      # * Add Command
      #----------------------------------------------------------------------------
      def add_command(text)
        ins_command(@commands.size, text)
      end
    end
    Метод решения проблемы исключительно дурацкий, но ввиду слабого (практически никакого) знания RGSS на другое я не способен.
    Однако, лишившись этого участка кода, скрипт всё равно работает как надо - при победе над тем или иным монстром он заносит его в список, да и командное окно исправно работает. И в меню теперь зайти можно, ошибка не случается.
    Только вот одно интересно - нафига тогда этот кусок вообще нужен в этом скрипте? За что он отвечает?

  9. #479

    По умолчанию

    Цитата Сообщение от Nefas Посмотреть сообщение
    Чувствую себя идиотом и все же... как нарисовать круг заданного цвета?..
    И еще вопрос, поинтереснее. Можно ли заставить анимацию в бою прорисовываться под спрайтом баттлера? Если да, то как?
    Код:
    Module Graphics
    #----------------------------------------------------------------------------
      # Возвращает массив координат точек, лежащих на окружности
      # Возвращает :[[i, i],..,[i, i]]
      # center     :[i, i]  - координаты x, y центра окружности
      # radius     :[i, i]  - координаты x, y точки лежащей на окружности
      # -radius    :integer - радиус окружности
      # accuracy   :integer {1~5) - точность вычислений; nil - автоматически
      #   чем больше значение accuracy, тем дольше расчеты
      #----------------------------------------------------------------------------
      def self.calculate_circle (center, radius, accuracy = nil)
        if radius.is_a?(Array)
          catet_x = (radius[0] - center[0]).abs
          catet_y = (radius[1] - center[1]).abs
          radius = hypot(catet_x, catet_y)
        end
        if accuracy == nil then accuracy = 1 + radius/100 end
        angle = 0
        array = []
        while angle > -360 * accuracy && angle < 360 * accuracy
          x = center[0] + radius * cos(PI * angle.to_f / (180 * accuracy))
          y = center[1] + radius * sin(PI * angle.to_f / (180 * accuracy))
          angle += 1
          unless array.include?([x.round, y.round])
            array.push([x.round, y.round])
          end
        end
        return array
      end
    end
    
    class Bitmap
    #----------------------------------------------------------------------------
      # Рисует точки заданной величины в координатах, взятых из массива
      # points      :[[i, i],..,[i, i]] - двумерный массив координат x, y точек
      # start_color :color   - цвет, которым будет изображена первая точка
      # width       :integer {1~5) - размер точек
      # end_color   :color - цвет, которым будет изображена последняя точка
      #  если начальный цвет и конечный совподают, то все точки будут нарисованы
      #  начальным цветом, в противном случае будет осуществлен плавный переход цвета
      #----------------------------------------------------------------------------
      def draw_rout (points, start_color, width = 1, end_color = start_color)
        if end_color == start_color
          for i in 0...points.size
            if width == 1
              self.set_pixel(points[i][0], points[i][1], start_color)
            else
              self.fill_rect(points[i][0], points[i][1], width, width, start_color)
            end
          end
        else
          for i in 0...points.size
            # Graphics.update # Следить за линией
            r = start_color.red   * (points.size-1-i)/(points.size-1) + end_color.red   * i/(points.size-1)
            g = start_color.green * (points.size-1-i)/(points.size-1) + end_color.green * i/(points.size-1)
            b = start_color.blue  * (points.size-1-i)/(points.size-1) + end_color.blue  * i/(points.size-1)
            a = start_color.alpha * (points.size-1-i)/(points.size-1) + end_color.alpha * i/(points.size-1)
            if width == 1
              self.set_pixel(points[i][0], points[i][1], Color.new(r, g, b, a))
            else
              self.fill_rect(points[i][0], points[i][1], width, width, Color.new(r, g, b, a)) 
            end
          end
        end
      end
    end
    Код:
    points = Graphics.calculate_circle ([5, 20], 10)
    bitmap = Bitmap.new(50, 50)
    bitmap.draw_rout(points , Color.new(255, 255, 255), 3)
    @sprite = Sprite.new()
    @sprite.bitmap = bitmap
    Возможно, есть варианты и получше - эти методы писал сам и очень, очень давно.

    Вопроса по-интереснее не понял. Battler и выводится, как спрайт. Что ты хочешь?

    100500
    Там какая-то левая вставка комманд "на лету", без пересоздания всего объекта (хотя странно, что нет удаления в таком случае), и еще какой-то изврат, назначение которого без контекста не ясно. Возможно, он пытался добиться совместимости с чем-то. Быть может, эти его "фичи" он и сам нигде не использует - вот и работает скрипт как надо.
    Последний раз редактировалось Equilibrium Keeper; 12.08.2011 в 10:31.

  10. #480
    Познающий Аватар для 100500
    Информация о пользователе
    Регистрация
    22.05.2011
    Сообщений
    351
    Записей в дневнике
    15
    Репутация: 28 Добавить или отнять репутацию

    По умолчанию

    Equilibrium Keeper, понятно. Спасибо что посмотрел.

Страница 48 из 147 ПерваяПервая ... 3846474849505898 ... ПоследняяПоследняя

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 3 (пользователей: 0 , гостей: 3)

Метки этой темы

Социальные закладки

Социальные закладки

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •  
Помощь с скриптами (RGSS)