RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[solved]Selectable windows: index = 0 vs. index =-1 ?

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 82
We learn by living...
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.)

Code: [Select]
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.
« Last Edit: January 23, 2011, 09:31:11 PM by shintashi »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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