Remember the last Command selected on Ksi's Simple Menu Script

Argami

Veteran
Veteran
Joined
Jun 22, 2012
Messages
130
Reaction score
10
First Language
Spanish
Primarily Uses
Hello! :)
I'm usig the Simple Menu Script by Ksi (And modified by Zalerinian) and I'm wondering if its possible edit the script so it remembers the last command selected after you open one of the options and then you return to the command window again.
I explain myself:
  • Pressing "Esc" you open the Menu
  • Then you select the Command (In this case there's Items, Save and Exit), let's imagine we select the Save command, so the Save Window will open.
  • Then we pres "Esc" again to exit the Save Window and return to the Menu. But when we return, the Items command is selected instead of the Save command, which is the last command we selected.
Is there an option to correct that?

Here's the script:

Thanks in advance!
 
Last edited:

Argami

Veteran
Veteran
Joined
Jun 22, 2012
Messages
130
Reaction score
10
First Language
Spanish
Primarily Uses
@Roninator2 Sorry about my ignorance but I'm trying to copy the script provided in the topic (And even switching on the switch indicated in the script) but nothing happens. What I'm suposed to do?

This is the script I'm talking about:
Code:
module Nataxinus
  module RememberSelection
   # Switch to remember the position of cursor
   ON_SWITCH = 1
   # The classes you want to be affected by this
   WINDOW_CLASSES = [Window_ChoiceList]
   # Reset position of cursor. Will deactivate last index if as long as set to
   # true.
   RESET_SWITCH = 2
  end
end

class Window_Selectable < Window_Base
  include Nataxinus::RememberSelection
 
  alias :remember_init :initialize
  def initialize(x, y, width, height)
   @locked = false
   remember_init(x, y, width, height)
   if reset_switch
     @@last_index = 0
   else
     @@last_index ||= 0
     return if !$game_switches[ON_SWITCH] || !WINDOW_CLASSES.include?(self.class)
     self.index = @@last_index if self.index
   end
  end
 
  alias :remember_activate :activate
  def activate
   remember_activate
   if reset_switch
     @@last_index = 0
   else
     return if !$game_switches[ON_SWITCH] || !WINDOW_CLASSES.include?(self.class)
     select(@@last_index)
   end
  end
 
  alias :remember_select :select
  def select(index)
   remember_select(index)
   if reset_switch
     @@last_index = 0
     @locked = false
     return
   end
   @@last_index = index if index && $game_switches[ON_SWITCH] &&
   WINDOW_CLASSES.include?(self.class) && @locked
   @locked = false
  end
 
  alias :remember_cursor_down :cursor_down
  def cursor_down(wrap = false)
   @locked = true
   remember_cursor_down(wrap)
  end
 
  alias :remember_cursor_up :cursor_up
  def cursor_up(wrap = false)
   @locked = true
   remember_cursor_up(wrap)
  end
 
  alias :remember_cursor_right :cursor_right
  def cursor_down(wrap = false)
   @locked = true
   remember_cursor_down(wrap)
  end
 
  alias :remember_cursor_left :cursor_left
  def cursor_left(wrap = false)
   @locked = true
   remember_cursor_left(wrap)
  end

  alias :remember_cursor_pagedown :cursor_pagedown
  def cursor_pagedown
   @locked = true
   remember_cursor_pagedown
  end
 
  alias :remember_cursor_pageup :cursor_pageup
  def cursor_pageup
   @locked = true
   remember_cursor_pageup
  end
 
  def reset_switch
   $game_switches[RESET_SWITCH]
  end
 
  alias :remember_cursor_update :update
  def update
   remember_cursor_update
   @@last_index = 0 if reset_switch && @@last_index != 0
  end
end
 

Ebanyle

açspasl~d~dfflass
Veteran
Joined
Sep 2, 2016
Messages
338
Reaction score
200
First Language
Portuguese
Primarily Uses
RMVXA
Have you tried to place the script he provided above the one you were using?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
sorry, haven't used the script just found it and thought it would work for you.
Which switch are you using?
It says the first one sets the script to work, the second resets the selection.
But I never tested it as I never needed it.
 

Argami

Veteran
Veteran
Joined
Jun 22, 2012
Messages
130
Reaction score
10
First Language
Spanish
Primarily Uses
@Ebanyle Yes! I just tried it and it doesn't work...
@Roninator2 I'm using the first switch, the "ON_SWITCH". I also tried editing the "WINDOW_CLASSES" part adding "Window_MenuHCommand" which I suposed that is the Simple Menu Script's command window. But I'm not a scripter so I don't know if it is what I have to do.
Maybe there's a way to merge the two scipts or so... I think the script in the other Topic is meant to be used in Choice List windows maybe that's why it doesn't work.
 

Argami

Veteran
Veteran
Joined
Jun 22, 2012
Messages
130
Reaction score
10
First Language
Spanish
Primarily Uses
*Little Bump*
 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
161
Reaction score
102
First Language
English
Primarily Uses
Works fine for me.

As long as you have Nataxus' script under the Ksi script and you have properly set up Nataxus' script to include the correct Window and you have the designated game switch turned on, it should work fine. If it still doesn't, there is probably a script clash with something else you are using, in which case nobody will be to able help if you don't specify what else you are running.
I also tried editing the "WINDOW_CLASSES" part adding "Window_MenuHCommand" which I suposed that is the Simple Menu Script's command window.
Yes, that is the correct window to add. It should look like:
Code:
WINDOW_CLASSES = [Window_ChoiceList, Window_MenuHCommand]
 

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

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.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,583
Latest member
write2dgray
Top