查看: 1891|回复: 4

[已经解决] 换个问题 请问这个脚本 显示在游戏里的时候怎么换行

[复制链接]
奖 100 星屑 回复本帖可获得 10 星屑奖励! 每人限 2 次(中奖概率 50%)
梦石
0
星屑
2016
在线时间
318 小时
注册时间
2020-3-17
回帖
43
发表于 2022-3-15 15:16:21 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 SYK1494715212 于 2022-3-18 16:53 编辑

就是下面那个脚本
里面的说明内容不管怎么写都是一行
想知道有没有什么办法让那个说明在游戏里显示的时候
换行
不要全都挤在一起

因为换了个问题所以
下面的图可以无视

[pre lang="ruby"]#~ #== Szyu Scripts presents =====================================================
# * Szyu Scripts' 简单派系
# Version 1.1
# by Szyu
#
#== Download ==================================================================
# * pastebin:
# http://adf.ly/4920670/simple-factions
#
#== About =====================================================================
# * 该脚本可以为游戏添加自定义派系系统,可以使用事件脚本进行控制
#
#== 使用方法 ================================================================
# * 在下面的 SZS_Factions 模块中修改设定.
#
# * 使用  $game_factions[索引]  来引用指定索引的派系
#   !第一个派系的索引是 0!
#
# * 增加派系声望值:
#    $game_factions.gain_reputation(id, 数值)   
#   减少派系声望值:
#    $game_factions.lose_reputation(id, 数值)
#   如果派系不可见,数值变动将不会出现在派系列表里
#
# * 设定当前事件页的派系,使用注释: <faction: 索引>  
#
# * 在分支条件里使用脚本检查当前事件页的派系:
#   event.faction
#   结果将返回事件的派系索引,无派系时返回  nil.
#
# * 在分支条件里使用脚本:
#   if event.faction && $game_factions[event.faction].reputation > x
#   来对比当前事件的派系值是否大于x
#
#== Terms of Use ==============================================================
# * You are free to use this script for commercial and non-commercial projects.
# However I'd like you to inform me of the projects you are planning to use it
# in, so I can keep track of where my scripts are used.
#
#== Import ====================================================================
$imported = {} if $imported.nil?
$imported["SZ-FACTIONS"] = true
#==============================================================================
module SZS_Factions
  # 设定派系等级:
  #   :name       - 派系等级名称
  #   :rep_min    - 派系等级的最低值
  #   :bar_color1 - Default_BarColor1为nil或未定义时显示的值槽的颜色1
  #   :bar_color2 - Default_BarColor2为nil或未定义时显示的值槽的颜色2
  Levels = [
    {:name => "过街老鼠", :rep_min => 0,
          :bar_color1 => Color.new(220, 20,18),
          :bar_color2 => Color.new(140, 5,30)},
         
    {:name => "芸芸众生", :rep_min =>  1000,
          :bar_color1 => Color.new(40, 32, 218)},
         
    {:name => "略有耳闻", :rep_min => 1800},
   
    {:name => "声名显赫", :rep_min => 2400,
          :bar_color1 => Color.new(52, 242, 32)}
  ]
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # 派系类别. 可以自由增减派系类别:
  #   :faction  - 定义符号, 类似 :type => "巴啦啦小魔仙"   
  FactionType = {
      :faction => "商业派系",
      :individual => "独立派系"
  }
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # 派系列表:
  #   :name           - 派系名称
  #   :type           - 派系类别
  #   :initial_value  - 派系初始声望值
  #   :discovered     - 该派系是否在游戏一开始就可见
  #   :graphic        - 显示的图像
  #   :description    - 显示的说明文字
  Factions = [
    {:name => "复仇者联盟", :type => :faction, :initial_value => 1250, :discovered => true,
      :graphic => "logo",:description =>
      "硬核派系,总是取胜。忠诚是其会员得原则之一,面对它们时不要掉以轻心..."},
    {:name => "创世纪协会", :type => :faction, :initial_value => 1000},
    {:name => "地球猫猫教", :type => :individual, :initial_value => 0,:discovered => true,
      :graphic => "logo",:description => "你已被猫猫包围。"},
  ]
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # 是否启用菜单指令
  UseInMenu = true
  MenuTerm = "派系"
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # 是否显示派系说明文字、图像和说明文字对齐方式
  UseDescriptions = false
  UseGraphics = false
  DescriptionAlignment = 1
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # 派系声望值上限
  MaxReputation = 2500
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # 拍戏声望值值槽默认的颜色1和颜色2
  Default_BarColor1 = Color.new(172,196,36)
  Default_BarColor2 = Color.new(82,106,16)
end

