(VXA) Adding a new shop option?

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
Hello! I'm new here and I am not 100% sure this is where I can get help with scripting.

So I want to make a new steal mechanic in the shop menu. The problem is that I don't know how to add the new option in Scene_Shop. Does anyone know how to add another shop menu option?
For a bit more context, all the scripting I have really done so far is a rough script to fix two characters.
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,354
Reaction score
8,536
First Language
English
Primarily Uses
RMMV

I've moved this thread to Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
Window_ShopCommand:
upload_2019-1-13_10-41-31.png
Code:
  def make_command_list
    add_command(Vocab::ShopBuy,    :buy)
    add_command(Vocab::ShopSell,   :sell,   !@purchase_only)
    add_command(Vocab::ShopSteal,  :steal)
    add_command(Vocab::ShopCancel, :cancel)
  end
Scene_Shop:
upload_2019-1-13_10-42-7.png
Code:
  def create_command_window
    @command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
    @command_window.viewport = @viewport
    @command_window.y = @help_window.height
    @command_window.set_handler(:buy,    method(:command_buy))
    @command_window.set_handler(:sell,   method(:command_sell))
    @command_window.set_handler(:steal, method(:command_steal))
    @command_window.set_handler(:cancel, method(:return_scene))
  end
upload_2019-1-13_10-42-36.png
Code:
  def command_buy
    @dummy_window.hide
    activate_buy_window
  end
  #-------------------------------------------------------------------------- 
  def command_steal
    #### stuff goes here
  end
You'll also need to make: def on_steal_ok, def activate_steal_window, and def on_steal_cancel.
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
Window_ShopCommand:
View attachment 107046
Code:
  def make_command_list
    add_command(Vocab::ShopBuy,    :buy)
    add_command(Vocab::ShopSell,   :sell,   !@purchase_only)
    add_command(Vocab::ShopSteal,  :steal)
    add_command(Vocab::ShopCancel, :cancel)
  end
Scene_Shop:
View attachment 107047
Code:
  def create_command_window
    @command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
    @command_window.viewport = @viewport
    @command_window.y = @help_window.height
    @command_window.set_handler(:buy,    method(:command_buy))
    @command_window.set_handler(:sell,   method(:command_sell))
    @command_window.set_handler(:steal, method(:command_steal))
    @command_window.set_handler(:cancel, method(:return_scene))
  end
View attachment 107048
Code:
  def command_buy
    @dummy_window.hide
    activate_buy_window
  end
  #--------------------------------------------------------------------------
  def command_steal
    #### stuff goes here
  end
You'll also need to make: def on_steal_ok, def activate_steal_window, and def on_steal_cancel.
Ok. I have done all this, but for some reason, .show.activate is not recognized for the steal activate.
Code:
  def command_steal
    @dummy_window.hide
    activate_steal_window
  end
 
  def on_steal_cancel
    @command_window.activate
    @dummy_window.show
    @steal_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
 
  def on_steal_ok
    @item = @steal_window.item
    @steal_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
 
  def create_steal_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @steal_window = Window_ShopSteal.new(0, wy, wh, @goods)
    @steal_window.viewport = @viewport
    @steal_window.help_window = @help_window
    @steal_window.status_window = @status_window
    @steal_window.hide
    @steal_window.set_handler(:ok,     method(:on_steal_ok))
    @steal_window.set_handler(:cancel, method(:on_steal_cancel))
  end
 
  def activate_steal_window
    @steal_window.show.activate
    @status_window.show
  end
Window_ShopSteal is just Window_ShopBuy but renamed.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,661
Reaction score
563
First Language
English
Primarily Uses
RMVXA
That just needs to be two commands.
@steal_window.show
@steal_window.activate
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,661
Reaction score
563
First Language
English
Primarily Uses
RMVXA
because your calling the activate before you create the window
def command_steal
@dummy_window.hide
create_steal_window
activate_steal_window
end
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
@Roninator2
That would create a memory leak because the steal window would be re-made without disposing the old one every time the player selects the steal command.

Just make that window upon starting the scene, either in the start method directly or in another, already existing window making method.
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
@Sixth @Roninator2
Thanks a lot guys!
That worked great, even finished the chance randomizer and what happens on a successful steal.
All I need to do now is somehow make the shop window close as the consequence.
 

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

Latest Threads

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,881
Messages
1,017,227
Members
137,607
Latest member
Maddo
Top