じ☆ve冰风 发表于 2026-8-3 08:05:02

KTitleUpdate ACE

KTItleUpdate ACE

by Kyonides​

Introduction


Well, I think the title is pretty much self descriptive but here we go!

Did you ever need to dynamically change your Title Scene but couldn't do it on your own?
Then use this scriptlet and you will be able to do it by yourself!

This is NOT a Plug and Play Script, yet, it will work from the very beginning if you are using the default assets in your game project.


Please read the instructions embedded in my script.

                Ruby:       
# * KTitleUpdate ACE * #
#   Scripter : Kyonides Arkanthes
#   2023-06-16

# This scriptlet lets you change the Background and Foreground Titles of your
# game project based on the value of a predefined Game Variable.

# You must configure 7 CONSTANTS to tell it which Title will be displayed on
# screen at that specific point.

# * Warning! * #
# If you don't use the Scene_End menu scene, delete that part from this script.

module KTitleUpdate
# For the Game's Root Save Directory the String might be "Save*"
# For a Custom Save Directory the String might be "CustomDir/Save*"
DIR_N_SAVE_FILENAME = "Save*"
TITLE_VAR_ID = 1
# Load Data Types: :var_max or :recent
LOAD_DATA_TYPE = :var_max
USE_BACKGROUNDS = true
USE_FOREGROUNDS = true
# Manually List All of Your Background and Foreground Titles
BACKGROUNDS = ["Book", "Fountain", "Island", "Sword"]
FOREGROUNDS = ["Metal", "Heroes", "Mist", "Mountains"]

extend self
def sort_save_files
    Dir.sort
end

def find_bg_fg(index)
    , FOREGROUNDS]
end
end

module DataManager
extend self
attr_accessor :titles, :total_save_files
def load_vars_only(fn)
    File.open(fn, "rb") do |file|
      Marshal.load(file)
      data = Marshal.load(file)
      variables = data[:variables]
      @titles << variables
      @make_times << File.mtime(fn) rescue Time.at(0)
    end
end

def check_save_files
    @titles = []
    @make_times = []
    filenames = KTitleUpdate.sort_save_files
    filenames.each {|fn| load_vars_only(fn) }
    @total_save_files = filenames.size
end

def highest_titles
    KTitleUpdate.find_bg_fg(@titles.max - 1)
end

def latest_titles
    time_max = @make_times.max
    title_index = @make_times.index(time_max)
    title_index = @titles - 1
    KTitleUpdate.find_bg_fg(title_index)
end

def default_title?
    @titles.empty? or @titles.max == 0
end
check_save_files
end

class Scene_Title
alias :kyon_title_change_scn_ttl_create_backgr :create_background
def create_background
    if DataManager.default_title?
      kyon_title_change_scn_ttl_create_backgr
    else
      custom_background
    end
end

def custom_background
    case KTitleUpdate::LOAD_DATA_TYPE
    when :var_max
      background, foreground = DataManager.highest_titles
    when :recent
      background, foreground = DataManager.latest_titles
    end
    @sprite1 = Sprite.new
    @sprite1.bitmap = Cache.title1(background)
    @sprite2 = Sprite.new
    @sprite2.z = 25
    @sprite2.bitmap = Cache.title2(foreground)
    center_sprite(@sprite1)
    center_sprite(@sprite2)
end
end

class Scene_End
alias :kyon_title_change_scn_end_comm_ttl :command_to_title
def command_to_title
    kyon_title_change_scn_end_comm_ttl
    DataManager.check_save_files
end
end


DOWNLOAD DEMO & SCRIPT​

Side Note

Usually, I would not make this kind of simple scripts, still, an unknown forumer was desperate to get another one work the way he expected and it made me flex my scripting muscles once again.

Terms & Conditions

Free for use in any game
Due credit is optional but appreciated.
That's it!


本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/ktitleupdate-ace.158410/
页: [1]
查看完整版本: KTitleUpdate ACE