查看: 3619|回复: 1

[已经解决] (已自行解决)全局开关变量与变量控制标题画面

[复制链接]
梦石
20
星屑
13965
在线时间
1744 小时
注册时间
2017-1-12
回帖
1667

MZ评测员开拓者

发表于 2020-5-5 10:47:01 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 火锅深处 于 2020-5-5 13:17 编辑

已解决,搜到了。
https://rpg.blue/thread-366001-1-1.html
===========================================
用的是下面这两个脚本。想实现的效果就是用变量5控制标题画面的变化,但现在那个换标题的脚本貌似是要玩家主动存档后才能发挥作用,我希望的就是只要变量5变化哪怕玩家不存档也能换标题。
大概能理解是因为换标题那个脚本没有“检查”全局变量脚本里的“System_Save.rvdata2”,所以要怎么改呢?
P.S.喵呜喵5的全局变量和换标题画面的脚本已经尝试过了,但是那个又和现有的其他脚本冲突。_(:з」∠)_
VIPArcher全局变量
[pre lang="ruby"]#===============================================================================
# 全局变量开关
#  By:VIPArcher [email: VIPArcher@sina.com]
#  -- 本脚本来自 http://rm.66rpg.com 使用或转载请保留以上信息。
#===============================================================================
# 说明:
#   把所有开关变量储存到一个文件中,开始新游戏时或者读档时自动载入该文件中设定好的
#   某些开关变量,应该也可以用于制作多结局多周目之类的功能。通关一个结局时事件脚本
#   调用 save_vs_data 一下就可以把当前的开关变量储存到一个文件中。
#===============================================================================
$VIPArcherScript ||= {};$VIPArcherScript[:save_varsw] = 20150121
#-------------------------------------------------------------------------------
module VIPArcher end
#==============================================================================
#  ☆ 设定部分 ☆
#==============================================================================
module VIPArcher::GLOBAL
  FILEURL = "Saves"             #储存数据的文件夹
  NAME = "System_Save.rvdata2"  #储存数据的文件名
  VAR = [5]   # 新游戏/读档时载入的变量
  SW  = []   # 新游戏/读档时载入的开关
end
#==============================================================================
#  ★ 设定结束 ★
#==============================================================================
module VIPArcher::GLOBAL
  FILENAME = FILEURL + "/" + NAME
  #--------------------------------------------------------------------------
  # ● 储存开关变量数据
  #--------------------------------------------------------------------------
  def self.save_data
    Dir.mkdir(FILEURL) unless FileTest.exist?(FILEURL)
    File.open(FILENAME , "wb") do |file|
      Marshal.dump(make_contents, file)
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取开关变量数据
  #--------------------------------------------------------------------------
  def self.make_contents
    contents = {}
    contents[:switches] = $game_switches
    contents[:variable] = $game_variables
    contents
  end
  #--------------------------------------------------------------------------
  # ● 读取变量数据
  #--------------------------------------------------------------------------
  def self.load_var(id)
    File.open(FILENAME , "rb") do |file|
      game_variables = Marshal.load(file)[:variable]
      $game_variables[id] = game_variables[id]
    end ; rescue
  end
  #--------------------------------------------------------------------------
  # ● 读取开关数据
  #--------------------------------------------------------------------------
  def self.load_sw(id)
    File.open(FILENAME , "rb") do |file|
      game_switches = Marshal.load(file)[:switches]
      $game_switches[id] = game_switches[id]
    end ; rescue
  end
  #--------------------------------------------------------------------------
  # ● 载入 VAR 和 SW 的开关和变量
  #--------------------------------------------------------------------------
  def self.load_game_versw
    VAR.each { |id| load_var(id) } ; SW.each { |id| load_sw(id) }
  end
end
#-------------------------------------------------------------------------------
class << DataManager
  #--------------------------------------------------------------------------
  # ● 设置新游戏
  #--------------------------------------------------------------------------
  alias_method :new_game_data , :setup_new_game
  def setup_new_game
    new_game_data ; VIPArcher::GLOBAL.load_game_versw
  end
end
#-------------------------------------------------------------------------------
class Game_System
  #--------------------------------------------------------------------------
  # ● 读档后的处理
  #--------------------------------------------------------------------------
  alias_method :after_load_data , :on_after_load
  def on_after_load
    after_load_data ; VIPArcher::GLOBAL.load_game_versw
  end
