[RESOLVED]Menu problem

Started by Hellfire Dragon, April 15, 2009, 05:33:55 pm

Previous topic - Next topic

Hellfire Dragon

April 15, 2009, 05:33:55 pm Last Edit: April 16, 2009, 11:55:04 am by Sally
I was making a simple mission select menu with unlockable missions based on whether or not a switch was on. I copied some of the title screen script as a base and edited away, I'm a total scripting n00b but w/e. I keep getting this error
Quote
Script 'Scene_Mission_Menu' line 110: SyntaxError occurred


Here's my script
Spoiler: ShowHide

#==============================================================================
# ** Scene_Mission_Menu
#------------------------------------------------------------------------------
#  This class performs Mission Menu processing.
#==============================================================================

class Scene_Mission_Menu
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
    # Make command window
    s1 = "Mission 1: Beginners Luck"
    s2 = "Mission 2: "
    s3 = "Mission 3: "
    s4 = "Mission 4: "
    @command_window = Window_Command.new(192, [s1, s2, s3, s4])
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update command window
    @command_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # M1
        command_m1
      when 1  # M2
        command_m2
      when 2  # M3
        command_m3
      when 3  # M4
        command_m4
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Command: M1
  #--------------------------------------------------------------------------
  def command_m1
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Transfer
    $game_temp.player_transferring = true
    $game_temp.player_new_map_id = 4
    $game_temp.player_new_x = 9
    $game_temp.player_new_y = 11
    $game_temp.player_new_direction = 0
  end
  #--------------------------------------------------------------------------
  # * Command: M2 
  #--------------------------------------------------------------------------
  def command_m2
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Check if available
    if $game_switches[4] = true
    # Transfer
    $game_temp.player_transferring = true
    $game_temp.player_new_map_id = 5
    $game_temp.player_new_x = 9
    $game_temp.player_new_y = 11
    $game_temp.player_new_direction = 0
    else print 'This mission is not unlocked yet!'
   end
  #--------------------------------------------------------------------------
  # * Command: M3
  #--------------------------------------------------------------------------
  def command_m3
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Check if available
    if $game_switches[5] = true
    # Transfer
    $game_temp.player_transferring = true
    $game_temp.player_new_map_id = 6
    $game_temp.player_new_x = 9
    $game_temp.player_new_y = 11
    $game_temp.player_new_direction = 0
    else print 'This mission is not unlocked yet!'
  end
  #--------------------------------------------------------------------------
  # * Command: M4
  #--------------------------------------------------------------------------
  def command_m4
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Check if available
    if $game_switches[6] = true
    # Transfer
    $game_temp.player_transferring = true
    $game_temp.player_new_map_id = 7
    $game_temp.player_new_x = 9
    $game_temp.player_new_y = 11
    $game_temp.player_new_direction = 0
    else print 'This mission is not unlocked yet!'
  end


Aqua

Add an 'end'.
You didn't end the class. XD

I don't think you wanna use the 'print' command to show that a mission is unavailable.
You should draw that string instead.

Hellfire Dragon

April 15, 2009, 06:14:12 pm #2 Last Edit: April 15, 2009, 06:18:57 pm by Sally
Nope, still get the same error, just time on line 111 :huh:

Quote from: Aquaman on April 15, 2009, 05:41:39 pm
I don't think you wanna use the 'print' command to show that a mission is unavailable.
You should draw that string instead.


And how would I do that?

G_G

April 15, 2009, 06:25:32 pm #3 Last Edit: April 15, 2009, 06:30:41 pm by game_guy
Ok I'm going to redo this little script okay? Keep everything the same but redo it so it doesnt get the eror.
I'm also going to make it where no switches are needed. Or do you want to keep the switches like that.

I can make it where it uses a simple syntax.

Reno-s--Joker

April 16, 2009, 12:31:31 am #4 Last Edit: April 16, 2009, 12:34:30 am by Reno-s--Batman
Are you missing two 'end's?
Last few lines: ShowHide


    # Check if available
    if $game_switches[6] = true
    # Transfer
    $game_temp.player_transferring = true
    $game_temp.player_new_map_id = 7
    $game_temp.player_new_x = 9
    $game_temp.player_new_y = 11
    $game_temp.player_new_direction = 0
    else print 'This mission is not unlocked yet!'
<Maybe an end goes here?>
  end
<End the class like Aqua said>

Actually it happens a lot throughout. D= Seems to work after you end all the ifs. =]

Ryex

Spoiler: ShowHide

