Sub Menu Help

Started by monkeydash, January 15, 2011, 10:56:30 am

Previous topic - Next topic

monkeydash

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

winkio

you definitely forgot an ending parentheses:

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


also use code tags

monkeydash

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

monkeydash

January 15, 2011, 12:03:16 pm #3 Last Edit: January 15, 2011, 12:04:59 pm by monkeydash
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

The Niche

Just to point out, round these parts, double posting is a sin. The modify button is there for a reason.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

monkeydash

January 15, 2011, 12:17:13 pm #5 Last Edit: January 15, 2011, 12:26:10 pm by monkeydash
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.

The Niche

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.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

monkeydash

January 15, 2011, 12:39:33 pm #7 Last Edit: January 15, 2011, 01:24:59 pm by monkeydash
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

The Niche

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.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

winkio

Breaking the rules and insulting other members when they try to help you.  That's a 24 hour ban.

monkeydash

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.

WhiteRose


monkeydash

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.

Aqua

Well, you should have read the rules before posting on this forum...

http://forum.chaos-project.com/index.php/topic,4.0.html

monkeydash

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?

ForeverZer0

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.


I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

WhiteRose

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.

DeXuS

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)

monkeydash

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.

The Niche

Nah, we're not all script gods. Go ahead and submit it, it sounds interesting.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

The Niche

That post...I'd make it sticky had I the power.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

monkeydash

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.*

The Niche

Hmm...where'd Zer0's post go? That is most annoying, makes me look like a hypocrite. Oh wait...
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

ForeverZer0

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 *

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

The Niche

Hmm...I thought you'd linked to your defamatory noob post. I must be hallucinating.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!