end
#-------------------------------------------------------------------------------
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● 储存开关变量数据
  #--------------------------------------------------------------------------
  def save_vs_data ; VIPArcher::GLOBAL.save_data end
  #--------------------------------------------------------------------------
  # ● 读取变量数据
  #--------------------------------------------------------------------------
  def load_var(*args)
    args.each { |id| VIPArcher::GLOBAL.load_var(id) }
  end
  #--------------------------------------------------------------------------
  # ● 读取开关数据
  #--------------------------------------------------------------------------
  def load_sw(*args)
    args.each { |id| VIPArcher::GLOBAL.load_sw(id)  }
  end
end[/pre]

Racheal更换标题图
[pre lang="ruby"]#==============================================================================
# Dynamic Title
# by: Racheal
# Version 1.1
# Created: 24/06/2013
# Updated: 27/09/2013
#==============================================================================
# Changes the title screen based on a variable set in-game.
#==============================================================================
# Instructions:
# * Insert in the Materials section
# * Configure to your liking below
#==============================================================================
# Compatibility:
# This script is for RPG Maker VX Ace
# It is unlikely to work with anything that modifies the way the
# title screen is drawn such as an animated title screen
# * Overwrites: Scene_Title: create_background
=begin
Credit
- Racheal

Author's Notes
Free for commercial and non-commercial use. Just credit me (and let me know if you use it, just because). There's really not too much to this script. Version 1.1 features increased compatibility with save systems thanks to estriole's tip.

As this is a script that modifies the save header, it will not work with saves created before this script was installed.
=end
#==============================================================================

#==============================================================================
# Customization
#==============================================================================
module Racheal_Title
  #Set which variable controls the change in the title screen
  TITLE_VARIABLE = 5
  
  #Set which parts of the title screen are affected
  CHANGE_BACKGROUND = true
  CHANGE_FOREGROUND = true
  
  #Set whether to check the highest variable in all the save files or
  #just use the most recent save
  CHECK_ALL_SAVES = false
  
  #Set whether to use a series of numbers for the filenames (0.png, 1.png, etc)
  #or a series of names you define below
  USE_FILENAMES = true
  BACKGROUND_NAMES = ["Title0", "BTitle","Title0"]
  FOREGROUND_NAMES = ["Layer1", "Layer1", "Layer1"]
end
#==============================================================================
# End Customization
#==============================================================================

#==============================================================================
# ** DataManager
#==============================================================================

module DataManager
  #--------------------------------------------------------------------------
  # * Create Save Header
  #--------------------------------------------------------------------------
  class << self; alias dynamic_title_make_save_header make_save_header; end
  def self.make_save_header
      header = dynamic_title_make_save_header
      header[:title] = $game_variables[Racheal_Title::TITLE_VARIABLE]
      header
  end
end

#==============================================================================
# ** Scene_Title
#==============================================================================

class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Create Background
  #--------------------------------------------------------------------------
  def create_background
    @sprite1 = Sprite.new
    sprite_name = Racheal_Title::CHANGE_BACKGROUND ? get_title(1) : $data_system.title1_name
    @sprite1.bitmap = Cache.title1(sprite_name)
    @sprite2 = Sprite.new
          @sprite2.z = 99#自己加的
    sprite_name = Racheal_Title::CHANGE_FOREGROUND ? get_title(2) : $data_system.title2_name
    @sprite2.bitmap = Cache.title2(sprite_name)
    center_sprite(@sprite1)
    center_sprite(@sprite2)
  end
  #--------------------------------------------------------------------------
  # * Get Title Sprite Name
  #--------------------------------------------------------------------------
  def get_title(num)
    title = 0
    if Racheal_Title::CHECK_ALL_SAVES
      #Check all saves
      for i in 0...DataManager.savefile_max
        header = DataManager.load_header(i)
        next unless header and header[:title]
        title = [title, header[:title]].max
      end
    else
      #Check latest save
      header = DataManager.load_header(DataManager.latest_savefile_index)
      if header and header[:title]
        title = [title, header[:title]].max
      end
    end
    #---
    if Racheal_Title::USE_FILENAMES
      #convert number to name
      case num
      when 1
        return Racheal_Title::BACKGROUND_NAMES[title]
      when 2
        return Racheal_Title::FOREGROUND_NAMES[title]
      end
    else
      return title.to_s
    end
  end
end[/pre]

评分

参与人数 1赞 +1 收起 理由
chanszeman1018 + 1 认可答案

查看全部评分

梦石
0
星屑
11809
在线时间
623 小时
注册时间
2016-8-25
回帖
1340

R考场第七期纪念奖

发表于 2020-5-5 12:25:07 | 显示全部楼层
如果是事件标题

可能会简单不少
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部