Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Ryex on July 24, 2008, 11:28:17 am

Title: [RESOLVED] problem with creating a menu for jcsnider
Post by: Ryex on July 24, 2008, 11:28:17 am
I cant get the stat window to work right
here is the code I'm having a problem with

class Window_stats_Pokemon < Window_Selectable
  def initialize(actor_index = nil)
    super(320, 96, 320, 384)
    self.contents = Bitmap.new(width - 32, height - 32)
    if actor_index != nil
      @actor = $game_party.actors[actor_index]
    else
      @actor = nil
    end
    refresh
    self.active = false
    self.z = 99
  end
  def refresh
    self.contents.clear
    if @actor != nil
      draw_actor_name(@actor, 0, 0)
      draw_actor_class(@actor, 0, 32)
      draw_actor_parameter(@actor, 0, 128, 0)
      draw_actor_parameter(@actor, 0, 160, 1)
      draw_actor_parameter(@actor, 0, 192, 2)
      draw_actor_parameter(@actor, 0, 224, 3)
      draw_actor_parameter(@actor, 0, 256, 4)
      draw_actor_parameter(@actor, 0, 288, 5)
      draw_actor_parameter(@actor, 0, 320, 6)
    end
  end
end

   
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
#  This class performs status screen processing.
#==============================================================================

class Scene_Status
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    #make Command Window
    s1 = "Stats"
    s2 = "Skill"
    @command_window = Window_Command_pokemon.new([s1, s2])
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
    end
    # Make status window
    @status_window = Window_MenuStatus.new
    @stat_window = Window_stats_Pokemon.new
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @command_window.dispose
    @status_window.dispose
    @stat_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @status_window.update
    @stat_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
    if @stat_window.active
      update_stat
      return
    end
  end
 
 
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Menu.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 4
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to status screen
        @status_window.active = false
        @stat_window.active = true
        @stat_window = Window_stats_Pokemon.new(@status_window.index)
        @stat_window.z = 200
      when 1  # skill
        # If this actor's action limit is 2 or more
        if $game_party.actors[@status_window.index].restriction >= 2
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_Skill.new(@status_window.index)
      end
      return
    end
  end
 
  def update_stat
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @status_window.active = true
      @stat_window = Window_stats_Pokemon.new
      @stat_window.z = 99
      @stat_window.active = false
      return
    end
  end
end


in the Status screen if I press status in the command window and then  select and actor the window underneath pops up and displays stats every thing up to there works

but if I press b while the stat screen is up nothing happens the menu basically freezes because the stat window is active and cant be cancled and I cant figure out why...  any help so I can finish this guys menu?
Title: Re: problem with creating a menu for jcsnider
Post by: Fantasist on July 24, 2008, 12:11:28 pm
Okay, what's with calling a new instance of Window_stats_Pokemon? You created the window, but you didn't dispose it, that's the problem. And if I may suggest, don't make multiple instances of the window. Instead, try to mod the refresh method, so you can just refresh each time the window needs to be emptied or refreshed with a new actor's window.
Title: Re: problem with creating a menu for jcsnider
Post by: Starrodkirby86 on July 24, 2008, 12:18:55 pm
Quote from: Fantasist on July 24, 2008, 12:11:28 pm
Okay, what's with calling a new instance of Window_stats_Pokemon? You created the window, but you didn't dispose it, that's the problem. And if I may suggest, don't make multiple instances of the window. Instead, try to mod the refresh method, so you can just refresh each time the window needs to be emptied or refreshed with a new actor's window.
This isn't helping very much on your two's cases, but I can answer the reason why it's called the Pokemon Window Stats. The menu Ryex is making for jcsnider is a Pokemon CMS.

http://forum.chaos-project.com/index.php?topic=1266.0 (http://forum.chaos-project.com/index.php?topic=1266.0)

Meow. :)
Title: Re: problem with creating a menu for jcsnider
Post by: Berans on July 24, 2008, 02:11:51 pm
I believe what Fantasis meant was this
def update_stat
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @status_window.active = true
--->@stat_window = Window_stats_Pokemon.new<-----------
      @stat_window.z = 99
      @stat_window.active = false
      return
    end
  end


See that bit with the arrows? You're making a new instance of the Window_stats_Pokemon class, but it already exists. That's probably the cause of your problem. If you want to renew the contents in your stat window, you'll have to do it through the refresh method.
Title: Re: problem with creating a menu for jcsnider
Post by: Ryex on July 24, 2008, 08:33:13 pm
yay I got that it works now now I'm disposing the window before calling it again
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Berans on July 24, 2008, 08:59:41 pm
That's one way to do it, but I think if you rewrite the refresh method, you'd be somewhat better off....
Still, it doesn't matter all that much, provided it doesn't create any lag :P
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Fantasist on July 25, 2008, 12:10:21 am
Doesn't it? It might not be noticable with today's computers, but refreshing the window is a better choice. Just make it invisible when you don't need it (win.visible = false)
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Berans on July 25, 2008, 01:54:17 am
I know that it slows stuff down. that's why I added "provided it doesn't create any lag". If it did create lag it would seriously matter :P
while on the topic of lag,(and me being too lazy to make a whole new thread) I was wondering if you had any idea why my skill menu lags more for some characters than for others. The code is identical in all of them.
On top of that, some skills seems to also cause more lag when they're selected, as opposed to others...very strange
also seeing a trend where more skills on page = less lag, for some weird reason XD
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Fantasist on July 25, 2008, 02:56:16 am
Strange... :?
There must be some resson, like unnecesary refreshing. And by 'lag', how much do you mean? Very noticable, or just jerky? Anyway, could you post/PM the code if you want me to look into it?
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Berans on July 25, 2008, 03:06:39 am
The lag is actually hardly noticable. I think a better phrase would be "slower framerate". I'll have a look through my refresh methods and such first, but the "lag" is too minor to actually spend hours trying to get it out :P
My computer is a pretty bad judge of lag anyway, since it can be a bit turbulent and is very slow, and the framerate goes down from somewhere high 30's-40 to about 25-30.
Anyway, I'll have a look at my code first, and if I can't figure it out at all, I'll send it to you in a PM
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Fantasist on July 25, 2008, 03:16:00 am
Framerate going low is not abnormal, it happens sometimes. Mine sometimes goes down to as low as 2-7 fps. It might also be your power saving settings. When i'm in power saver mode, my processor's frequency goes down from 1700 to 800. It depends on many factors. It's not really serious. But if you see it happen everytime, like more lag for some particular actor or some skills cause more lag, something specific like that, then you might need to review your code.
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Berans on July 25, 2008, 03:29:58 am
Yeah, that's what got me worried-ish. It seems to be a pretty solid trend, where certain actors/skills cause more lag than others. I'm gonna try to pinpoint the problem a little first. But even if I can't find it, I'm not too worried since I don't know anybody with a computer slower than mine :P
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Fantasist on July 25, 2008, 03:33:57 am
I do. It's really old, still works, and that's where I took my first steps with computers.
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Berans on July 25, 2008, 03:38:23 am
From what I can see in my own code, there's very little wrong with the code....maybe it's got something to do with the skill/actor IDs or whatever.
I don't think PMing you the code will help right now though, because (though I'm fairly sure it's effective) it's all over the place, and has like 10 lines of commenting in it that only make sense to me :P
Anyway, the point of my question was more to see if there was some generic reason why some actors would cause more lag than others (Might also have something to do with the fact that I have some animations in my skill window)
On to my equip menu....this one's gonna be a monster :P
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Fantasist on July 25, 2008, 04:00:09 am
Quoteif there was some generic reason why some actors would cause more lag than others

Well, there's no generic reason.
Quote(Might also have something to do with the fact that I have some animations in my skill window)

If so, you should be able to spot it, right? Like the actor with more lag uses a skill with an animation which is either very long or uses a graphic which is very large.

Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Berans on July 25, 2008, 04:37:29 am
Actually...the skills themselves are completely static. It's the actor that is moving. I just have their sprite in a perpetual walking motion that switches between the 4 directions.
Funny thing is, it only happens when I am in the actual skill window. If the skill window is no longer active, the scene always runs at 40fps (with some tiny hitches, as can be expected)
Also, it seems that the cleric class has virtually no lag....weird stuff...Most of the trends I'm seeing are very random and none of them seem to be related to eachother in any way XD
Title: Re: [Resolved] problem with creating a menu for jcsnider
Post by: Fantasist on July 25, 2008, 09:17:18 am
Then try tracing what's going on when the skill window is active. Try using the print command to trace things (did I already say this? I dunno...)
Title: Re: [RESOLVED] problem with creating a menu for jcsnider
Post by: Berans on July 25, 2008, 10:33:23 pm
I've tried tracing various things but nothing coherent lol...maybe it's just my computer telling me it hates me (when I was playtesting my comp was a little low on memory. I tried to paste a printscreen image from my snes emulator into paint, and it told me I didn't have enough memory to get the information from clipboard XD)
Anyway, I'm ignoring it for now, and might come back to it once I have everything else working and clean up the code for a proper release. On to bigger challenges now :P
Title: Re: [RESOLVED] problem with creating a menu for jcsnider
Post by: Fantasist on July 25, 2008, 11:57:28 pm
All the best :)
You don't mind sharing your computer stats with, do you ;)
Title: Re: [RESOLVED] problem with creating a menu for jcsnider
Post by: Berans on July 27, 2008, 03:48:45 am
errr....lets see...not much stats to say. It's an acer TravelMate 530. 512Mb RAM, 2.4?(maybe 2.0) GHz intel pentium 4. crappy 20Gb harddisk
and an inbuilt 64MB intel video card...not much else I can say about it :P (Apart from the fact that it doesn't read CDs anymore...still DVDs but no CDs for some stupid reason XD)
Title: Re: [RESOLVED] problem with creating a menu for jcsnider
Post by: Fantasist on July 27, 2008, 09:11:34 am
Well, it's pretty good actually. Here are my desktop's stats:
RAM - 512mb
Processor - AMD, 1.67GHz
Hard Disk - 2 Units, each 40gb
Graphics - GeForce MX 400 (64mb video memory)

So you've got a better processor and less hard disk space (which won't effect performance THAT much). I didn't have any lag problems running RMXP games though.

Quote(Apart from the fact that it doesn't read CDs anymore...still DVDs but no CDs for some stupid reason XD)

Wierd... :|
Title: Re: [RESOLVED] problem with creating a menu for jcsnider
Post by: Berans on July 27, 2008, 06:24:26 pm
I don't  "Generally" have any problems either :P
I think my swapfile might be a little full though, which could be why it runs so slow atm.