Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Error with my script...

I was playing with a script, but when I call it... it gives me this error and i don't know how to make it disapear....

Code:
ERROR SCRIPT "Window Base" line 95 RGSS error occurred

disposed window.

Thanx for reading.
 
EDIT: Still don't works...

Here Is the script... Don't be too harsh on me since this is my first script, and I made in a couple of hours. I know that is has a lot of mistakes, but i don't know how to solve them. If you can help...Post
Code:
#--------------------------------------------------------------------------------------------------------------------
#Test Your might script b
#Version-1.0
#Actualy this is my first script, so don't think this a  great thing, it imulates the Mortal Kombat
#Test your might Mini game, where you have to press a key very fast to do something, break a wall
#etc... Anyway this is fully custumizable. ENJOY!
# NOTE: This is not SDK because I don't fully understand SDK yet... :(
#--------------------------------------------------------------------------------------------------------------------
# Instructions
$bar = false # make this true if you want the show might window to have a bar instead of a number
$str_influence = 20 # str influence in the might test
$dex_influence = 20 # dex influnce in the might test
$int_influence = 20 # int influence in the might test
$timer = 60 #how much time you have to full the bar.
#--------------------------------------------------------------------------------------------------------------------


#This window shows the actual character stats that influence 
#how much the bar will fill in one hit

#Class start
class Window_status_current < Window_Base
  def initialize
    super(0,0,200, 400)
    self.contents = Bitmap.new(width - 32, height - 32)
    $chanlenger = 0
    refresh
 
    end
 #refresh the windows contents
  def refresh 
   
    self.contents.clear
    cx = contents.text_size($game_party.actors[$chanlenger].name).width
    # draws the name of the player
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 100+ 50, 50 , 34,"Name", 2)
    self.contents.font.color = system_color
    self.contents.draw_text(200-cx*2, 120+50, cx, 34,$game_party.actors[$chanlenger].name , 2)
   # draws the atributes that have influence in the might test
   #draws power
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 150+50, 50 , 34,($data_system.words.str).to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(200-cx*2, 170+50, cx, 34,($game_party.actors[$chanlenger].str).to_s , 2)
   #draws intelegence
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 200+50, 50 , 34,($data_system.words.int).to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(200-cx*2, 220+50, cx, 34,($game_party.actors[$chanlenger].int).to_s , 2)
   #draws dex
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 250+50, 50 , 34,($data_system.words.dex).to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(200-cx*2, 270+50, cx, 34,($game_party.actors[$chanlenger].dex).to_s , 2)
  
  
    end
end


#this window is the one that shows the might bar
class Window_Display_might < Window_Base
 
  def initialize
    super(0, 0, 170, 170)
    self.contents = Bitmap.new(width - 32, height - 32)
    $might_power= 0
    refresh
  end
  
  def refresh

    self.contents.clear
    cx = contents.text_size("Acumulated power").width
    self.contents.font.color = system_color
    self.contents.draw_text(-32, 0, cx, 32,"Acumulated Power" , 2)
    self.contents.font.color = normal_color
    self.contents.draw_text(60, 50, 50, 32, $might_power.to_s, 2)
  end
end

#Actual script start here
class Test_your_might
  
  def initialize(menu_index = 0) #initializes the menu
    @menu_index = menu_index 
    
  end
  
  #main start
  def main
    @spriteset = Spriteset_Map.new
    @start_time = false
    #Sets the menu options, change the commands name 
    s1 = "Start"
    s2 = "Chose Player"
    @command_window = Window_Command.new(160, [s1, s2])
    @command_window.index = @menu_index
    @window1 = Window_Display_might.new 
    # checks if there is only one player in the team
     if $game_party.actors.size == 1
        @command_window.disable_item(1)
      # if end
    end
      #defines the Window_cstatus as Current windows status for easier future use
      @window_cstatus=Window_status_current.new
  
      #defines the command_window positions
      @command_window.x = 320-80
      @command_window.y = 240
      #updates the screen
      Graphics.transition
      #Starts a loop
      loop do
      #updates grafix
      Graphics.update
      #updates the player input
      Input.update
      #updates window
      update
      # check if scene is current is self if not breaks loop
      if $scene != self
        break
      end # If end
    end # Loop end
     
    Graphics.freeze 
   #makes the current windows stauts appear in the screen
   @window_cstatus.dispose if !@window_cstatus.disposed?()
    # makes command window appear in the screen
   @command_window.dispose if !@command_window.disposed?()

      
    # def main end
  end
  
  #this is the update command
  def update 
    if @game_started = true
      if Graphics.frame_rate  % $timer.to_i == $timer.to_i
    $scene =scene_map
  end
  end
    #this updates the command window
    @command_window.update  
   #checks if the command window is the active one
   if @command_window.active 
     #updates the command window
      update_command  
     # returns back
      return
      # If end
    end
  # def update end
  if @game_started == false
    update_command
  else
    update_key_press
end
end

def update_key_press
    
    if Input.trigger?(Input::C) 
      $might_power =+ 1
      
      return
  end
end

 # update the user input
  def update_command 
# if escape is pressed
    if Input.trigger?(Input::B) 
      #play sound cancel
      $game_system.se_play($data_system.cancel_se) 
#changes to map screen
      $scene = Scene_Map.new 
      # returns back
      return 
    # if end
  end 
  
  # If Space or enter is pressed 
    if Input.trigger?(Input::C)
       # if there is only one guy in party 
             if $game_party.actors.size == 1 and @command_window.index = 1
               $game_system.se_play($data_system.buzzer_se)
               return
               end
               case @command_window.index
      #When cursor is in index 0 - first option
        when 0 
           #play sound desision
           $game_system.se_play($data_system.decision_se)
           # Do actions here
        
          @window1.dispose if !@window1.disposed?()
   
          @window_cstatus.dispose if !@window_cstatus.disposed?()
          @command_window.dispose if !@command_window.disposed?()
          @game_started = true
return
            
          #cursor is in index 1 - second option
      when 1  
             # if there is only one guy in party 
             if $game_party.actors.size > 1
              #play sound desision
               $game_system.se_play($data_system.decision_se)
               # Call chara slection window
               @command_window.active = false
             return
             else
                $game_system.se_play($data_system.buzzer_se)
             return
             end
             return
           
             end
           end
         end
       end

Thanx For reading.
 
The error may is caused for this, I don't understand why dispose windows in middle of the scene, it must be used in the end:
Code:
      #When cursor is in index 0 - first option
        when 0 
           #play sound desision
           $game_system.se_play($data_system.decision_se)
           # Do actions here
        
          @window1.dispose if !@window1.disposed?()
   
          @window_cstatus.dispose if !@window_cstatus.disposed?()
          @command_window.dispose if !@command_window.disposed?()
          @game_started = true
return
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top