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.
Help with scene script

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 86
Okay, I'm new at scripting, so this is probably a stupid problem, but I seriously need help because I can't figure this out for the life of me. I made this script to show a list in the game of your skills, such as Fishing, Rune Reading, Smithing, etc. I got it to open and close correctly(opening bypressing a key through a Common Event and close though the typical scripting way), but if you try to open it again after already doing it once, the game gets an error. YOu know, one of those gay ones that say "(BLANK) has encountered an error and needs to close. We're sorry for the inconvienence" or something like that. So, what did I do wrong in this script?

Code: [Select]
#########################################################################
#Scene_SkillList
#####################################################################

class Scene_SkillList
  def main
    @skilllist_window = Window_SkillList.new
    @skilllist_window.x = 0
    @skilllist_window.y = 0
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @skilllist_window.dispose
  end

#Update
  def update
    @skilllist_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
  end
end

#################################################################
#Window_SkillList
#################################################################
class Window_SkillList < Window_Base
  def initialize
    super(0, 0, 250, 480)
    @background = Spriteset_Map.new
    self.contents = Bitmap.new(width - 32, height - 32)
    add_contents
    refresh
  end
  #Refresh
  def refresh
    self.contents.clear
    add_contents
  end
  #Contents
  def add_contents
    contents.draw_text(0, 0, 80, 32, "Skill List")
    contents.draw_text(0, 30, 120, 32, "Rune Reading")
  end
end

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
http://rmrk.net/index.php/topic,19774.0.html
Why don't you give us the fucking error? Maybe then someone will help you out.

**
Rep:
Level 86
"(BLANK) has encountered an error and needs to close. We're sorry for the inconvienence"

Just filll in the (BLANK) with Game.exe. That's the error I get. So, yeah, I did give the error. The thing that confuses me is, as I think you thought, it isn't a standard error for scripts, since normally the error tells you exactly whats wrong with the script. If it was a nromal error, I would just figure it out on my own, but this is a bit more confusing. And I know its the script because I've copied it into new projects, and the same error occurs.

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Is this a windows error, or an error that appears in the game.exe?

If it is a windows error, try not closing it, and see if you can get a game.exe error to apear.

**
Rep:
Level 86
I just tried leaving for a minute, but all it does is freeze up the game. You know, the kind of freeze that if you should drag the windows error box over the game window, the box kinds of pastes itself into it several times. Anyway, yeah, that's the only error I get. Maybe something in the script overloaded the engine when used twice? Just poking suggestions.

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
I don't know what's going on, I put the script in a new project and set an event to call the scene on an action button trigger, and it seems to work fine; I open it an close it multiple times with no errors.

You should put more info on how you're calling the scene or whatever.

Wait, I think I see your problem, you put the spriteset method in a weird place.

Try this:

Code: [Select]
#########################################################################
#Scene_SkillList
#####################################################################

class Scene_SkillList
  def main
    @skilllist_window = Window_SkillList.new
    @skilllist_window.x = 0
    @skilllist_window.y = 0
    @spriteset = Spriteset_Map.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @skilllist_window.dispose
    @spriteset.dispose
  end

#Update
  def update
    @skilllist_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
  end
end

#################################################################
#Window_SkillList
#################################################################
class Window_SkillList < Window_Base
  def initialize
    super(0, 0, 250, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    add_contents
    refresh
  end
  #Refresh
  def refresh
    self.contents.clear
    add_contents
  end
  #Contents
  def add_contents
    contents.draw_text(0, 0, 80, 32, "Skill List")
    contents.draw_text(0, 30, 120, 32, "Rune Reading")
  end
end
« Last Edit: May 26, 2008, 02:20:48 PM by Falcon »

**
Rep:
Level 86
Yeah, I'm kind of a noob at scripting, so that's bound to happen.

Also, this just hit me, could it be conflicting with other scripts? I'm using that one, Leon's Shopping System, Synthesis' Point Based Level Up, and Charlie Lee's Weapon Enhancement Scripts, three of which are called by buttons. My script is called with 'X', the Leveling System is called with 'Y', and the Enhancement script is called with 'Z', in RMXP terms. Sorry if I'm being annoying, its just it really should be fine...

EDIT: Actually, nevermind, that works perfectly. And I see what you changed. Maybe it was that somehow? Either way, thanks man!
« Last Edit: May 26, 2008, 02:26:51 PM by Shadow Eye »

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Yeah, you called the spriteset_map but you never got rid of it, that was the problem. You hid that method in the window for some reason, so I missed it initially.