#==============================================================================
# ** Game Faction
#==============================================================================
class Game_Faction
  attr_reader :id
  attr_reader :name
  attr_reader :reputation
  attr_reader :type
  attr_reader :level
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(id)
    @id = id
    fac = SZS_Factions::Factions[id]
    @name = fac[:name]
    @type = fac[:type]
    @reputation = fac[:initial_value]
    check_level
  end
  #--------------------------------------------------------------------------
  # * Gain Reputation
  #--------------------------------------------------------------------------
  def gain_reputation(amount)
    @reputation += amount
    check_level
  end
  #--------------------------------------------------------------------------
  # * Lose Reputation
  #--------------------------------------------------------------------------
  def lose_reputation(amount)
    gain_reputation(-amount)
  end
  #--------------------------------------------------------------------------
  # * Check Reputation Level
  #--------------------------------------------------------------------------
  def check_level
    lv = -1
    SZS_Factions::Levels.each do |rlv|
      lv += 1 if @reputation >= rlv[:rep_min]
    end
    @level = lv
  end
end

#==============================================================================
# ** Game Factions
#==============================================================================
class Game_Factions
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @data = []
  end
  #--------------------------------------------------------------------------
  # * Get Actor
  #--------------------------------------------------------------------------
  def [](fac_id)
    return nil unless SZS_Factions::Factions[fac_id]
    @data[fac_id] ||= Game_Faction.new(fac_id)
  end
  #--------------------------------------------------------------------------
  # * Get All Factions not nil
  #--------------------------------------------------------------------------
  def all_factions
    return @data.select{|f| !f.nil?}
  end
  #--------------------------------------------------------------------------
  # * Get All Factions of a certain type
  #--------------------------------------------------------------------------
  def factions_of(type)
    return @data.select{|f| !f.nil? && f.type == type}
  end
  #--------------------------------------------------------------------------
  # * Gain Reputation
  #--------------------------------------------------------------------------
  def gain_reputation(fac_id, amount)
    return nil unless SZS_Factions::Factions[fac_id]
    @data[fac_id] ||= Game_Faction.new(fac_id)
    @data[fac_id].gain_reputation(amount)
  end
  #--------------------------------------------------------------------------
  # * Lose Reputation
  #--------------------------------------------------------------------------
  def lose_reputation(fac_id, amount)
    gain_reputation(fac_id, -amount)
  end
end

#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Get Faction ID of the event's current page
  #--------------------------------------------------------------------------
  def faction
    @page.list.map{|l| l.parameters}.each do |line|
      next if line[0].nil?
      if line[0] =~ /<faction:\s*(\d+)\s*>/i
        fac_id = $1.to_i
        return fac_id if SZS_Factions::Factions[fac_id]
      end
    end
    return nil
  end
end

#==============================================================================
# ** Game_Interpreter
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Get Current event
  #--------------------------------------------------------------------------
  def event
    $game_map.events[@event_id] || nil
  end
end

#==============================================================================
# ** DataManager
#==============================================================================
class << DataManager
  alias :szs_factions_create_game_objects :create_game_objects
  alias :szs_factions_make_save_contents :make_save_contents
  alias :szs_factions_extract_save_contents :extract_save_contents
  alias :szs_factions_setup_new_game :setup_new_game
  #--------------------------------------------------------------------------
  # * Create Game Objects
  #--------------------------------------------------------------------------
  def create_game_objects
    szs_factions_create_game_objects
    $game_factions = Game_Factions.new
  end
  #--------------------------------------------------------------------------
  # * Create Save Contents
  #--------------------------------------------------------------------------
  def make_save_contents
    contents = szs_factions_make_save_contents
    contents[:factions]        = $game_factions
    contents
  end
  #--------------------------------------------------------------------------
  # * Extract Save Contents
  #--------------------------------------------------------------------------
  def extract_save_contents(contents)
    szs_factions_extract_save_contents(contents)
    $game_factions        = contents[:factions]
  end
  #--------------------------------------------------------------------------
  # * Set Up New Game
  #--------------------------------------------------------------------------
  def setup_new_game
    szs_factions_setup_new_game
    SZS_Factions::Factions.select{|f| f[:discovered]}.each do |f|
      $game_factions[SZS_Factions::Factions.index(f)]
    end
  end
end

