ReKordChoices XP
#1
ReKordChoices XP

by Kyonides

Introduction

This scriptlet allows you to auto-select 2 game variables that will store the choices list ID for the selected event page and the number of times you have selected a given option.

The value of that game variable will get updated automatically every time you pick any of the available choices.

The Script

Code:
# * ReKordChoices XP * #
#  Scripter : Kyonides Arkanthes
#  2024-10-08

# This scriptlet allows you to auto-select 2 game variables that will store
# the choices list ID for the selected event page and the number of times you
# have selected a given option.

# The value of that game variable will get updated automatically every time
# you pick any of the available choices.

# * Script Calls * #
# Use them to create a new choices list storage or to retrieve its data.
#  List of Arguments:
#  - ListID stands for Any "String" or Number
#  - ChoiceIndex is a Number, 1 through 4
#  - EventPage is a Number, 1 through 99 (Maximum Number of Pages)
# get_choice(ListID, ChoiceIndex)
# get_choice(ListID, ChoiceIndex, EventPage)
# get_choice(ListID, ChoiceIndex, EventPage, EventID)
# get_choice(ListID, ChoiceIndex, EventPage, EventID, MapID)

module ReKord
  CHOICES_LIST_VAR_ID = 5
  CHOICES_TIMES_VAR_ID = 6

class GameChoices
  def initialize
    @data = {}
    @data.default = 0
  end

  def [](key)
    @data[key]
  end

  def increase(key)
    @data[key] += 1
  end
  attr_reader :data
end

end

class Game_Variables
  alias :kyon_rekord_choices_gm_var_init :initialize
  def initialize
    kyon_rekord_choices_gm_var_init
    @choice_data = {}
  end

  def find_choice_set(map_id, event_id, page_index, list_index)
    @choice_data ||= {}
    key = [map_id, event_id, page_index, list_index]
    @choice_data[key] ||= ReKord::GameChoices.new
  end

  def set_choice_vars(choice_index, total)
    @data[ReKord::CHOICES_LIST_VAR_ID] = choice_index + 1
    @data[ReKord::CHOICES_TIMES_VAR_ID] = total
  end

  def choice(map_id, event_id, page, list_index, choice_index, go_up)
    choices = find_choice_set(map_id, event_id, page, list_index)
    choices.increase(choice_index) if go_up
    set_choice_vars(choice_index, choices[choice_index])
  end
end

class Game_Event
  def page_index
    @event.pages.index(@page)
  end
end

class Interpreter
  alias :kyon_rekord_choices_int_cmd_402 :command_402
  def command_402
    if @branch[@list[@index].indent] == @parameters[0]
      map_id = $game_map.map_id
      page = $game_map.events[@event_id].page_index
      list = $game_variables[ReKord::CHOICES_LIST_VAR_ID]
      choice = @parameters[0]
      $game_variables.choice(map_id, @event_id, page, list, choice, true)
    end
    kyon_rekord_choices_int_cmd_402
  end

  def get_choice(list, choice_index, page=nil, ev_id=nil, map_id=nil)
    map_id ||= $game_map.map_id
    ev_id ||= @event_id
    page = page ? page - 1 : $game_map.events[ev_id].page_index
    choice_index -= 1
    $game_variables.choice(map_id, ev_id, page, list, choice_index, nil)
  end
end


Terms & Conditions

Free for use in ANY game. Gamer
Due credit is mandatory!
Mention this forum in your game credits.
That's it! Tongue sticking out
"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]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: 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! Laughing + Tongue sticking out

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
Reply }




Users browsing this thread: 1 Guest(s)