Yazik Shop Upgrade

Hey, I've been using Yazik's Skill Shop for a while.

Spoiler: Yazik Skill & State Shop
Code:
#=======================================================
# Yazik - Skill & State Shop
#=======================================================

$imported = {} if $imported == nil
$imported[:Yazik_Skill_State_Shop] = true

#=======================================================
# Configurations
#=======================================================

module Yazik
  module Actor
    #--------------------------------------------------
    # Script Call:
    #   1. Actor's Add Skill Points
    #     add_skill_points(actor_id, points)
    #--------------------------------------------------
    
    # Starting Skill Point (When Actor at Level 1)
    StartingSkillPoint = 1
    
    # Skill Point Gain (When Actor Leveled Up)
    SkillPointGain = 1
  end
 
  module SkillShop
    # Command Name in Main Menu
    CommandName = 'Temple'

    # Command Index in Main Menu
    CommandIndex = 1
    
    # Skill Point Symbol
    SkillPointSymbol = '\C[16]W\C[0]'
    
    # Total Skill Point Text
    TotalSkillPointText = '\C[16]Waves: \C[0]'
    
    # Total Skill Point Text's X & Y position
    TotalSkillPointText_X = 216
    TotalSkillPointText_Y = 216
    
    # Vocab on Option Window
    VocabBuy = 'Acquire'
    VocabCancel = 'Cancel'

    # Help Window Settings
    HelpWindow_Opacity = 0
    HelpWindow_LineNumber = 4
    
    # Shop Window Settings
    ShopWindow_Opacity = 0
    ShopWindow_Column = 4
    ShopWindow_X = 0
    ShopWindow_Y = 22
    ShopWindow_Width = Graphics.width * 3/4
    ShopWindow_Height = (6 * 24) + 2 * 12
    
    # Actor's Skill Shop Database
    ShopDatabase = {
      # actor_id => [[skill_id, price], ..., [skill_id, price]],
      #player
      1 => [[139, 2], [140, 2], [133, 3], [127, 3], [51, 3], [50, 3], [8, 2], [135, 4], [60, 1], [102, 1], [28, 1], [29, 1], [2, 2], [53, 1], [54, 1], [117, 1],
      [55, 1], [56, 1], [57, 1], [44, 1], [124, 1], [97, 1], [75, 4, :state, "Teaches you how to use bows."],
      [74, 2, :state, "Teaches you how to use spears."], [88, 4, :state, "Teaches you how to use artifacts."], [112, 1, :state, "Teaches you how to use axes."],
      [101, 8, :state, "Doubles maximum magia points (continuously)."], [105, 2, :state, "+2% HP Regen."], [104, 5, :state, "200% Status Recovery Rate"],
      [102, 6, :state, "+15% DEF stat"], [68, 4, :state, "Immune to common poisons and venoms."], [4, 4, :state, "+150% TP Charge Rate."],
      [110, 3, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."], [125, 4, :state, "Immune to stat debuffs."]],
      #3 Bran
      3 => [[6, 2], [10, 3], [11, 2], [28, 1], [29, 1], [97, 1],  [123, 4, :state, "DEF stat is doubled."], [125, 3, :state, "Immune to stat debuffs."]],
      #4 Huiliang
      4 => [[137, 2], [60, 1], [28, 1], [29, 1], [97, 1], [125, 5, :state, "Immune to stat debuffs."]],
      #5 Xia
      5 => [[156, 3], [146, 1], [147, 2], [166, 1], [133, 1], [108, 2], [145, 2], [170, 1], [51, 1], [141, 4], [139, 1], [140, 1], [44, 1],
      [68, 2, :state, "Immune to common poisons and venoms."], [101, 4, :state, "Doubles maximum magia points."], [125, 1, :state, "Immune to stat debuffs."]],
      #7 Hana
      7 => [[45, 4], [50, 4], [13, 3], [14, 3], [15, 3], [16, 4], [135, 3], [3, 1], [12, 1], [60, 1], [102, 1], [202, 3], [28, 1], [29, 1], [44, 1],
      [75, 2, :state, "Teaches you how to use bows."], [76, 4, :state, "Teaches you how to use swords."],
      [87, 1, :state, "Teaches you how to wear magia clothes."], [68, 2, :state, "Immune to common poisons and venoms."],
      [101, 8, :state, "Doubles maximum magia points (continuously)."], [4, 3, :state, "+150% TP Charge Rate."],
      [100, 6, :state, "60% Frost Resistance, 10% Agility boost, +2 HP Regen, Immune to State: Hypothermia"], [125, 2, :state, "Immune to stat debuffs."],
      [110, 3, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."]],
      #8 Bloodfang
      8 => [[59, 5], [22, 3], [24, 4], [25, 2], [45, 2], [60, 1], [28, 1], [29, 1], [165, 1], [90, 1], [88, 5, :state, "Teaches you how to use artifacts."],
      [101, 8, :state, "Doubles maximum magia points (continuously)."], [68, 4, :state, "Immune to common poisons and venoms."],
      [4, 5, :state, "+150% TP Charge Rate."], [110, 3, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."],
      [125, 3, :state, "Immune to stat debuffs."]],
      #9 Azar
      9 => [[81, 2], [82, 3], [84, 4], [56, 3], [59, 4], [60, 1], [90, 1], [101, 8, :state, "Doubles maximum magia points (continuously)."],
      [4, 2, :state, "+150% TP Charge Rate."], [68, 2, :state, "Immune to common poisons and venoms."], [125, 4, :state, "Immune to stat debuffs."],
      [110, 2, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."]],
      #10 Tsei
      10 => [[71, 10], [74, 8], [76, 9], [60, 1], [28, 1], [29, 1], [97, 1], [101, 8, :state, "Doubles maximum magia points (continuously)."],
      [68, 4, :state, "Immune to common poisons and venoms."], [4, 2, :state, "+150% TP Charge Rate."], [125, 5, :state, "Immune to stat debuffs."],
      [110, 3, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."]],
      #12 Kaliska
      12 => [[38, 7], [39, 7], [51, 2], [60, 1], [101, 2, :state, "Doubles maximum magia points (continuously)."],
      [68, 2, :state, "Immune to common poisons and venoms."], [4, 4, :state, "+150% TP Charge Rate."], [125, 4, :state, "Immune to stat debuffs."],
      [110, 2, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."],
      [123, 4, :state, "DEF stat is doubled."], [124, 3, :state, "Kaliska received -60% Light and Dark damage, and also +1 HRG"]],
      #20 Celeste
      20 => [[59, 4], [191, 2], [109, 1], [68, 2, :state, "Immune to common poisons and venoms."], [105, 2, :state, "+2% HP Regen."],
      [125, 2, :state, "Immune to stat debuffs."]],
      #21 Nuala
      21 => [[6, 2], [10, 3], [11, 2], [28, 1], [29, 1], [44, 1], [97, 1],  [123, 4, :state, "DEF stat is doubled."], [125, 4, :state, "Immune to stat debuffs."]],
      }
    
    # Actor's Skill Shop Group Background
    # Place background graphic in Graphics/Pictures folder
    ShopBackground = {
      # actor_id => "Filename",
      # Set "" into filename to disable background.
      1 => "nl-scare2",
      2 => "nl-scare2",
      3 => "nl-scare2",
      4 => "nl-scare2",
      5 => "nl-scare2",
      6 => "nl-scare2",
      7 => "nl-scare2",
      8 => "nl-scare2",
      9 => "nl-scare2",
      10 => "nl-scare2",
      11 => "nl-scare2",
      12 => "nl-scare2",
      13 => "nl-scare2",
      14 => "nl-scare2",
      15 => "nl-scare2",
      16 => "nl-scare2",
      17 => "nl-scare2",
      18 => "nl-scare2",
      19 => "nl-scare2",
      20 => "nl-scare2",
      21 => "nl-scare2",
    }
  end
end

#==============================================================================
# ** Game_Interpreter
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Addd Skill Points
  #--------------------------------------------------------------------------
  def add_skill_points(actor_id, points)
    $game_actors[actor_id].skill_point += points
  end
end

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Variables
  #--------------------------------------------------------------------------
  attr_accessor :skill_point
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  alias :yazik_lsk_setup :setup
  def setup(actor_id)
    yazik_lsk_setup(actor_id)
    if @level > 1
      sp = Yazik::Actor::StartingSkillPoint
      @skill_point = sp + Yazik::Actor::SkillPointGain * (@level - 1)
    else
      @skill_point = Yazik::Actor::StartingSkillPoint
    end
  end
  #--------------------------------------------------------------------------
  # * Level Up
  #--------------------------------------------------------------------------
  alias :lune_sk_level_up :level_up
  def level_up
    lune_sk_level_up
    @skill_point += Yazik::Actor::SkillPointGain
  end
end

#==============================================================================
# ** Window_MenuCommand
#==============================================================================

class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def insert_command(index, name, symbol, enabled = true, ext = nil)
    cmd = {:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext}
    @list.insert(index, cmd)
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  alias :yazik_lst_make_command_list :make_command_list
  def make_command_list
    yazik_lst_make_command_list
    cmd_index = Yazik::SkillShop::CommandIndex
    cmd_name = Yazik::SkillShop::CommandName
    insert_command(cmd_index, cmd_name, :skill_tree, main_commands_enabled)
  end
end

#==============================================================================
# ** Window_ShopSkill
#==============================================================================

class Window_ShopSkill < Window_SkillList
  #--------------------------------------------------------------------------
  # * Variáveis públicas
  #--------------------------------------------------------------------------
  attr_reader :skill_tree
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, w, h)
    super(x, y, w, h)
    self.opacity = Yazik::SkillShop::ShopWindow_Opacity
    self.contents_opacity = 255
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return Yazik::SkillShop::ShopWindow_Column
  end
  #--------------------------------------------------------------------------
  # * Include in Skill List?
  #--------------------------------------------------------------------------
  def include?(item)
    return item
  end
  #--------------------------------------------------------------------------
  # * Display Skill in Active State?
  #--------------------------------------------------------------------------
  def enable?(item)
    return item
  end
  #--------------------------------------------------------------------------
  # * Create Skill List
  #--------------------------------------------------------------------------
  def make_item_list
    if @actor
      skills = []
      db = Yazik::SkillShop::ShopDatabase[@actor.id]
      for i in 0...db.size
        if db[i][2] == :state
          state_id = db[i][0]
          if @actor.state_addable?(state_id)
            state = $data_states[state_id]
            skills.push(state)
          end
        else
          skill = $data_skills[db[i][0]]
          if @actor.added_skill_types.include?(skill.stype_id)
            skills.push(skill)
          end
        end
      end
      @data = skills
    else
      @data = []
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    data = @data[index]
    if data
      rect = item_rect(index)
      rect.width -= 4
      enabled = data.class == RPG::Skill ? @actor.skill_learn?(data) : @actor.state?(data.id)
      draw_skill_icon(index, data, rect.x, rect.y, enabled)
      draw_skill_price(rect, index)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item Name
  #--------------------------------------------------------------------------
  def draw_skill_icon(index, item, x, y, enabled)
    return unless item
    draw_icon(item.icon_index, x, y, enabled)
  end
  #--------------------------------------------------------------------------
  # * Draw Skill Price
  #--------------------------------------------------------------------------
  def draw_skill_price(rect, index)
    db = Yazik::SkillShop::ShopDatabase[@actor.id]
    price = db[index][1]
    draw_text_ex(rect.x + 24 + 4, rect.y, price.to_s + Yazik::SkillShop::SkillPointSymbol)
  end
end

#==============================================================================
# ** Window_ShopHelp
#==============================================================================

class Window_ShopHelp < Window_Help
  #--------------------------------------------------------------------------
  # * Inicialização
  #--------------------------------------------------------------------------
  def initialize(line_number = Yazik::SkillShop::HelpWindow_LineNumber)
    super(line_number)
    self.opacity = Yazik::SkillShop::HelpWindow_Opacity
    self.contents_opacity = 255
    @item_name = ''
  end
  #--------------------------------------------------------------------------
  # * Clear
  #--------------------------------------------------------------------------
  alias :yazik_ss_clear :clear
  def clear
    @item_name = ''
    yazik_ss_clear
  end
  #--------------------------------------------------------------------------
  # * Set Name
  #--------------------------------------------------------------------------
  def set_name(item_name)
    if item_name != @item_name
      @item_name = item_name
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #--------------------------------------------------------------------------
  alias :yazik_ss_set_item :set_item
  def set_item(item)
    set_name(item ? item.name : "")
    if SceneManager.scene_is?(Scene_SkillShop)
      if (item) and (item.class == RPG::State)
        set_text(SceneManager.scene.database_item[3])
        return
      end
    end
    yazik_ss_set_item(item)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    change_color(system_color)
    draw_text(4, 0, contents_width - 4, line_height, @item_name)
    change_color(normal_color)
    draw_text_ex(4, line_height, @text)
    reset_font_settings
  end
end

#==============================================================================
# ** Window_TotalSkillPoint
#==============================================================================

class Window_TotalSkillPoint < Window_Base
  #--------------------------------------------------------------------------
  # * Inicialização
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, Graphics.width, Graphics.height)
    @actor = nil
    self.z = 200
    self.opacity = 0
    self.contents_opacity = 255
  end
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Atualização
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    tx = Yazik::SkillShop::TotalSkillPointText_X
    ty = Yazik::SkillShop::TotalSkillPointText_Y
    txt = Yazik::SkillShop::TotalSkillPointText + @actor.skill_point.to_s
    draw_text_ex(tx, ty, txt)
  end
end

#==============================================================================
# ** Window_ShopConfirm
#==============================================================================

class Window_ShopConfirm < Window_Command
  #--------------------------------------------------------------------------
  # * Inicialização do objeto
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    self.z = 9999
    self.x = (Graphics.width - self.width) / 2
    self.y = (Graphics.height - self.height) / 2
    self.openness = 0
  end
  #--------------------------------------------------------------------------
  # * Aquisição da largura da janela
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # * Criação da lista de comandos
  #--------------------------------------------------------------------------
  def make_command_list
    add_main_commands
  end
  #--------------------------------------------------------------------------
  # * Get Alignment
  #--------------------------------------------------------------------------
  def alignment
    return 1
  end
  #--------------------------------------------------------------------------
  # * Adição dos comandos principais
  #--------------------------------------------------------------------------
  def add_main_commands
    add_command(Yazik::SkillShop::VocabBuy, :confirm_buy, true)
    add_command(Yazik::SkillShop::VocabCancel, :confirm_cancel, true)
  end
end

#==============================================================================
# ** Scene_Menu
#==============================================================================

class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  alias :yazik_lst_create_command_window :create_command_window
  def create_command_window
    yazik_lst_create_command_window
    @command_window.set_handler(:skill_tree, method(:command_personal))
  end
  #--------------------------------------------------------------------------
  # * [OK] Personal Command
  #--------------------------------------------------------------------------
  alias :yazik_lst_on_personal_ok :on_personal_ok
  def on_personal_ok
    case @command_window.current_symbol
    when :skill_tree
      SceneManager.call(Scene_SkillShop)
    else
      yazik_lst_on_personal_ok
    end
  end
end

#==============================================================================
# ** Scene_SkillShop
#==============================================================================

class Scene_SkillShop < Scene_Skill
  #--------------------------------------------------------------------------
  # * Inicialização do processo
  #--------------------------------------------------------------------------
  def start
    super
#   create_actor_window
    create_info_window
    create_confirm_window
    create_background_image
  end
  #--------------------------------------------------------------------------
  # * Remove Default Scene_Skill Windows
  #--------------------------------------------------------------------------
  def create_command_window; end
  def create_status_window; end
  #--------------------------------------------------------------------------
  # * Create Help Window
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_ShopHelp.new(4)
    @help_window.viewport = @viewport
    @help_window.x = 0
    @help_window.y = Graphics.height - @help_window.height
  end
  #--------------------------------------------------------------------------
  # * Create Item Window
  #--------------------------------------------------------------------------
  def create_item_window
    wx = Yazik::SkillShop::ShopWindow_X
    wy = Yazik::SkillShop::ShopWindow_Y
    ww = Yazik::SkillShop::ShopWindow_Width
    wh = Yazik::SkillShop::ShopWindow_Height
    @item_window = Window_ShopSkill.new(wx, wy, ww, wh)
    @item_window.actor = @actor
    @item_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.set_handler(:ok,     method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:return_scene))
    @item_window.select(0)
    @item_window.activate
  end
  #--------------------------------------------------------------------------
  # * Item [OK]
  #--------------------------------------------------------------------------
  def on_item_ok
    is_skill = item.class == RPG::Skill
    is_state = item.class == RPG::State
    if (is_skill and [email protected]_learn?(item)) or (is_state and [email protected]?(item.id))
      db = Yazik::SkillShop::ShopDatabase[@actor.id]
      price = db[@item_window.index][1]
      if price <= $game_actors[@actor.id].skill_point
        @confirm_window.open
        @confirm_window.select(0)
        @confirm_window.activate
      else
        Sound.play_buzzer
        @item_window.activate
      end
    else
      @item_window.activate
    end
  end
  #--------------------------------------------------------------------------
  # * Criação das Janelas
  #--------------------------------------------------------------------------
  def create_confirm_window
    @confirm_window = Window_ShopConfirm.new
    @confirm_window.set_handler(:confirm_buy, method(:buy_item))
    @confirm_window.set_handler(:confirm_cancel, method(:activate_shop_window))
    @confirm_window.set_handler(:cancel, method(:activate_shop_window))
    @confirm_window.close
    @confirm_window.deactivate
  end
  #--------------------------------------------------------------------------
  # * Create Info Window
  #-------------------------------------------------------------------------- 
  def create_info_window
    @info_window = Window_TotalSkillPoint.new
    @info_window.actor = @actor
  end
  #--------------------------------------------------------------------------
  # * Activate Shop Window
  #--------------------------------------------------------------------------
  def activate_shop_window
    @confirm_window.close
    @confirm_window.deactivate
    @item_window.refresh
    @item_window.activate
  end
  #--------------------------------------------------------------------------
  # * Create Background Image
  #--------------------------------------------------------------------------
  def create_background_image
    bg = Yazik::SkillShop::ShopBackground[@actor.id]
    @background_image = Sprite.new
    @background_image.bitmap = Cache.picture(bg)
  end
  #--------------------------------------------------------------------------
  # * Database Item
  #--------------------------------------------------------------------------
  def database_item
    return Yazik::SkillShop::ShopDatabase[@actor.id][@item_window.index]
  end
  #--------------------------------------------------------------------------
  # * Buy Skill or State
  #--------------------------------------------------------------------------
  def buy_item
    db = Yazik::SkillShop::ShopDatabase[@actor.id]
    if db[@item_window.index][2] == :state
      state_id = db[@item_window.index][0]
      state_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= state_price
      $game_actors[@actor.id].add_state(state_id)
    else
      skill_id = db[@item_window.index][0]
      skill_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= skill_price
      $game_actors[@actor.id].learn_skill(skill_id)
    end
    @info_window.refresh
    @confirm_window.close
    @confirm_window.deactivate
    @item_window.refresh
    @item_window.activate
  end
  #--------------------------------------------------------------------------
  # * Terminate
  #--------------------------------------------------------------------------
  def terminate
    super
    @background_image.bitmap.dispose
    @background_image.dispose
  end
end

What I want is:
The ability to increase variables and turn on switches through it, like you would normally buy a skill or a state.
(and secondary: The ability to increase stats/ex parameters etc directly. While gaining states does somewhat cover this, it does not give me enough freedom. This one is not a priority though.)

Thanks for any help provided. The script will be used for my free-to-play Broken Reality RPG (https://lord-rutsah.itch.io/broken-reality-rpg).
Is that any variable and any switch?
There are a few stat point systems, perhaps one of those would work for you.
If there was a script that did a separate shop for variables and switches, would that also be good?
Is that any variable and any switch?
There are a few stat point systems, perhaps one of those would work for you.
If there was a script that did a separate shop for variables and switches, would that also be good?
I'd prefer if it were integrated into this one. A system for one-time "purchases", like one would with the skills/variables.
new code below
Spoiler: Yazik Skill Shop addon
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Yazik Skill Shop Addon       ║  Version: 1.01     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Allow Switches, Variables         ╠════════════════════╣
# ║   and Stat changes in shop          ║    06 Jul 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Input the settings to your preference. read carefully  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║   2022 07 06 - Initial Publish                           ║
# ║   2022 07 07 - Set switches to only be activated once    ║
# ║                Updated instructions                      ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝
#     ShopDatabase = {
#
      # Switch item format : [switch_id, price, :switch, "Description", item index],
      #   item index for switches and variables and stats is used to pull in
      #   an item for drawing an icon and making the code happy.
      # Variable item format : [var_id, price, :variable, "Description", item index],
      # Stat item format : [stat_id, price, :stat, "Description", item index, amount],
      #   stat amount is how much the stat increases
      #   Stat_id options are 0, 1, 2, 3, 4, 5, 6, 7
      #     MHP, MMP, ATK, DEF, MAT, MDF, AGI, LUK


class Window_ShopSkill < Window_SkillList
  def make_item_list
    if @actor
      skills = []
      db = Yazik::SkillShop::ShopDatabase[@actor.id]
      for i in 0...db.size
        if db[i][2] == :state
          state_id = db[i][0]
          if @actor.state_addable?(state_id)
            state = $data_states[state_id]
            skills.push(state)
          end
        elsif db[i][2] == :switch
          switch_id = db[i][0]
          switch = [$game_switches[switch_id], $data_items[db[i][4]]]
          skills.push(switch)
        elsif db[i][2] == :variable
          var_id = db[i][0]
          var = [$game_variables[var_id], $data_items[db[i][4]]]
          skills.push(var)
        elsif db[i][2] == :stat
          stat_id = db[i][0]
          stat = [stat_id, $data_items[db[i][4]], db[i][5]]
          skills.push(stat)
        else
          skill = $data_skills[db[i][0]]
          if @actor.added_skill_types.include?(skill.stype_id)
            skills.push(skill)
          end
        end
      end
      @data = skills
    else
      @data = []
    end
  end
  def draw_item(index)
    data = @data[index]
    if data
      rect = item_rect(index)
      rect.width -= 4
      if data.class == RPG::Skill
        enabled = @actor.skill_learn?(data)
      elsif data.class ==  RPG::State
        enabled = @actor.state?(data.id)
      else
        if data[0].is_a?(Fixnum)
          enabled = true
        elsif data[0].is_a?(FalseClass)
          enabled = false
        else
          enabled = true
        end
      end
      draw_skill_icon(index, data, rect.x, rect.y, enabled)
      draw_skill_price(rect, index)
    end
  end
  def draw_skill_icon(index, item, x, y, enabled)
    return unless item
    if item.is_a?(Array)
      draw_icon(item[1].icon_index, x, y, enabled)
    else
      draw_icon(item.icon_index, x, y, enabled)
    end
  end
end

class Scene_SkillShop < Scene_Skill
  def on_item_ok
    is_skill = item.class == RPG::Skill
    is_state = item.class == RPG::State
    is_array = item.class == Array
    if (is_skill and [email protected]_learn?(item)) or (is_state and [email protected]?(item.id)) or (is_array)
      db = Yazik::SkillShop::ShopDatabase[@actor.id]
      price = db[@item_window.index][1]
      if db[@item_window.index][2] == :switch
        if $game_switches[db[@item_window.index][0]] == true
          Sound.play_buzzer
          @item_window.activate
        else
          @confirm_window.open
          @confirm_window.select(0)
          @confirm_window.activate
        end
      elsif price <= $game_actors[@actor.id].skill_point
        @confirm_window.open
        @confirm_window.select(0)
        @confirm_window.activate
      else
        Sound.play_buzzer
        @item_window.activate
      end
    else
      @item_window.activate
    end
  end
  def buy_item
    db = Yazik::SkillShop::ShopDatabase[@actor.id]
    if db[@item_window.index][2] == :state
      state_id = db[@item_window.index][0]
      state_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= state_price
      $game_actors[@actor.id].add_state(state_id)
    elsif db[@item_window.index][2] == :switch
      switch_id = db[@item_window.index][0]
      switch_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= switch_price
      $game_switches[switch_id] = !$game_switches[switch_id]
    elsif db[@item_window.index][2] == :variable
      var_id = db[@item_window.index][0]
      var_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= var_price
      $game_variables[var_id] += var_price
    elsif db[@item_window.index][2] == :stat
      stat_id = db[@item_window.index][0]
      amount = db[@item_window.index][5]
      stat_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= stat_price
      @actor.add_param(stat_id, amount)
    else
      skill_id = db[@item_window.index][0]
      skill_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= skill_price
      $game_actors[@actor.id].learn_skill(skill_id)
    end
    @info_window.refresh
    @confirm_window.close
    @confirm_window.deactivate
    @item_window.refresh
    @item_window.activate
  end
end

class Window_ShopHelp < Window_Help
  def set_item(item)
    if item.class == Array
      item = item[1]
      set_name(item.name)
    else
      set_name(item ? item.name : "")
    end
    if SceneManager.scene_is?(Scene_SkillShop)
      if (item) and (item.class == RPG::State or Array)
        set_text(SceneManager.scene.database_item[3])
        return
      end
    end
    yazik_ss_set_item(item)
  end
end
IDK if the forums have deleted it, but I responded that for some reason, variables don't grey out once you buy them. You can purchase them infinitely, which is something I don't want.
New code below
@Gravemaster
Spoiler: Yazik Skill Shop Addon - 1.02
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Yazik Skill Shop Addon       ║  Version: 1.02     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Allow Switches, Variables         ╠════════════════════╣
# ║   and Stat changes in shop          ║    06 Jul 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Input the settings to your preference. read carefully  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║   2022 07 06 - Initial Publish                           ║
# ║   2022 07 07 - Set switches to only be activated once    ║
# ║                Updated instructions                      ║
# ║   2022 07 09 - Modified variables to be used only once   ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝
#     ShopDatabase = {
#
      # Switch item format : [switch_id, price, :switch, "Description", item index],
      #   item index for switches and variables and stats is used to pull in
      #   an item for drawing an icon and making the code happy.
      # Variable item format : [var_id, price, :variable, "Description", item index],
      # Stat item format : [stat_id, price, :stat, "Description", item index, amount],
      #   stat amount is how much the stat increases
      #   Stat_id options are 0, 1, 2, 3, 4, 5, 6, 7
      #     MHP, MMP, ATK, DEF, MAT, MDF, AGI, LUK


class Window_ShopSkill < Window_SkillList
  def make_item_list
    if @actor
      skills = []
      db = Yazik::SkillShop::ShopDatabase[@actor.id]
      for i in 0...db.size
        if db[i][2] == :state
          state_id = db[i][0]
          if @actor.state_addable?(state_id)
            state = $data_states[state_id]
            skills.push(state)
          end
        elsif db[i][2] == :switch
          switch_id = db[i][0]
          switch = [$game_switches[switch_id], $data_items[db[i][4]], :switch]
          skills.push(switch)
        elsif db[i][2] == :variable
          var_id = db[i][0]
          var = [$game_variables[var_id], $data_items[db[i][4]], :variable]
          skills.push(var)
        elsif db[i][2] == :stat
          stat_id = db[i][0]
          stat = [stat_id, $data_items[db[i][4]], :stat, db[i][5]]
          skills.push(stat)
        else
          skill = $data_skills[db[i][0]]
          if @actor.added_skill_types.include?(skill.stype_id)
            skills.push(skill)
          end
        end
      end
      @data = skills
    else
      @data = []
    end
  end
  def draw_item(index)
    data = @data[index]
    if data
      rect = item_rect(index)
      rect.width -= 4
      if data.class == RPG::Skill
        enabled = @actor.skill_learn?(data)
      elsif data.class ==  RPG::State
        enabled = @actor.state?(data.id)
      elsif data[2] == :switch
        enabled = true if data[0].is_a?(FalseClass)
      elsif data[2] == :variable
        enabled = true if data[0] == 0
      elsif data[2] == :stat
        enabled = true
      end
      draw_skill_icon(index, data, rect.x, rect.y, enabled)
      draw_skill_price(rect, index)
    end
  end
  def draw_skill_icon(index, item, x, y, enabled)
    return unless item
    if item.is_a?(Array)
      draw_icon(item[1].icon_index, x, y, enabled)
    else
      draw_icon(item.icon_index, x, y, enabled)
    end
  end
end

class Scene_SkillShop < Scene_Skill
  def on_item_ok
    is_skill = item.class == RPG::Skill
    is_state = item.class == RPG::State
    is_array = item.class == Array
    if (is_skill and [email protected]_learn?(item)) or (is_state and [email protected]?(item.id)) or (is_array)
      db = Yazik::SkillShop::ShopDatabase[@actor.id]
      price = db[@item_window.index][1]
      if db[@item_window.index][2] == :switch
        if $game_switches[db[@item_window.index][0]] == true
          Sound.play_buzzer
          @item_window.activate
        else
          @confirm_window.open
          @confirm_window.select(0)
          @confirm_window.activate
        end
      elsif db[@item_window.index][2] == :variable
        if $game_variables[db[@item_window.index][0]] != 0
          Sound.play_buzzer
          @item_window.activate
        else
          @confirm_window.open
          @confirm_window.select(0)
          @confirm_window.activate
        end
      elsif price <= $game_actors[@actor.id].skill_point
        @confirm_window.open
        @confirm_window.select(0)
        @confirm_window.activate
      else
        Sound.play_buzzer
        @item_window.activate
      end
    else
      @item_window.activate
    end
  end
  def buy_item
    db = Yazik::SkillShop::ShopDatabase[@actor.id]
    if db[@item_window.index][2] == :state
      state_id = db[@item_window.index][0]
      state_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= state_price
      $game_actors[@actor.id].add_state(state_id)
    elsif db[@item_window.index][2] == :switch
      switch_id = db[@item_window.index][0]
      switch_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= switch_price
      $game_switches[switch_id] = !$game_switches[switch_id]
    elsif db[@item_window.index][2] == :variable
      var_id = db[@item_window.index][0]
      var_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= var_price
      $game_variables[var_id] += var_price
    elsif db[@item_window.index][2] == :stat
      stat_id = db[@item_window.index][0]
      amount = db[@item_window.index][5]
      stat_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= stat_price
      @actor.add_param(stat_id, amount)
    else
      skill_id = db[@item_window.index][0]
      skill_price = db[@item_window.index][1]
      $game_actors[@actor.id].skill_point -= skill_price
      $game_actors[@actor.id].learn_skill(skill_id)
    end
    @info_window.refresh
    @confirm_window.close
    @confirm_window.deactivate
    @item_window.refresh
    @item_window.activate
  end
end

class Window_ShopHelp < Window_Help
  def set_item(item)
    if item.class == Array
      item = item[1]
      set_name(item.name)
    else
      set_name(item ? item.name : "")
    end
    if SceneManager.scene_is?(Scene_SkillShop)
      if (item) and (item.class == RPG::State or Array)
        set_text(SceneManager.scene.database_item[3])
        return
      end
    end
    yazik_ss_set_item(item)
  end
end
Thank you Roninator2, but now one of the old problems is back, where many skills/states don't have their matching descriptions (sorry for answering late, development has been hectic).
I downloaded your game and compared the code to the temple screen bought some variable upgrades and they worked.
I don't see any issue.
No, the variables work fine. It's skills and states that are missing descriptions left and right again.
1657996354489.png


I do see a possible issue.
just change one small part. item to itemn in two spots. (just a random character. n for name.
Ruby:
class Window_ShopHelp < Window_Help
  def set_item(item)
    if item.class == Array
      itemn = item[1]
      set_name(itemn.name)
    else
      set_name(item ? item.name : "")
    end
    if SceneManager.scene_is?(Scene_SkillShop)
      if (item) and (item.class == RPG::State or Array)
        set_text(SceneManager.scene.database_item[3])
        return
      end
    end
    yazik_ss_set_item(item)
  end
end
I'll update the code in a second.
Can I ask for one more change? Can you give me the option with the addon to increase the variables by an "X" number instead of a steady 1?
Code updated below
Version 1.03 fixes the issue for states that can be purchased, but now all skills have no descriptions.
Fixed. It was the condition for the help text. 1.03.1
Thank you! It finally works as intended.
You can find the full game here btw, I uploaded the newest patch a few days ago.
...Nevermind, it doesn't work as intended. It doesn't let the players buy the variable-raising ones at all.
It has the options as greyed out completely.
It doesn't let the players buy the variable-raising ones at all.
It has the options as greyed out completely.
I'm using your demo and it works fine for me.
Actually it lets me buy the variable even if I don't have enough points.
I'll look at that. Fixed buying variables without proper skill points
It doesn't let the players buy the variable-raising ones at all.
It has the options as greyed out completely.
One thought. Are these variables higher than 0 at any time before you buy them in the shop?
Because that's the condition for having them available is that they are less than or equal to 0.
So if that variable is 1 or 2 at any time then the shop will think you bought it.

I think I understand another issue as well.
The switches and variables are global for all actors not individually.
I'll have to work on it some more.

Code updated below
Addon pops up error when trying to enter the shop of a character.
image_2022-07-20_192304573.png
Addon pops up error when trying to enter the shop of a character.
Unfortunately you need to start a new game.
The change puts variables into the game actor which is setup when starting a game.

Original thread: https://forums.rpgmakerweb.com/threads/yazik-shop-upgrade.149220/