How to call a method from and event script call?

Status
Not open for further replies.

Aeri_Sicher

Rookie Programmer! >.
Veteran
Joined
Jun 3, 2013
Messages
74
Reaction score
10
First Language
English
Primarily Uses
Well, I tried to create an event that would call the method "change_value" from Scene_Title. This method should add "1" to the attribute @startup_thing... and depending on what @startup_thing is, it would change @game_restart to either true or false:

when @game_restart == false, show the new_game command

when @game_restart == true, show the new_game_plus command

Does anyone know how I could go about doing this..?

Here are the areas I changed in Scene_Base:

 

class Scene_Title < Scene_Base

 

 

 

 

  #--------------------------------------------------------------------------

  # * Start Processing

  #--------------------------------------------------------------------------

  def start

    super

    @startup_thing = 1

    if @startup_thing == 1

      @restart_game = false                                  

    elsif @startup_thing == 2

      @restart_game = true

    end

    SceneManager.clear

    Graphics.freeze

    create_background

    create_foreground

    create_command_window

    play_title_music

  end

 

 

 

 

 

 

 

  #--------------------------------------------------------------------------

  # * Create Command Window

  #--------------------------------------------------------------------------

  def create_command_window

    @command_window = Window_TitleCommand.new

    if @restart_game == false

      @command_window.set_handler:)new_game, method:)command_new_game))

    elsif @restart_game == true

      @command_window.set_handler:)new_game_plus, method:)command_new_game_plus))

    end

    @command_window.set_handler:)continue, method:)command_continue))

    @command_window.set_handler:)shutdown, method:)command_shutdown))

  end

 

 

 

 

 

 

 

  #--------------------------------------------------------------------------

  # * [Change Value] Command

  #--------------------------------------------------------------------------

  def change_value

    @startup_thing += 1

  end

 

 

 

 

  #--------------------------------------------------------------------------

  # * [New Game Plus] Command

  #--------------------------------------------------------------------------

  def command_new_game_plus

    DataManager.setup_new_game

    close_command_window

    fadeout_all

    $game_map.autoplay

    SceneManager.goto(Scene_Map)

  end

 

 

 

 

 
This is the error:

And here is how I called the method to add "1" to the @startup_thing counter:

Anyone know what I could try to fix the error? Any help would be greatly appreciated!
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
You're accessing it as a class method so you need to define it as a class method

Code:
class Scene_Title  def self.change_value    ...  endend
You probably want to define the startup_thing as a class variable as well.
 

Aeri_Sicher

Rookie Programmer! >.
Veteran
Joined
Jun 3, 2013
Messages
74
Reaction score
10
First Language
English
Primarily Uses
You're accessing it as a class method so you need to define it as a class method

class Scene_Title def self.change_value ... endendYou probably want to define the startup_thing as a class variable as well.
Thanks again Tsukihime for your help!! 

I'll keep that in mind to place a self before the method if I want it to be called via event script call.. also changing the startup_thing to a class variable fixed my other problem that I didn't see yet =] (problem 100% solved)
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,078
Members
137,580
Latest member
Snavi
Top