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.

My script doesn't want to work with the SDK.

Status
Not open for further replies.
My game is unplayable right now, because it crashes when I hit "save" in the menu. I think it's my script causing it, but I have no idea why.
Here's the error:
http://i162.photobucket.com/albums/t241 ... FError.png[/IMG]
And here's the script:
Code:
class Window_Itachi_One < Window_Base
  
  def initialize
    @bitmap = RPG::Cache.windowskin("InfectionWindow.png")
    super(0, 260, @bitmap.width, @bitmap.height) # 90 | 70
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = 'Arial'
    self.contents.font.size = 24
    self.contents.font.color = text_color(2)
    @var = nil
    refresh
  end

  def to_s
    $game_variables[15].to_s
  end

  def refresh
    self.contents.clear
    @bitmap = RPG::Cache.windowskin("InfectionWindow.png")
    self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 170)
    self.contents.draw_text(18, 0, @bitmap.width, @bitmap.height, to_s + "%")
  end

  def update
    return if @var == $game_variables[15]
    @var = $game_variables[15]
    refresh
  end
end

class Scene_Map
    
  alias_method :old_main, :main
  alias_method :old_update, :update
  
  def main
    @window = Window_Itachi_One.new
    old_main
    @window.dispose
  end

  def update
    @window.update
    old_update
  end
end
How can I fix this?
Thanks. :(
 

khmp

Sponsor

Get rid of:
Code:
@bitmap = RPG::Cache.windowskin("InfectionWindow.png")
in the refresh method. You don't need to do that every time the window updates.

I don't believe it has anything to do with your error but I think it will eat up RAM. :) Your error seems like you altered what data is saved and when the data is loaded its going past the end of the file. EOF = end of file. Like writing 4 bytes of information and then trying to read 5 bytes.

That code isn't 216 lines long. Are you using the RSC version of the SDK?
 

khmp

Sponsor

I'm confused because it points to a line of code that does not exist in either script. In the SDK line 216 is a comment. The custom window script is only 47 lines. I think you'll need the help of a more knowledgeable person. Sorry I couldn't be of more assistance. ':|
 
1) The error is in the SDK Part II script mostly likely, not yours since yours does not alter the save/load commands at first glance.

2) Which version SDK do you have? If it's SDK v2.2, then lines 208-22 are:

Code:
#--------------------------------------------------------------------------
  # * Object Initialization : Game Data
  #--------------------------------------------------------------------------
  def init_gamedata
    file = File.open(@filename, "r")
    @time_stamp = file.mtime
    @characters = Marshal.load(file)
    @frame_count = Marshal.load(file)
    @game_system = Marshal.load(file)
    @game_switches = Marshal.load(file)
    @game_variables = Marshal.load(file)
    @total_sec = @frame_count / Graphics.frame_rate
    file.close
  end
end

3) If that is not the case, you may want to search for any other scripts that conflict with the save/load features as well as make sure all of your scripts are below the SDK.

Otherwise I have no clue.
 
I think I've narrowed it down to being a conflict with Mr.Mo's ABS.
I tried removing every other script except the ABS, and still got the error. Copy and pasted the script into a new project with the SDK and without Mr.Mo's ABS, and it worked. I'll live without my script. :(

Thanks everybody,
it's resolved.
 
Status
Not open for further replies.

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