Battle Item Count VX
by Kyonides
Introduction


Then this scriptlet is for you!

The Script
Code:
# * Battle Item Count VX * #
# Plug & Play Script
# Scripter : Kyonides Arkanthes
# 2023-11-17
# The scriptlet updates the number of available items every single time you pick
# one or go back to the prior actor in battle.
class Game_Temp
alias :kyon_btl_itm_cnt_gm_tmp_init :initialize
def initialize
kyon_btl_itm_cnt_gm_tmp_init
@item_count = {}
@item_count.default = 0
end
def clear_item_count
@item_count.clear
end
def add_item_count(item)
@item_count[item.id] += 1
end
def reduce_item_count(item)
item_id = item.id
@item_count[item_id] -= 1 if @item_count[item_id] > 0
end
attr_reader :item_count
end
class Game_Party
alias :kyon_btl_itm_cnt_itm_nmbr :item_number
def item_number(item)
n = kyon_btl_itm_cnt_itm_nmbr(item) - $game_temp.item_count[item.id]
[n, 0].max
end
end
class Scene_Battle
alias :kyon_btl_itm_cnt_scn_btl_term :terminate
alias :kyon_btl_itm_cnt_scn_btl_st_pty_cmd_sel :start_party_command_selection
alias :kyon_btl_itm_cnt_scn_btl_prr_act :prior_actor
def terminate
kyon_btl_itm_cnt_scn_btl_term
$game_temp.clear_item_count
end
def start_party_command_selection
kyon_btl_itm_cnt_scn_btl_st_pty_cmd_sel
$game_temp.clear_item_count
end
def temp_decrease_item_count
return unless @active_battler
action = @active_battler.action
return unless action and action.item?
item = $data_items[action.item_id]
$game_temp.reduce_item_count(item) if item
end
def temp_increase_item_count
$game_temp.add_item_count(@item) if @item
end
def prior_actor
kyon_btl_itm_cnt_scn_btl_prr_act
temp_decrease_item_count
end
def update_item_selection
@item_window.active = true
@item_window.update
@help_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
temp_decrease_item_count
end_item_selection
elsif Input.trigger?(Input::C)
@item = @item_window.item
$game_party.last_item_id = @item.id if @item
if $game_party.item_can_use?(@item)
Sound.play_decision
temp_increase_item_count
determine_item
else
Sound.play_buzzer
end
end
end
end
Terms & Conditions
Free for use in ANY game.

Due credit is mandatory.

That's it!

"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE