Chaos Project

RPG Maker => Tutorials => Topic started by: monkeydash on January 15, 2011, 10:56:30 am

Title: Sub Menu Help
Post by: monkeydash on January 15, 2011, 10:56:30 am
Hi. I'm attempting to script a sub menu so that I don't clutter up the main one.

I followed the tutorial on the site, but now I am getting a syntaxerror on line 14. I've looked over the tutorial again and it doesnt explain what could be wrong.

Can anyone help? I'm sure it must be something simple. (For you guys)

Spoiler: ShowHide
class Scene_SubMenu
 
  def initialize(menu_index = 0)
    @menu_index = menu_index
    end
 
  def main
   
    s1 = Quests
    s2 = Notes
    s3 = Achievements
   
    @command_window = Window_Command.new(160, [s1, s2, s3]
    @command_window.index = @menu_index
   
    Graphics.transition
loop do
  Graphics.update
  Input.update
  update
 
  if $scene != self
    break
  end
end

@playtime_window = Window_PlayTime.new
@playtime_window.x = #Set the x co-ordinates of where the playtime window will appear
@playtime_window.y = #Set the playtime window's y co-ords
@steps_window = Window_Steps.new
@steps_window.x = #The x co-ords of the steps window
@steps_window.y = #The steps window's y co-ords
@gold_window = Window_Gold.new
@gold_window.x = #The x of the gold window
@gold_window.y = #The y of the gold window
@status_window = Window_MenuStatus.new
@status_window.x = #The x of the menustatus window
@status_window.y = #The y of the menustatus window

Graphics.freeze
  @command_window.dispose
  @playtime_window.dispose
  @steps_window.dispose
  @gold_window.dispose
  @status_window.dispose
end
   
def update
  @command_window.update
  @playtime_window.update
  @steps_window.update
  @gold_window.update
  @status_window.update
 
  if @command_window.active
    update_command
    return
  end
 
  if @status_window.active
    update_status
    return
  end
end

def update_command
  if Input.trigger?(Input::B)
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Menu.new
    return
  end
 
  when 0
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Quest.new
 
   when 1
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Book.new
 
  when 2
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Achievements.new
 
  end
    return
  end
end
end
Title: Re: Sub Menu Help
Post by: winkio on January 15, 2011, 11:34:41 am
you definitely forgot an ending parentheses:

@command_window = Window_Command.new(160, [s1, s2, s3])


also use code tags
Title: Re: Sub Menu Help
Post by: monkeydash on January 15, 2011, 11:48:53 am
Thank you. There were a couple of other syntax problems, but I was able to solve them by having a closer look. This now works.

Spoiler: ShowHide
Quoteclass Scene_SubMenu

  def initialize(menu_index = 0)
    @menu_index = menu_index
    end

  def main
   
    s1 = Quests
    s2 = Notes
    s3 = Achievements
   
    @command_window = Window_Command.new(160, [s1, s2, s3])
    @command_window.index = @menu_index
   
    Graphics.transition
loop do
  Graphics.update
  Input.update
  update

  if $scene != self
    break
  end
end

@playtime_window = Window_PlayTime.new
@playtime_window.x = #Set the x co-ordinates of where the playtime window will appear
@playtime_window.y = #Set the playtime window's y co-ords
@steps_window = Window_Steps.new
@steps_window.x = #The x co-ords of the steps window
@steps_window.y = #The steps window's y co-ords
@gold_window = Window_Gold.new
@gold_window.x = #The x of the gold window
@gold_window.y = #The y of the gold window
@status_window = Window_MenuStatus.new
@status_window.x = #The x of the menustatus window
@status_window.y = #The y of the menustatus window

Graphics.freeze
  @command_window.dispose
  @playtime_window.dispose
  @steps_window.dispose
  @gold_window.dispose
  @status_window.dispose
end
   
def update
  @command_window.update
  @playtime_window.update
  @steps_window.update
  @gold_window.update
  @status_window.update

  if @command_window.active
    update_command
    return
  end

  if @status_window.active
    update_status
    return
  end
end

def update_command
  if Input.trigger?(Input::B)
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Menu.new
    return
  end

  case @command_window.index
  when 0
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Quest.new

   when 1
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Book.new

  when 2
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Achievements.new

  end
    return
  end
end
Title: Re: Sub Menu Help
Post by: monkeydash on January 15, 2011, 12:03:16 pm
Spoke too soon...

Now when I select the menu, it gives me the Error - Uninitialized constant Quests..

Spoiler: ShowHide
Quoteclass Scene_SubMenu

 def initialize(menu_index = 0)
   @menu_index = menu_index
   end

 def main
 
   s1 = Quests
   s2 = Notes
   s3 = Perks
   s4 = Achievements
 
   @command_window = Window_Command.new(160, [s1, s2, s3, s4])
   @command_window.index = @menu_index
 
   Graphics.transition
loop do
 Graphics.update
 Input.update
 update

 if $scene != self
   break
 end
end

@playtime_window = Window_PlayTime.new
@playtime_window.x = #Set the x co-ordinates of where the playtime window will appear
@playtime_window.y = #Set the playtime window's y co-ords
@steps_window = Window_Steps.new
@steps_window.x = #The x co-ords of the steps window
@steps_window.y = #The steps window's y co-ords
@gold_window = Window_Gold.new
@gold_window.x = #The x of the gold window
@gold_window.y = #The y of the gold window
@status_window = Window_MenuStatus.new
@status_window.x = #The x of the menustatus window
@status_window.y = #The y of the menustatus window

Graphics.freeze
 @command_window.dispose
 @playtime_window.dispose
 @steps_window.dispose
 @gold_window.dispose
 @status_window.dispose
end
 
def update
 @command_window.update
 @playtime_window.update
 @steps_window.update
 @gold_window.update
 @status_window.update

 if @command_window.active
   update_command
   return
 end

 if @status_window.active
   update_status
   return
 end
end

def update_command
 if Input.trigger?(Input::B)
   $game_system.se_play($data_system.cancel_se)
   $scene = Scene_Menu.new
   return
 end

 case @command_window.index
 when 0
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Quest.new

  when 1
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Book.new

 when 2
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Passive.new

 when 3
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Achievements.new

 end
   return
 end
end
Title: Re: Sub Menu Help
Post by: The Niche on January 15, 2011, 12:13:38 pm
Just to point out, round these parts, double posting is a sin. The modify button is there for a reason.
Title: Re: Sub Menu Help
Post by: monkeydash on January 15, 2011, 12:17:13 pm
I figured that modifying the post would be less noticeable than double posting. I'd just like a quick response, considering I initially thought the problem was solved.


EDIT: Problem solved... The menu names after s1, s2 etc needed to be in quote marks.
Title: Re: Sub Menu Help
Post by: The Niche on January 15, 2011, 12:33:03 pm
Quote from: monkeydash on January 15, 2011, 12:17:13 pm
I figured that modifying the post would be less noticeable than double posting. I'd just like a quick response, considering I initially thought the problem was solved.


EDIT: Problem solved... The menu names after s1, s2 etc needed to be in quote marks.


That's the reason most people double post. It's still illegal.
Title: Re: Sub Menu Help
Post by: monkeydash on January 15, 2011, 12:39:33 pm
Or you could say something helpful instead of being a post Nazi...

No one likes a post Nazi.


Now I'm getting this error message.

QuoteScript 'mysubmenu' line 40: NoMethodError occurred.
undefined method 'update for nil:NilClass


Spoiler: ShowHide
Quoteclass Scene_SubMenu

 def initialize(menu_index = 0)
   @menu_index = menu_index
   end

 def main
 
   s1 = "Quests"
   s2 = "Notes"
   s3 = "Perks"
   s4 = "Achievements"
 
   @command_window = Window_Command.new(160, [s1, s2, s3, s4])
   @command_window.index = @menu_index
 
   Graphics.transition
loop do
 Graphics.update
 Input.update
 update

 if $scene != self
   break
 end
end

   # Make status window
   @status_window = Window_MenuStatus.new
   @status_window.x = 160
   @status_window.y = 0

Graphics.freeze
 @command_window.dispose
 @status_window.dispose
end
 
def update
 @command_window.update
 @status_window.update

 if @command_window.active
   update_command
   return
 end

 if @status_window.active
   update_status
   return
 end
end

def update_command
 if Input.trigger?(Input::B)
   $game_system.se_play($data_system.cancel_se)
   $scene = Scene_Menu.new
   return
 end

 case @command_window.index
 when 0
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Quest.new

  when 1
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Book.new

 when 2
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Passive.new

 when 3
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Achievements.new

 end
   return
 end
end



Line 40 is:
@status_window.update

I think someone should do a better tutorial on this.


SOLVED

Fully functional. Brilliant. So if anyone is looking for a submenu system, then there it is.

Spoiler: ShowHide
Quoteclass Scene_SubMenu

  def initialize(menu_index = 0)
    @menu_index = menu_index
    end

  def main
   
    s1 = "Quests"
    s2 = "Notes"
    s3 = "Perks"
    s4 = "Achievements"
   
    @command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @command_window.index = @menu_index
   
      # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
   
    Graphics.transition
loop do
  Graphics.update
  Input.update
  update

  if $scene != self
    break
  end
end


Graphics.freeze
  @command_window.dispose
  @status_window.dispose
end
   
def update
  @command_window.update
  @status_window.update

  if @command_window.active
    update_command
    return
  end

  if @status_window.active
    update_status
    return
  end
end

def update_command
  if Input.trigger?(Input::B)
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Menu.new
    return
  end
 
if Input.trigger?(Input::C)
  if $game_party.actors.size == 0 and @command_window.index < 4
    $game_system.se_play($data_system.buzzer_se)
    return
  end
  case @command_window.index
  when 0
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Quest.new

   when 1
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Book.new

  when 2
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Passive.new

  when 3
  $game_system.se_play($data_system.decision_se)
  $scene = Scene_Achievements.new

  end
    return
  end
end

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
  end
  end
Title: Re: Sub Menu Help
Post by: The Niche on January 15, 2011, 02:05:48 pm
How am I - Alright, fine. Double post all you want, get banned, etc. More to the point, you should submit your script in the script forum, 'member to apply the template and stuff.
Title: Re: Sub Menu Help
Post by: winkio on January 15, 2011, 02:31:50 pm
Breaking the rules and insulting other members when they try to help you.  That's a 24 hour ban.
Title: Re: Sub Menu Help
Post by: monkeydash on January 15, 2011, 05:20:05 pm
I wouldnt have minded if anything helpful was said.

I'm an admin on another site and have been staff on others so I know how boards work. If someone breaks our rules for the first time we let them know but we make sure we still help out.

Sorry to you winkio, because you were helpful and I appreciate that.
Title: Re: Sub Menu Help
Post by: WhiteRose on January 15, 2011, 05:48:28 pm
Quote from: monkeydash on January 15, 2011, 05:20:05 pm
I'm an admin on another site


What site, out of curiosity?
Title: Re: Sub Menu Help
Post by: monkeydash on January 15, 2011, 05:54:14 pm
If I told you that, I would have to kill you.  :evil:

But it's a Role Playing site that has been going for some years now.
Title: Re: Sub Menu Help
Post by: Aqua on January 15, 2011, 06:08:01 pm
Well, you should have read the rules before posting on this forum...

http://forum.chaos-project.com/index.php/topic,4.0.html
Title: Re: Sub Menu Help
Post by: monkeydash on January 15, 2011, 06:23:20 pm
I've been on enough forums to know that the rules are pretty much always the same, so I tend not to read them any more and I'm sure most of you do the same.
That's the first time I've seen that modifying posts treats it the same as a new one. It won't happen again.
So.. who's ready to stop making a fuss over nothing?
Title: Re: Sub Menu Help
Post by: ForeverZer0 on January 15, 2011, 06:35:17 pm
Off-Topic: ShowHide

I would have helped you, but you have a bad attitude.

Niche was being helpful when he told you not to double post, and you told him he was a post-Nazi.
If its so nothing, then just do it fucking right the first time, or don't argue when someone corrects you.

BTW, I don't believe you are an admin on any other site. Just saying.


Title: Re: Sub Menu Help
Post by: WhiteRose on January 15, 2011, 07:51:16 pm
Quote from: ForeverZer0 on January 15, 2011, 06:35:17 pm
BTW, I don't believe you are an admin on any other site. Just saying.


Qft. I doubt any true admin would miss such a grand opportunity to get more visitors to his site.

Anyway, back on topic:

Quote from: The Niche on January 15, 2011, 02:05:48 pm
More to the point, you should submit your script in the script forum, 'member to apply the template and stuff.
Title: Re: Sub Menu Help
Post by: DeXuS on January 16, 2011, 06:38:31 am
Not true WhiteRose...  I have 3 websites and I have not once mentioned them.  But then again...  I don't belive in unsolicited spam...  So ask me about my favorite one and I will tell you.  :haha:

Oh, and LMAO @ Post-Nazi.  The Niche is anything but.  But I still want to know what a Padawan is...

MonkeyDash...  Try opening up your script editor and looking at the error line a bit. (The numbers going down the left margin of the editor.)  That tells you what line is what.  So If you have a error on line 111...  Look at line 111 to find it.  (Or your last edited script if you save and test after each modification like a normal person, lol)
Title: Re: Sub Menu Help
Post by: monkeydash on January 16, 2011, 06:48:12 am
One of the rules on most sites is to not advertise.
I'm not sure if it's the sort of thing anyone on here would be into anyway, but if anyone is a fan of forum roleplay then maybe we can talk over PM.

Thanks DeXus, but I've figured out what was wrong with it eventually.
A Padawan is basically the Jedi word for apprentice, although its a more formal title.

Should I submit this to the script forum? I figured it was basic stuff that most of you can do with your eyes shut.
Title: Re: Sub Menu Help
Post by: The Niche on January 16, 2011, 02:00:34 pm
Nah, we're not all script gods. Go ahead and submit it, it sounds interesting.
Title: Re: Sub Menu Help
Post by: The Niche on January 16, 2011, 02:09:16 pm
That post...I'd make it sticky had I the power.
Title: Re: Sub Menu Help
Post by: monkeydash on January 16, 2011, 03:14:16 pm
All righty. May as well if you guys think so.

*slaps Niches wrist for double posting - not that I care about that sort of thing.*
Title: Re: Sub Menu Help
Post by: The Niche on January 16, 2011, 03:17:02 pm
Hmm...where'd Zer0's post go? That is most annoying, makes me look like a hypocrite. Oh wait...
Title: Re: Sub Menu Help
Post by: ForeverZer0 on January 16, 2011, 03:20:33 pm
Quote from: The Niche on January 16, 2011, 03:17:02 pm
Hmm...where'd Zer0's post go? That is most annoying, makes me look like a hypocrite. Oh wait...


I don't think I had a post there. That was earlier. I made only one post in this thread. Unless I did in a stupor and a mod erased it. Thats always a possibility....

* Hits Niche in the back of the head with a steel pipe for double-posting *

Title: Re: Sub Menu Help
Post by: The Niche on January 16, 2011, 03:27:55 pm
Hmm...I thought you'd linked to your defamatory noob post. I must be hallucinating.