I recently encountered small lagging when starting the game (stagnant animations and such).
I am sure lagging can be caused by using too much scripts, but can copious amounts of charsets and sounds in the project also cause the game
to become slower?
sincerly
i think charsets and other pics/sounds are loaded when the particular map in which they are is loaded. so, basically, the graphics used in the particular map such as a extra large tileset or a lot of events can lag the map. You can prevent the lagging due to events via an anti lag script. hope that was helpful
So lagging on small maps will most likely be caused by scripts. Are all scripts loaded simultaneously or just when needed?
Sincerely
send from my phone
All scripts are checked through when the game begins, but only called when needed. A good way to stop lag like the one you've described is through an anti-lag script.
Why, here's my very own.#===============================================================================
#
# Pacman Advanced Creative (PAC) Engine - Lag Reduction
# 24/5/2011
# Type: Core
# Installation: Simple Value.
# Level: Difficult-ish
#
#===============================================================================
#
# Description:
# Got a tonne of events running on your maps? Causes a lot of lag, doesn't it?
# This is a lag reduction script to make your game run not as bad-like.
#
#===============================================================================
#
# Instructions:
# INSTALLATION
# Paste below materials, on top of as many other custom scripts as possible.
# This will run perfectly fine on its own, but is designed for usage with other
# PAC scripts.
# CONFIGURATION
# Set UPDATE_RANGE to any value between 20 and 120. It generally sits well at
# around 80. If this is too low or high, the script will give you a friendly
# reminder that will make your game look really bad.
#
#===============================================================================
#
# BEGIN EDITING
#
#===============================================================================
module PAC # Don't touch this.
module CORE # Or this.
UPDATE_RANGE = 80 # You may touch this.
end # You shouldn't touch this.
end # This is far too important for you to touch.
#===============================================================================
#
# This script no longer requires editing. Do not edit anything in this script
# unless you are a compenent scripter. Should you edit without any scripting
# education, it may result in me tutting at you for getting it wrong.
#
#===============================================================================
#===============================================================================
# Imported Clause
#===============================================================================
$imported = {} if $imported == nil
$imported["PAC_LagReduction"] = true
module Graphics
unless method_defined?(:resize_screen_PAC_CORE)
class << Graphics
alias resize_screen_pac_lag resize_screen
end
def self.resize_screen(width, height)
resize_screen_pac_lag(width, height)
if $game_temp != nil
$game_temp.setup_lightening_value
end
end
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# The instance of this class is referenced by $game_temp.
#==============================================================================
class Game_Temp
attr_accessor :valid_common_event_check
attr_reader :display_center_x
attr_reader :display_center_y
attr_reader :map_sprite_update_width
attr_reader :map_sprite_update_height
alias initialize_pac_lag initialize
def initialize
initialize_pac_lag
@valid_common_event_check = true
setup_lightening_value
end
#--------------------------------------------------------------------------
# * Setup Lightening Value
#--------------------------------------------------------------------------
def setup_lightening_value
@display_center_x = Graphics.width / 2
@display_center_y = Graphics.height / 2
@map_sprite_update_width = Graphics.width *
PAC::CORE::UPDATE_RANGE / 100
@map_sprite_update_height = Graphics.height *
PAC::CORE::UPDATE_RANGE / 100
end
end
if PAC::CORE::UPDATE_RANGE < 20
p "Your lag reduction is incredibly low. Raise it."
elsif PAC::CORE::UPDATE_RANGE < 50
p "Your lag reduction isn't very high. Consider raising it."
elsif PAC::CORE::UPDATE_RANGE > 120
p "Your lag reduction is quite high. Consider lowering it."
end
#==============================================================================
# ** Game_Switches
#------------------------------------------------------------------------------
# This class handles switches. It's a wrapper for the built-in class "Array."
# The instance of this class is referenced by $game_switches.
#==============================================================================
class Game_Switches
#--------------------------------------------------------------------------
# alias listing
#--------------------------------------------------------------------------
alias indexer_equal_pac_lag []=
#--------------------------------------------------------------------------
# * Set Switch
#--------------------------------------------------------------------------
def []=(switch_id, value)
indexer_equal_pac_lag(switch_id, value)
$game_temp.valid_common_event_check = true
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# alias listing
#--------------------------------------------------------------------------
alias setup_pac_lag setup
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup(map_id)
setup_pac_lag(map_id)
update_valid_common_event_list
end
#--------------------------------------------------------------------------
# * Update Valid Common Event List
#--------------------------------------------------------------------------
def update_valid_common_event_list
@valid_common_events = {}
@common_events.each { |event_id, event|
if event.trigger == 2 && $game_switches[event.switch_id]
@valid_common_events[event_id] = event
end
}
$game_temp.valid_common_event_check = false
end
#--------------------------------------------------------------------------
# * Update Events
#--------------------------------------------------------------------------
def update_events
for event in @events.values
event.update
end
if $game_temp.valid_common_event_check
update_valid_common_event_list
end
for common_event in @valid_common_events.values
common_event.update
end
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
@@_auto_start_common_event_list = nil
#--------------------------------------------------------------------------
# alias listing
#--------------------------------------------------------------------------
alias clear_pac_lag clear
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
clear_pac_lag
if @@_auto_start_common_event_list == nil
create_auto_start_common_event_list
end
end
#--------------------------------------------------------------------------
# * Create Auto Start Common Event List
#--------------------------------------------------------------------------
def create_auto_start_common_event_list
@@_auto_start_common_event_list = []
$data_common_events.compact.each { |event|
@@_auto_start_common_event_list << event if event.trigger == 1
}
end
#--------------------------------------------------------------------------
# * Setup Starting Event
#--------------------------------------------------------------------------
def setup_starting_event
if $game_map.need_refresh
$game_map.refresh
end
if $game_temp.common_event_id > 0
setup($data_common_events[$game_temp.common_event_id].list)
$game_temp.common_event_id = 0
return
end
for event in $game_map.events.values
if event.starting
event.clear_starting
setup(event.list, event.id)
return
end
end
for event in @@_auto_start_common_event_list
if $game_switches[event.switch_id]
setup(event.list)
end
end
end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display characters. It observes a instance of the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# * Within Update Range
#--------------------------------------------------------------------------
def within_update_range?
sx = @character.screen_x - $game_temp.display_center_x
sy = @character.screen_y - $game_temp.display_center_y
return (sx.abs <= $game_temp.map_sprite_update_width &&
sy.abs <= $game_temp.map_sprite_update_height)
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Update Characters
#--------------------------------------------------------------------------
def update_characters
for sprite in @character_sprites
sprite.update if sprite.within_update_range?
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
super
$game_map.interpreter.update
$game_map.update
$game_player.update
$game_system.update
@spriteset.update
@message_window.update
unless $game_message.visible
update_transfer_player
update_encounter
update_call_menu
update_call_debug
if $game_temp.next_scene != nil
update_scene_change
end
end
end
end
#===============================================================================
#
# END OF SCRIPT
#
#===============================================================================
The lag I encounter is definetely not caused by events.
There also isn't any lag when entering new maps, so the problem must be the initial check of all scipts, done by the game.
Is there a way, to have the game show like a loading screen till the check is done?
It doesn't even have to be animated, just a picture, that shows for a few seconds when pressing continue.
Could someone make this?
sincerly
Aha. There's a high chance it's just your computer then. How many/what scripts are you using? I'm positive that even around 40 scripts won't cause much noticeable lag on a computer that operates finely without any other custom scripts, solely because YEM (and, by unfair comparison, PAC) manages to run fine despite all of the scripts within the engine. Although, YEM is focused on efficiency...
Unless you're using hundreds of scripts or the scripts are that poorly coded, chances are it's your computer. Or of course, resources, but there have been stand-alone (non-RTP) full games that operate completely fine with only imported resources.
about 44 scripts /shame
My specs are far above average, so I can assure you, that it is not my computer.
I think the loading screen idea wouldn't be so bad after all, as all the lagging happends the time you jump into the game.
You don't know a scipt that lets you modify what happends on pressing "New game" or "Continue", by any chance?
Calling a common event on pressing one of these would be enough.
also, thx for your fast replies
edit:
can you tell me how to call a common event in rgss?
that would fix all my problems, or at least I believe so.
edit2:
I thought I could call a common event by modifying the Scene_Title, but although there isn't an error message, the event does not get called.
I actually was thinking about a loading screen, but then I remembered how lazy I am. Calling a common event through script, off the top of my head (I don't have VX atm), should be$game_temp.common_event_id = COMMON_EVENT_ID
I suppose I could whip up something for your 'new game' and 'continue' common events, but I can't now because I'm destroyed and am about to fall asleep on the keyboard.
Modifying Scene_Title was nonsense.
The function to continue the game is in Scene_File.
Sadly, I can't get the common event to get called, before the map shows up.
stuck at this point
Startup-lag does not appear on all maps, leading to the conclusion, that it has in fact nothing to do with my scripts.
The affected maps do not have many events.
The loading screen idea would still be fun and effective, but I simply do not know what the original problem is.