RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VX] Scene_Base

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 88
Scene_Base
Authors: Nathmatt
Version: 1.02

Introduction
This script is an updated version of the original Scene_Base

Features

  • Automatically updates active windows
  • Automatically disposes all windows & sprites

Screenshots

no screenshot

Demo
no demo

Script

Spoiler for:
Code: [Select]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Scene_Base by Nathmatt
# Version: 1.01
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #-----------------------------------------------------------------------------
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
#  This is a superclass of all scenes in the game.
#==============================================================================

class Scene_Base
  attr_accessor :windows
  attr_accessor :sprites
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    add_processing                # Adds processing
    start                         # Start processing
    perform_transition            # Perform transition
    post_start                    # Post-start processing
    Input.update                  # Update input information
    loop do
      Graphics.update             # Update game screen
      Input.update                # Update input information
      update                      # Update frame
      update_windows              # update windows
      break if $scene != self     # When screen is switched, interrupt loop
    end
    Graphics.update
    pre_terminate                 # Pre-termination processing
    Graphics.freeze               # Prepare transition
    terminate                     # Termination processing
    terminate_windows             # terminate windows
  end
  #--------------------------------------------------------------------------
  # * Add processing
  #--------------------------------------------------------------------------
  def add_processing
    @windows = []
    @sprites  = []
    @animate = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update_windows
    @windows.each{|s| s.update if !s.updated? && s.active}
  end
  #--------------------------------------------------------------------------
  # * Terminate Windows Processing
  #--------------------------------------------------------------------------
  def terminate_windows
    @windows.each{|s| s.dispose if !s.disposed?}
    @sprites.each{|s| s.dispose if !s.disposed?}
  end
 
end
#==============================================================================
# Window
#==============================================================================
class Window
 
  alias scene_base_initialize initialize unless $@
  def initialize(viewport = nil)
    scene_base_initialize(viewport = nil)
    self.openness = 0
    $scene.windows.push(self)
  end
  alias scene_base_update update unless $@
  def update
    @frame_count = Graphics.frame_count if @frame_count != Graphics.frame_count
    scene_base_update
  end
 
  def updated?
    return true if @frame_count == Graphics.frame_count
  end
 
end
#==============================================================================
# Sprite
#==============================================================================
class Sprite
 
  alias scene_base_initialize initialize unless $@
  def initialize(viewport = nil)
    scene_base_initialize(viewport = nil)
    $scene.sprites.push(self)
  end
 
end

Instructions
just place above main

Compatibility
Should not have any compatibility issues

Credits and Thanks

  • Nathmatt
  • modern algebra for the unless $@ code

Author's Notes

If you have any suggestions post here
« Last Edit: May 13, 2010, 02:03:34 PM by Nathmatt »

***
Rep:
Level 82
aka DigiDeity
Wow a nice idea!
But i don't know if it's helpfull. I think you'll update unneeded things like Windows which aren't active and this can cause laggs.
Anyways I think it's a good idea. xD

Deity
Greetings
DigiDeity

├Work┤
├Contact┤


*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, it's not a bad idea, I guess. But I'm not sure how much it will be used since most people writing a script would rather just dispose the windows manually than require the user to install a whole other script. However, it's nice if you have a series of scripts that you'll release as a compilation. One thing I'll mention is that you don't need to recopy the entire class, only the parts you want to change, so you can make the script quite a bit smaller than it is.

Also, you'll probably want to add an
Code: [Select]
unless $@
after the aliases in Window and Sprite, as you will get an F12 error otherwise.

**
Rep: +0/-0Level 88
i made it as more of a use it with the custom scripts you make for yourself and made sure it only updates windows 1nce per frame so if they have been updated they wont update again
fixed the only updates active windows and the unless $@
« Last Edit: May 13, 2010, 01:35:00 PM by Nathmatt »