#==============================================================================
# ** Scene FactionList
#==============================================================================
class Scene_FactionList < Scene_Base
  #--------------------------------------------------------------------------
  # * Start
  #--------------------------------------------------------------------------
  def start
    super
    create_category_window
    create_help_window
    create_fac_list_window
    create_desc_window if SZS_Factions::UseDescriptions
  end
  #--------------------------------------------------------------------------
  # * Create Category Window
  #--------------------------------------------------------------------------
  def create_category_window
    @category_win = Window_FactionCategory.new
    @category_win.set_handler(:ok,     method(:on_category_ok))
    @category_win.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * Create Status Window
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_FactionStatus.new
  end
  #--------------------------------------------------------------------------
  # * Create List Window
  #--------------------------------------------------------------------------
  def create_fac_list_window
    y = @category_win.height
    w = Graphics.width
    h = Graphics.height-y-@help_window.height
    w /= 2 if SZS_Factions::UseDescriptions
    @fac_list_win = Window_FactionList.new(0,y,w,h)
    @fac_list_win.help_window = @help_window
    @fac_list_win.set_handler(:cancel, method(:on_faction_cancel))
    @category_win.reputation_window = @fac_list_win
  end
  #--------------------------------------------------------------------------
  # * Create Description Window
  #--------------------------------------------------------------------------
  def create_desc_window
    y = @category_win.height
    h = Graphics.height-y-@help_window.height
    x = @fac_list_win.width
    w = Graphics.width - x
    @desc_window = Window_FactionDescription.new(x,y,w,h)
    @fac_list_win.description_window = @desc_window
  end
  #--------------------------------------------------------------------------
  # * Terminate
  #--------------------------------------------------------------------------
  def terminate
    super
    @category_win.dispose
    @fac_list_win.dispose
    @help_window.dispose
    @desc_window.dispose if @desc_window
  end
  #--------------------------------------------------------------------------
  # * On Category selected
  #--------------------------------------------------------------------------
  def on_category_ok
    @fac_list_win.activate.select(0)
  end
  #--------------------------------------------------------------------------
  # * On List cancel
  #--------------------------------------------------------------------------
  def on_faction_cancel
    @fac_list_win.deactivate.select(-1)
    @help_window.faction = nil
    @desc_window.faction = nil if @desc_window
    @category_win.activate
  end
end

#==============================================================================
# ** Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
  alias :szs_factions_create_command_window :create_command_window
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    szs_factions_create_command_window
    @command_window.set_handler(:factions, method(:command_factions))
  end
  #--------------------------------------------------------------------------
  # * Command Factions
  #--------------------------------------------------------------------------
  def command_factions
    SceneManager.call(Scene_FactionList)
  end
end

#==============================================================================
# ** Window_FactionCategory
#==============================================================================
class Window_FactionCategory < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :reputation_window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return SZS_Factions::FactionType.size
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    @reputation_window.category = current_symbol if @reputation_window
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    SZS_Factions::FactionType.each do |k, v|
      add_command(v,k)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Item Window
  #--------------------------------------------------------------------------
  def reputation_window=(reputation_window)
    @reputation_window = reputation_window
    update
  end
end

#==============================================================================
# ** Window_FactionList
#==============================================================================
class Window_FactionList < Window_Selectable
  attr_reader :description_window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super
    @category = :none
    @data = []
  end
  #--------------------------------------------------------------------------
  # * Set Category
  #--------------------------------------------------------------------------
  def category=(category)
    return if @category == category
    @category = category
    refresh
    self.oy = 0
  end
  #--------------------------------------------------------------------------
  # * Set Description Window
  #--------------------------------------------------------------------------
  def description_window=(dw)
    @description_window = dw
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return SZS_Factions::UseDescriptions ? 1 : 2
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  #--------------------------------------------------------------------------
  # * Get Activation State of Selection Item
  #--------------------------------------------------------------------------
  def current_item_enabled?
    return true
  end
  #--------------------------------------------------------------------------
  # * Create Item List
  #--------------------------------------------------------------------------
  def make_item_list
    @data = $game_factions.factions_of(@category)
  end
  #--------------------------------------------------------------------------
  # * Restore Previous Selection Position
  #--------------------------------------------------------------------------
  def select_last
    select(@data.index($game_party.last_item.object) || 0)
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_text_ex(rect.x,rect.y, item.name)
    end
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
  def update_help
    @help_window.faction = item if @help_window
    @description_window.faction = item if @description_window
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
end

