Main Menu
  • Welcome to The RPG Maker Resource Kit.

[solved]Selectable windows: index = 0 vs. index =-1 ?

Started by shintashi, January 23, 2011, 07:25:46 AM

0 Members and 1 Guest are viewing this topic.

shintashi

I' experiencing a technical difficulty with selectable menus patterned on the skill selection menu.

When transitioning from an option menu to a mock skill selection menu, if the selection index is set to 0, it loads correctly with a window selection box and hitting space bar activates the option normally.

The problem is because I'm using the spacebar to switch from an option menu to a skill menu, and the choices in both are activated using spacebar, it is automatically triggering the first option (index 0) on loading.

When I set the index to -1, like with actor menus, my selection boxes never appear and the space bar does nothing at all. Here's some pieces of the script:
(window 9 = main options menu. window 6 = skill selection menu.)

def main

... (loading windows)
@window_9 = Window_Command.new(200, [s1,s2,s3,s4,s5,s6,s7,s8,s9])
if Input.trigger?(32)
case @window_9.index
  when 0
... (when 1,2, etc.)
    when 3
    edit_rng
end
end (main)


def edit_rng
@window_6.visible = true
@window_6.active = true
@window_0.active = false
@window_9.active = false
if Input.trigger?(32)
  case @window_6.index
  when 0
#commands for option 0 go here...
... (when 1, 2, 3...etc.)
end #(case)
end #(def)


Basically, in @window_6.index is set to -1, the windows selection function doesn't appear, but if @window_6.index is set to 0, while the options appear and can be reached using arrow keys and respond normally to spacebar commands, the first option (when 0...) automatically loads once.

It's like buying a scantron for a test where someone already filled in "A" with a no. 2 pencil.

modern algebra

Well, keep it at -1 when it's not active. Turn it to 0 when it becomes active. As for avoiding selecting both at the same time, just make sure you only run one per frame. Ie. something like this:

if window1.active
  # update stuff
elsif window2.active
  # update stuff
end

rather than:

if window1.active
  # update stuff
end
if window2.active
  # update stuff
end