public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers
Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: ReKordChoices VX
  • Original author: kyonides
  • Original date: October 9, 2024
  • Source thread: https://forums.rpgmakerweb.com/threads/rekordchoices-vx.172484/
  • Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSS2 Scripts (RMVX)

Summary

ReKordChoices VX 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.

Archived First Post

ReKordChoices VX

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 VX + ACE * #
#   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
    @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 Game_Interpreter
  alias :kyon_rekord_choices_int_cmd_402 :command_402
  def command_402
    if @branch[@indent] == @params[0]
      map_id = $game_map.map_id
      page = $game_map.events[@event_id].page_index
      list = $game_variables[ReKord::CHOICES_LIST_VAR_ID]
      choice = @params[0] + 1
      $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
    $game_variables.choice(map_id, ev_id, page, list, choice_index, nil)
  end
end

DOWNLOAD DEMOS

Terms & Conditions

Free for use in ANY game.
Due credit is mandatory!
Mention this forum in your game credits.
That's it!

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download

License / Terms Note

Due credit is mandatory! Mention this forum in your game credits. That's it!

Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#rgss2#script-archive

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar