Jump to content
PoPS

In need of script: Adding option to menu that calls a script

Recommended Posts

Hi there,

Being as much of a scripting "noob" as I am (as in, I pretty much know literally nothing about scripting...), I've been picking up some fun scripts from the master list.

There is one thing I can't seem to find an easy way to do though; adding new options to the in-game menu.

 

Specifically, I'd like to add a menu option called Itempedia to the menu (above the Save option, preferably), which will activate the script call:

SceneManager.call (Scene_ItemDictionary)

 

If anybody's able to help me out with this, I'd very much appreciate it.

Thanks for your time!

Share this post


Link to post
Share on other sites

This seems like a nice scriptlet to make to improve my scripting skills.

Give me 5-10 minutes, i'll see what I can do.

 

Edit:

Aaannnnd, here we go:

 

#PoPS request - Itempedia in Menu
#By Jackus

class Window_MenuCommand
  alias PoPS_Menu_Request add_main_commands
  def add_save_command
    add_command("Itempedia", :itempedia)
    PoPS_Menu_Request()
  end
end

class Scene_Menu
    alias PoPS_Menu_Request_Scene create_command_window
    def create_command_window
      PoPS_Menu_Request_Scene()
      @command_window.set_handler(:itempedia,    method(:pedia))
    end
    
    def pedia
      SceneManager.call (Scene_ItemDictionary)
    end
  end

 

Let me know if you run into any issues or need something added :)

Edited by Jackus

Share this post


Link to post
Share on other sites

Awesome, thanks for the quick response!

That script you did semi-works... Itempedia shows up in the menu, and does exactly what I want it to do, buuut... this also happens for some reason (don't mind the strange names and stuff, it's a very silly game):

 

ONO_zpsw9syvktg.jpg

 

 

In case the image doesn't work, my first 4 menu commands are duplicated and placed under Itempedia, then the Quit option is under those, with the Save option completely gone!

It's strange to me how such a small bit of script can do so much...

I don't know anything about scripting, but maybe the "add_main_commands" is adding those 4 main commands for the 2nd time (since "add_main_commands" already appears in a default script), and the  "def add_save_command"  might be what's removing the Save option?

Edited by PoPS

Share this post


Link to post
Share on other sites

*Laughs* Yeah, it was a typo sorry. This should work:

 

#PoPS request - Itempedia in Menu
#By Jackus

class Window_MenuCommand
  alias PoPS_Menu_Request add_save_command
  def add_save_command
    add_command("Itempedia", :itempedia)
    PoPS_Menu_Request()
  end
end

class Scene_Menu
    alias PoPS_Menu_Request_Scene create_command_window
    def create_command_window
      PoPS_Menu_Request_Scene()
      @command_window.set_handler(:itempedia,    method(:pedia))
    end
    
    def pedia
      SceneManager.call (Scene_ItemDictionary)
    end
  end
Edited by Jackus

Share this post


Link to post
Share on other sites

Yaayy, seems to work perfectly now!

Thanks so much for your help! I have made a note of your name (at least, this one, Jackus) to put in the credits. As long as that's ok with you, of course.

Share this post


Link to post
Share on other sites

Yaayy, seems to work perfectly now!

Thanks so much for your help! I have made a note of your name (at least, this one, Jackus) to put in the credits. As long as that's ok with you, of course.

Yes, I prefer to credited as 'Jackus'. (Crediting is not compulsory, but would be nice. :))

 

Glad you like it! I learned a lot about Alias's making the script! :)

Edited by Jackus

Share this post


Link to post
Share on other sites

I know it's already solved but I'm using the Galv's Menu Theme Engine . With this , you an customize your menu and be able to add any SceneManager.call by adding it to the list . Hope it can help :P

Share this post


Link to post
Share on other sites

That does look quite good, but even that looks too complicated for me somehow. Pretty much anything that requires modifying/adding to the script in any way is likely to be beyond my abilities, and even with the instructions in that script, I wouldn't know what to do.

But thank ya for the suggestion. Maybe if I manage to get better at understanding scripts some day, I might be able to make use of more cool stuff like this.

Share this post


Link to post
Share on other sites

True , you need a little of script knowledge but it's not the most difficult script I have seen ( I can understand a little bit of scripting but it is very limited ) You don't need advanced knowledge to know how to make it work . Sorry to bother...

Share this post


Link to post
Share on other sites

It's no bother at all, I very much appreciate your suggestion and desire to help.

It pleases me that people here seem so friendly and helpful!

Share this post


Link to post
Share on other sites

Another way to modify the menu is to first go into the script editor, scroll down to the "Window_MenuCommand" script, and then add the specific command you want there; for example:

  #--------------------------------------------------------------------------
  # * Add Main Commands to List
  #--------------------------------------------------------------------------
  def add_main_commands
    add_command(("Inventory"),   :item,   main_commands_enabled)
    add_command(Vocab::equip,  :equip,  main_commands_enabled)
    add_command(("Learn"), :learn, main_commands_enabled)
    add_command(Vocab::skill,  :skill,  main_commands_enabled)
    add_command(Vocab::status, :status, main_commands_enabled)
    add_command(("Jobs"), :journal, main_commands_enabled)
  end

Then, scroll down to the "Scene_Menu" script where you can set the handler for the command.

  def create_command_window
    @command_window = Window_MenuCommand.new
    @command_window.x = 480
    @command_window.set_handler(:item,      method(:command_item))
    @command_window.set_handler(:skill,     method(:command_personal))
    @command_window.set_handler(:equip,     method(:command_personal))
    @command_window.set_handler(:status,    method(:command_personal))
    @command_window.set_handler(:parameters, method(:command_personal))
    @command_window.set_handler(:learn, method(:command_personal))
    @command_window.set_handler(:formation, method(:command_formation))
    @command_window.set_handler(:save,      method(:command_save))
    @command_window.set_handler(:game_end,  method(:command_game_end))
    @command_window.set_handler(:cancel,    method(:return_scene))
    @command_window.set_handler(:journal,      method(:command_journal))
    @command_window.set_handler(:load,      method(:command_load))
    @command_window.set_handler(:spellbook, method(:command_spellbook))
  end

And then finally, while still in the "Scene_Menu" script, add the actual scene call.

  #--------------------------------------------------------------------------
  # * [Item] Command
  #--------------------------------------------------------------------------
  def command_item
    SceneManager.call(Scene_Item)
  end
  
  def command_journal
    SceneManager.call(Scene_Journal)
  end
  
  def command_spellbook
    YES.skill_shop(1)
  end

Or, if it's a personal command (one that lets you select an actor, such as the Status or Equip commands), set the scene call here:

  #--------------------------------------------------------------------------
  # * [OK] Personal Command
  #--------------------------------------------------------------------------
  def on_personal_ok
    case @command_window.current_symbol
    when :skill
      SceneManager.call(Scene_Skill)
    when :equip
      SceneManager.call(Scene_Equip)
    when :status
      SceneManager.call(Scene_Status)
    when :parameters
      SceneManager.call(Scene_DistributeParameter)
    when :learn
        SceneManager.call(Scene_LearnSkill)
    end
  end

Share this post


Link to post
Share on other sites

I know it's already solved but I'm using the Galv's Menu Theme Engine . With this , you an customize your menu and be able to add any SceneManager.call by adding it to the list . Hope it can help :P

Yes that's true, but there are many incompatibilities with other scripts. For example I can't use that in my game, since it simply not works properly.

 

@ EDIT

May I use this script in my game? I would like to add LOAD command into my menu. :P

Edited by Rikifive

Share this post


Link to post
Share on other sites

@Disponi: Yeah, I was making a standalone script for covinience.

 

 

 

I know it's already solved but I'm using the Galv's Menu Theme Engine . With this , you an customize your menu and be able to add any SceneManager.call by adding it to the list . Hope it can help :P

Yes that's true, but there are many incompatibilities with other scripts. For example I can't use that in my game, since it simply not works properly.

 

@ EDIT

May I use this script in my game? I would like to add LOAD command into my menu. :P

 

To add load command, use this:

 

#Rikifive request - Load in Menu
#By Jackus

class Window_MenuCommand
  alias Rikifive_Menu_Request add_save_command
  def add_save_command
    add_command("Load", :Load)
    Rikifive_Menu_Request()
  end
end

class Scene_Menu
    alias Rikifive_Menu_Request_Scene create_command_window
    def create_command_window
      Rikifive_Menu_Request_Scene()
      @command_window.set_handler(:Load,    method(:load))
    end
    
    def load
      SceneManager.call (Scene_Load)
    end
  end

Share this post


Link to post
Share on other sites

I did that (edited) by myself already, :D I only wanted your permission to be able to use that. XD

But thank you anyway, it's a very useful script :)

Edited by Rikifive

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×