class Scene_Mission_Menu
  def initialize
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = "Mission 1: Beginners Luck"
    s2 = "Mission 2: "
    s3 = "Mission 3: "
    s4 = "Mission 4: "
    @command_window = Window_Command.new(192, [s1, s2, s3, s4])
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update command window
    @command_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # M1
        command_m1
      when 1  # M2
        command_m2
      when 2  # M3
        command_m3
      when 3  # M4
        command_m4
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Command: M1
  #--------------------------------------------------------------------------
  def command_m1
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Transfer
    $game_temp.player_transferring = true
    $game_temp.player_new_map_id = 4
    $game_temp.player_new_x = 9
    $game_temp.player_new_y = 11
    $game_temp.player_new_direction = 0
  end
  #--------------------------------------------------------------------------
  # * Command: M2 
  #--------------------------------------------------------------------------
  def command_m2
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Check if available
    if $game_switches[4] = true
      # Transfer
      $game_temp.player_transferring = true
      $game_temp.player_new_map_id = 5
      $game_temp.player_new_x = 9
      $game_temp.player_new_y = 11
      $game_temp.player_new_direction = 0
    else
      print 'This mission is not unlocked yet!'
    end
   end
  #--------------------------------------------------------------------------
  # * Command: M3
  #--------------------------------------------------------------------------
  def command_m3
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Check if available
    if $game_switches[5] = true
      # Transfer
      $game_temp.player_transferring = true
      $game_temp.player_new_map_id = 6
      $game_temp.player_new_x = 9
      $game_temp.player_new_y = 11
      $game_temp.player_new_direction = 0
    else
      print 'This mission is not unlocked yet!'
    end
  end
  #--------------------------------------------------------------------------
  # * Command: M4
  #--------------------------------------------------------------------------
  def command_m4
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Check if available
    if $game_switches[6] = true
      # Transfer
      $game_temp.player_transferring = true
      $game_temp.player_new_map_id = 7
      $game_temp.player_new_x = 9
      $game_temp.player_new_y = 11
      $game_temp.player_new_direction = 0
    else
      print 'This mission is not unlocked yet!'
    end
  end
end

also you forgot to define Main and initialize
initialize doesn't have to do anything but if you don't define it in my experience bad thing will happen
and the reason you have to add def main is because when you call your scene with $scene = Scene_Mission_Menu the base scrips will try to call the main method and if you don't have it defined it wont work. the code above has all the ends and method definitions and should work
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Hellfire Dragon

ty everyone, no error popups anymore, only 1 problem, the game 'freezes' whenever the script is called... :argh: The only thing you can do is close the game <_<

Blizzard

You mean this?

$scene = Scene_Mission_Menu.new


Try this:

$scene =
Scene_Mission_Menu.new

Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Hellfire Dragon

April 16, 2009, 07:45:58 am #8 Last Edit: April 16, 2009, 07:55:05 am by Sally
Well that's weird... the game isn't actually freezing up, when I call the script it looks like it is but if you press up or down you can hear the cursor sound, so you just cant see the menu, and none the options do what there supposed to but you can here the cursor and confirm sounds :P
What would be the problem there?

nathmatt

try this

Spoiler: ShowHide
class Scene_Mission_Menu
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  def main
    s1 = "Mission 1: Beginners Luck"
    s2 = "Mission 2: "
    s3 = "Mission 3: "
    s4 = "Mission 4: "
    @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
    Graphics.freeze
    @command_window.dispose
  end
 
  def update
    @command_window.update
    update_command
  end

  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.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_temp.player_transferring = true
       $game_temp.player_new_map_id = 4
       $game_temp.player_new_x = 9
       $game_temp.player_new_y = 11
       $game_temp.player_new_direction = 0
       $scene = Scene_Map.new
      when 1 
      if $game_switches[4] == true
      # Transfer
      $game_temp.player_transferring = true
      $game_temp.player_new_map_id = 5
      $game_temp.player_new_x = 9
      $game_temp.player_new_y = 11
      $game_temp.player_new_direction = 0
      $scene = Scene_Map.new
    else
      print 'This mission is not unlocked yet!'
    end
      when 2
         if $game_switches[5] = true
      # Transfer
      $game_temp.player_transferring = true
      $game_temp.player_new_map_id = 6
      $game_temp.player_new_x = 9
      $game_temp.player_new_y = 11
      $game_temp.player_new_direction = 0
      $scene = Scene_Map.new
    else
      print 'This mission is not unlocked yet!'
    end
      when 3 
      $game_temp.player_transferring = true
      $game_temp.player_new_map_id = 7
      $game_temp.player_new_x = 9
      $game_temp.player_new_y = 11
      $game_temp.player_new_direction = 0
      $scene = Scene_Map.new
    else
      print 'This mission is not unlocked yet!'
    end
      end
      return
    end
  end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Hellfire Dragon

Perfect! Except I just had to change the width of the choice box but w/e ty matt :)

So my first scripting attempt pretty much failed but I can try again :D


nathmatt

i have to admit all i did was strip scene menu i like to use scrips that are already there & just edit it frankenscripting  lol
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script