I'm learning Ruby little by little, but I've ran into something I need help with that I can't solve myself.
With CSCA's Crafting script, toast messages can appear for learning a new recipe, for successfully creating something, and for failing to create something. I'd like for the toast messages to appear in the scene, but they only show up after I've closed the scene...if I use a script that alters the background of the menu.
Note, in the Toast Manager, there's a part of the script that omits certain scenes from showing toasts, and the crafting scene is NOT within that list of scenes, nor have I accidentally put it there.
I've included links to both the crafting script and the toast manager script in case anyone needs it.
CSCA's Crafting script: https://www.caspergaming.com/scripts/csca/crafting/
CSCA's Toast Manager script: https://www.caspergaming.com/scripts/csca/toastmanager/
The script that alters the background to use images:
When I remove just the entry for "Scene_Crafting", the issue does not go away. When I remove the entire script, Toasts appear properly once again.
Can anyone help?
EDIT: this can be fixed by one of the easiest fixes in RPG Maker, script order. Putting CSCA's Core, Toast, and Crafting scripts above the custom background script allows for the crafting script to show toasts. I'm still unsure why the background script disallows toasts being shown in menu scenes, but that's a mystery for another day.
This can be closed.
With CSCA's Crafting script, toast messages can appear for learning a new recipe, for successfully creating something, and for failing to create something. I'd like for the toast messages to appear in the scene, but they only show up after I've closed the scene...if I use a script that alters the background of the menu.
Note, in the Toast Manager, there's a part of the script that omits certain scenes from showing toasts, and the crafting scene is NOT within that list of scenes, nor have I accidentally put it there.
I've included links to both the crafting script and the toast manager script in case anyone needs it.
CSCA's Crafting script: https://www.caspergaming.com/scripts/csca/crafting/
CSCA's Toast Manager script: https://www.caspergaming.com/scripts/csca/toastmanager/
The script that alters the background to use images:
Ruby:
#===============================================================================
# ** Custom Menu Backgrounds 2.0 **
#===============================================================================
#
# Version: 2.0
# Datum: 29.06.2014
# Author: eugene222
#
#===============================================================================
# CHANGELOG:
#
# Version 2.0 , 29.06.2014: rewrote the script, added many features
# Version 1.1a , 13.05.2014: improved compatibility
# Version 1.1 , 24.04.2014: layouts added
# Version 1.01 , 21.03.2014: code optimized
# Version 1.0 , 02.03.2014: Script created
#
#===============================================================================
# Features:
#
# - Custom Background For Every Scene (Custom Scenes should work, too)
# - Custom Layout Which Will Be Displayed Over The Background
# - Custom Opacity For The Windows
# - Particle Effects
#
#===============================================================================
# Installation:
#
# Place this script above main but below the default scripts
#
# The background and layout pictures have to be in "Graphics\Menu"
# => Create the Folder if you dont have one.
# The particle picture has to be in "Graphics\Menu", too.
# The size dont matter but I recommend 32x32
#
#===============================================================================
module EVG
module SceneBG
USED_SCENES = ["Scene_Menu", "Scene_Item", "Scene_Skill", "Scene_Equip",
"Scene_Status", "Scene_End",
"Scene_System", "CSCA_Scene_Achievements",
"Scene_Mail", "Scene_Party", "Scene_Notebook, Scene_Text_Reader"]
#"CSCA_Scene_Crafting",
#---------------------------------------------------------------------------
# You need to define the default Attributes below
# All Scenes in USED_SCENES will use these values as their default
# A little bit more below you can overwrite attributes for certain scenes
#----------------------------------------------------------------------------
DEFAULT_CONFIG = {
#------------------------------------------------------------------------
# You can set :opacity, :background, :layout and :particle to :disabled
# This means, that this script wont touch disabled attributes
# But you can overwrite them for certain scenes.
#-------------------------------------------------------------------------
# :opacity => value or :disabled,
:opacity => 128,
# :background => "filename" or :disabled,
:background => "Scene_Menu",
# :layout => "filename" or :disabled,
:layout => :disabled,
# :particle => "filename" or :disabled,
:particle => :disabled,
# How many particles should be shown on the screen?
:particle_number => 10,
# The x-axis speed per frame
:particle_speed_x => 0,
# The y-axis speed per frame
:particle_speed_y => 3,
# The angle speed per frame
:particle_speed_a => 1,
#---------------------------------------------------------------------------
} # Diese Zeile nicht verändern
#---------------------------------------------------------------------------
# Here you can define individual settings for the used scenes
# The default attributes get overwriten by this.
#---------------------------------------------------------------------------
OVERWRITE = { # Diese Zeile nicht verändern
#---------------------------------------------------------------------------
# Custom Scene Config:
# - The overwriten attributes needs to be seperated by a comma
#---------------------------------------------------------------------------
"Scene_Menu" => {
:particle_number => 5, :background => "Scene_Menu", :opacity => 0, :particle => "particle",
},
"CSCA_Scene_Achievements" => {
:particle_number => 5, :background => "Scene_Trophies", :opacity => 0, :particle => "Trophy_1"
},
"CSCA_Scene_Crafting" => {
:background => "Scene_Crafting", :opacity => 0, :particle => "Crystal_01A", :particle_number => 5
},
"Scene_Item" => {
:background => "Scene_Item", :opacity => 0, :particle => :disabled,
},
"Scene_Skill" => {
:particle_number => 5, :background => "Scene_Skill", :opacity => 0,
},
"Scene_System" => {
:particle_number => 5, :background => "Scene_System", :opacity => 0,
},
"Scene_Equip" => {
:background => "Scene_Equip", :opacity => 50,
},
"Scene_Status" => {
:particle_number => 4, :background => "Scene_Status", :opacity => 0,
},
"Scene_Mail" => {
:particle_number => 4, :background => "Scene_Mail", :opacity => 255, :particle => "Particle_Mail"
},
"Scene_Party" => {
:background => "Scene_Party", :opacity => 0,
},
"Scene_Status" => {
:background => "Scene_Status", :opacity => 0,
},
"Scene_StatusStates" => {
:background => "Scene_StatusStates", :opacity => 0,
},
"Scene_StatusResist" => {
:background => "Scene_StatusResist", :opacity => 0,
},
"Scene_StatusElements" => {
:background => "Scene_StatusElements", :opacity => 0,
},
"Scene_Notebook" => {
:background => "Scene_Status", :opacity => 100,
},
#---------------------------------------------------------------------------
# CONFIG END
#---------------------------------------------------------------------------
} # Diese Zeile nicht verändern
#---------------------------------------------------------------------------
end
end
#===============================================================================
# ** Cache
#===============================================================================
class Scene_MenuBase
#---------------------------------------------------------------------------
# Post Start
#---------------------------------------------------------------------------
alias :evg_smb_ps_cmb :post_start
#---------------------------------------------------------------------------
def post_start
if custom_bg_scene?
change_opacity
create_layout
create_particles
end
evg_smb_ps_cmb
end
#--------------------------------------------------------------------------
# * Custom Background Scene?
#--------------------------------------------------------------------------
def custom_bg_scene?
return EVG::SceneBG::USED_SCENES.include?(current_scene)
end
#--------------------------------------------------------------------------
# * Current Scene
#--------------------------------------------------------------------------
def current_scene
return SceneManager.scene.class.to_s
end
#--------------------------------------------------------------------------
# * Is type An Overwrite Type?
#--------------------------------------------------------------------------
def overwrite_type?(type)
EVG::SceneBG::OVERWRITE[current_scene.to_s] &&
EVG::SceneBG::OVERWRITE[current_scene.to_s][type]
end
#--------------------------------------------------------------------------
# * Create Viewport
#--------------------------------------------------------------------------
alias :evg_smb_cmv_cmb :create_main_viewport
def create_main_viewport
evg_smb_cmv_cmb
w = Graphics.width + 32; h = Graphics.height + 32
@particle_viewport = Viewport.new(-32, -32, w, h)
@particle_viewport.z = 5
end
#---------------------------------------------------------------------------
# Return Value For Type
#---------------------------------------------------------------------------
def return_value(type)
if overwrite_type?(type)
return EVG::SceneBG::OVERWRITE[current_scene.to_s][type]
else
return EVG::SceneBG::DEFAULT_CONFIG[type]
end
end
#---------------------------------------------------------------------------
# Get Opacity
#---------------------------------------------------------------------------
def get_opacity
return_value(:opacity)
end
#---------------------------------------------------------------------------
# Get Background
#---------------------------------------------------------------------------
def get_background
return_value(:background)
end
#---------------------------------------------------------------------------
# Get Layout
#---------------------------------------------------------------------------
def get_layout
return_value(:layout)
end
#---------------------------------------------------------------------------
# New Create Background
#---------------------------------------------------------------------------
def new_create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = Cache.menu(get_background)
end
#---------------------------------------------------------------------------
# Create Background
#---------------------------------------------------------------------------
alias :evg_smb_cb_cmb :create_background
#---------------------------------------------------------------------------
def create_background
if custom_bg_scene?
return evg_smb_cb_cmb if get_background == :disabled
return new_create_background
else
evg_smb_cb_cmb
end
end
#---------------------------------------------------------------------------
# Create Öayout
#---------------------------------------------------------------------------
def create_layout
return if get_layout == :disabled
@layout_sprite = Sprite.new
@layout_sprite.z = @background_sprite.z + 1
@layout_sprite.bitmap = Cache.menu(get_layout)
end
#--------------------------------------------------------------------------
# Create Particles
#--------------------------------------------------------------------------
def create_particles
return if return_value(:particle) == :disabled
dispose_particles
file = return_value(:particle)
speed_x = return_value(:particle_speed_x)
speed_y = return_value(:particle_speed_y)
speed_a = return_value(:particle_speed_a)
@particles = Array.new(return_value(:particle_number)) do
EVGParticle.new(@particle_viewport, speed_x, speed_y, speed_a, file)
end
end
#---------------------------------------------------------------------------
# Change Opacity
#---------------------------------------------------------------------------
def change_opacity
return if get_opacity == :disabled
instance_variables.each do |name|
instance = instance_variable_get(name)
set_opacity(instance) if instance.is_a?(Window)
end
update_file_opacity if @savefile_windows
end
#---------------------------------------------------------------------------
# For Scene File
#---------------------------------------------------------------------------
def update_file_opacity
@savefile_windows.each do |window|
set_opacity(window)
end
end
#---------------------------------------------------------------------------
# Set Window Opacity
#---------------------------------------------------------------------------
def set_opacity(window)
return if window.nil?
return if window.disposed?
window.opacity = get_opacity
end
#---------------------------------------------------------------------------
# Update
#---------------------------------------------------------------------------
alias :evg_smb_update_cbs :update
#---------------------------------------------------------------------------
def update
evg_smb_update_cbs
@particles.each(&:update) if @particles
end
#---------------------------------------------------------------------------
# Dispose Öayout
#---------------------------------------------------------------------------
def dispose_layout
return unless @layout_sprite
@layout_sprite.bitmap.dispose
@layout_sprite.dispose
end
#---------------------------------------------------------------------------
# Dispose Particles
#---------------------------------------------------------------------------
def dispose_particles
return unless @particles
@particles.each(&:dispose)
@particle_viewport.dispose
@particles = nil
end
#---------------------------------------------------------------------------
# Terminate
#---------------------------------------------------------------------------
alias :evg_smb_terminate_cbs :terminate
#---------------------------------------------------------------------------
def terminate
evg_smb_terminate_cbs
dispose_layout
dispose_particles
end
#---------------------------------------------------------------------------
end
#===============================================================================
# ** Particle
#===============================================================================
class EVGParticle < Sprite
#-----------------------------------------------------------------------------
# Initialize
#-----------------------------------------------------------------------------
def initialize(viewport = nil, speed_x, speed_y, speed_angle, file)
super(viewport)
self.bitmap = Cache.menu(file)
@sx = speed_x
@sy = speed_y
@sa = speed_angle
reset_particle(true)
end
#-----------------------------------------------------------------------------
# Particle Width
#-----------------------------------------------------------------------------
def pw
return self.bitmap.width
end
#-----------------------------------------------------------------------------
# Particle Height
#-----------------------------------------------------------------------------
def ph
return self.bitmap.height
end
#-----------------------------------------------------------------------------
# Particle Visible?
#-----------------------------------------------------------------------------
def on_screen?
self.x.between?(-pw, Graphics.width + pw) &&
self.y.between?(-ph, Graphics.height + ph)
end
#-----------------------------------------------------------------------------
# Reset Particle
#-----------------------------------------------------------------------------
def reset_particle(init = false)
self.opacity = 0
reset_zoom
reset_position(init)
reset_speed
end
#-----------------------------------------------------------------------------
# Reset Zoom
#-----------------------------------------------------------------------------
def reset_zoom
zoom = (50 + rand(75)) / 100.0
self.zoom_x = zoom
self.zoom_y = zoom
end
#-----------------------------------------------------------------------------
# Reset Position
#-----------------------------------------------------------------------------
def reset_position(init)
self.x = rand(Graphics.width)
self.y = init ? rand(Graphics.height + pw) : Graphics.height + rand(ph + 32)
end
#-----------------------------------------------------------------------------
# Reset Speed
#-----------------------------------------------------------------------------
def reset_speed
@speed_x = @sx == 0 ? 0 : [[rand(@sx), 20].min, 1].max
@speed_y = @sy == 0 ? 0 : [[rand(@sy), 20].min, 1].max
@speed_a = @sa == 0 ? 0 : [[rand(@sa), 20].min, 1].max
end
#-----------------------------------------------------------------------------
# Update
#-----------------------------------------------------------------------------
def update
super
self.x += @speed_x
self.y -= @speed_y
self.angle += @speed_a
self.opacity += 5
reset_particle unless on_screen?
end
#-----------------------------------------------------------------------------
# Dispose
#-----------------------------------------------------------------------------
def dispose
self.bitmap.dispose
super
end
end
#===============================================================================
# ** Cache
#===============================================================================
module Cache
#-----------------------------------------------------------------------------
def self.menu(filename)
load_bitmap("Graphics/Menu/", filename)
end
#-----------------------------------------------------------------------------
end
#===============================================================================
# END
#===============================================================================
When I remove just the entry for "Scene_Crafting", the issue does not go away. When I remove the entire script, Toasts appear properly once again.
Can anyone help?
EDIT: this can be fixed by one of the easiest fixes in RPG Maker, script order. Putting CSCA's Core, Toast, and Crafting scripts above the custom background script allows for the crafting script to show toasts. I'm still unsure why the background script disallows toasts being shown in menu scenes, but that's a mystery for another day.
This can be closed.