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.
[ALL GOOD] Reading Menu Index from other scenes

0 Members and 1 Guest are viewing this topic.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
In the already-delayed-enough development of PAC Main Menu, I've hit a rather annoying roadblock.
In the configuration of the script, you put the name of the command you want in quotation marks. Simple enough:
Code: [Select]
ITEMS = [
  'Inventory',
  etc...
]
and you enter the other information on that command in the other configurable hashes, using the name you designated in the ITEMS array.
To optimize awesomeness, I decided to make each scene return to the correct index. I tried something like this in each of the scenes' (default, anyway) return_scene method.
Code: [Select]
class Scene_Equip < Scene_Base
  def return_scene
    $scene = Scene_Menu.new(PAC::MM::ITEMS.index('Equip'))
  end
end
And I thought it would all work until I realized not everyone will be calling that command 'Equip'. Which means it will go wrong when it tries to find that index D:
So, of course, I put an attr_accessor of menu_index in Scene_Menu and try to read that through the return_scene method of all of these scenes.
Code: [Select]
class Scene_Equip < Scene_Base
  def return_scene
    $scene = Scene_Menu.new(Scene_Menu.menu_index)
  end
end
However, when that happens... it throws me an no method error:
undefined method `menu_index' for Scene_Menu:Class
So I even put a method to return the value. Still, the same error.
What's happening, and how would I get the index value?
« Last Edit: July 28, 2011, 12:44:14 PM by Pacman »
it's like a metaphor or something i don't know

**
Rep: +0/-0Level 82
RMVX Scripter
As Scene_Menu gets closed the index doesn't get saved so your asking for a variable in a scene that isn't actual active, either use a new class to save the index, a module or use Game_System as it runs all the time (I believe).

Also you could always use the actual index or key instead of the name.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
I was thinking of using Game_System, but I wouldn't know when to set it. I could use Game_Temp, but then it wouldn't be remembered in the save scene.
And I'm not going to use the index or key in the config because that would defeat the purpose of PAC MM's focus: simple configuration.
I'll try Game_System.

EDIT:: I got the system to not yell at me, i.e. no errors, but now I believe it's starting the menu index at -1. Which is odd.
« Last Edit: July 28, 2011, 11:50:02 AM by Pacman »
it's like a metaphor or something i don't know

**
Rep: +0/-0Level 82
RMVX Scripter
What I meant about the index was that as the ITEMS is an array you can save and call depending on where the item is in the array,

An array is literally a hash with numbered keys starting at 0 and going upwards (a negative index would go backwards from the end of the array downwards).

The menu_index thing is probably because of how scenes and windows work. I believe they usually start at 0 and go up, however the index is set to -1 usually if the window is selectable and then calls an update, this is probably due to commands or selectable objects may be disabled and if the original index is disabled it could cause an error in the program, try using p and print commands to figure what the index actually starts at.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Not that I hadn't already started that -_-
Well, I did it. I put a setting of my new attribute of Game_System, menu_index, to @command_window.index in Scene_Menu#update_command_selection. Another sexy thing I did was make the menu default to the saved index, so there's no need to have the argument in the first place. And no configuration was altered at all.
Success!
Thanks for being a sounding board.
« Last Edit: July 28, 2011, 12:46:30 PM by Pacman »
it's like a metaphor or something i don't know