#==============================================================================
# ** Window_FactionStatus
#==============================================================================
class Window_FactionStatus < Window_Base
  attr_reader :faction
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    h = fitting_height(1)
    super(0,Graphics.height-h,Graphics.width, h)
  end
  #--------------------------------------------------------------------------
  # * Set Faction
  #--------------------------------------------------------------------------
  def faction=(faction)
    @faction=faction
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    return unless @faction
    draw_reputation
    draw_reputation_text
  end
  #--------------------------------------------------------------------------
  # * Draw Reputation
  #--------------------------------------------------------------------------
  def draw_reputation
    draw_rep_gauge(0, 0, contents.width/3*2,line_height-8,
      @faction.reputation.to_f/SZS_Factions::MaxReputation,
      hp_gauge_color1, hp_gauge_color2)
    change_color(system_color)
    draw_current_and_max_values(96, 0, 132,
      @faction.reputation, SZS_Factions::MaxReputation,
      normal_color, normal_color)
  end
  #--------------------------------------------------------------------------
  # * Draw Reputation Gauge
  #--------------------------------------------------------------------------
  def draw_rep_gauge(x, y, width,height, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y+(line_height-height)/2
    contents.fill_rect(x, gauge_y, width, height, gauge_back_color)
    contents.gradient_fill_rect(x, gauge_y, fill_w, height,
    SZS_Factions::Levels[faction.level][:bar_color1] || SZS_Factions::Default_BarColor1,
    SZS_Factions::Levels[faction.level][:bar_color2] || SZS_Factions::Default_BarColor2)
  end
  #--------------------------------------------------------------------------
  # * Draw Reputation Text
  #--------------------------------------------------------------------------
  def draw_reputation_text
    x = contents.width/3*2+8
    txt = SZS_Factions::Levels[faction.level][:name]
    fc = Color.new(0,0,0,96)
    contents.fill_rect(x,0,contents.width-x,line_height, fc)
    draw_text(x,0,contents.width-x,line_height, txt,1)
  end
end

#==============================================================================
# ** Window_FactionDescription
#==============================================================================
class Window_FactionDescription < Window_Base
  attr_reader :faction
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(x,y,w,h)
    super(x,y,w,h)
  end
  #--------------------------------------------------------------------------
  # * Set Faction
  #--------------------------------------------------------------------------
  def faction=(faction)
    @faction=faction
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    return unless @faction
    draw_faction_graphic if SZS_Factions::UseGraphics
    draw_faction_desc if SZS_Factions::UseDescriptions
  end
  #--------------------------------------------------------------------------
  # * Draw Faction Graphic
  #--------------------------------------------------------------------------
  def draw_faction_graphic
    return unless SZS_Factions::Factions[@faction.id][:graphic]
    gr = Cache.picture(SZS_Factions::Factions[@faction.id][:graphic])
    aspect = gr.width.to_f / gr.height.to_f
    h = contents.width * aspect
    contents.stretch_blt(Rect.new(0,(contents.height-h),contents.width, h),
        gr, Rect.new(0,0,gr.width, gr.height))
  end
  #--------------------------------------------------------------------------
  # * Draw Faction Description
  #--------------------------------------------------------------------------
  def draw_faction_desc
    return unless SZS_Factions::Factions[@faction.id][:description]
    i = 0
    split_text(SZS_Factions::Factions[@faction.id][:description]).each do |line|
      draw_line_back(0, line_height*i, contents.width, line_height)
      draw_text(0, line_height * i, contents.width, line_height, line, SZS_Factions::DescriptionAlignment)
      i += 1
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Line Back
  #--------------------------------------------------------------------------
  def draw_line_back(x,y,w,h)
    contents.fill_rect(x,y+1,w,h-2, Color.new(0,0,0,96))
  end
  #--------------------------------------------------------------------------
  # * Split Text
  #--------------------------------------------------------------------------
  def split_text(txt)
    txt_splits = []
    line = ""
    txt.split.each do |word|
      line += word + " "
      if contents.text_size(line).width > width
        txt_splits << line
        line = ""
      end
    end
    txt_splits << line if line.size > 0
    txt_splits
  end
end

#==============================================================================
# ** Window_MenuCommand
#==============================================================================
class Window_MenuCommand < Window_Command
  alias :szs_factions_add_original_commands :add_original_commands
  #--------------------------------------------------------------------------
  # * For Adding Original Commands
  #--------------------------------------------------------------------------
  def add_original_commands
    szs_factions_add_original_commands
    add_command(SZS_Factions::MenuTerm,   :factions) if SZS_Factions::UseInMenu
  end
end[/pre]
X(T}DWIK6M7L(QIXWV]GN33.png
↖这就是个新手,什么都不懂,大佬见谅。
梦石
0
星屑
2016
在线时间
318 小时
注册时间
2020-3-17
回帖
43
 楼主| 发表于 2022-3-15 20:47:40 | 显示全部楼层
真的,求求各位大佬了……
要我重新发个悬赏也行啊……
↖这就是个新手,什么都不懂,大佬见谅。
回复

使用道具 举报

梦石
0
星屑
2016
在线时间
318 小时
注册时间
2020-3-17
回帖
43
 楼主| 发表于 2022-3-18 16:54:50 | 显示全部楼层
就是:description那里……
↖这就是个新手,什么都不懂,大佬见谅。
回复

使用道具 举报

梦石
0
星屑
10713
在线时间
922 小时
注册时间
2017-10-10
回帖
23
发表于 2022-3-21 16:10:57 | 显示全部楼层
你要的效果?

1

1

只要这样...

2

2

还是问题已经解决了?

点评

解决了,还是谢谢回答了。  发表于 2022-3-22 17:37
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部