Main Menu
  • Welcome to The RPG Maker Resource Kit.

[VXA] ATS: Choice Options 1.0.0

Started by modern algebra, January 28, 2013, 01:29:34 AM

0 Members and 1 Guest are viewing this topic.

modern algebra

ATS: Choice Options
Version: 1.0.0
Author: modern algebra
Date: 27 January 2013

Version History




  • <Version 1.0.0> 2013.01.27 - Original Release

Description



This script improves your control over the choice box by permitting more than four choices in a box, each of which you can disable or remove contingent on the value of any given switch. Additionally, it also allows you to extend the length of the choice beyond the editor's spacial limitations, allowing you to have long choices, and it adds an option for a help window to assist in describing the choices. Aside from that dynamic control over choice branches, you are also permitted to set the number of columns in the choice box, its size, and its position. There are other more minor features as well, which you can learn about in the instructions.

Features


  • More than four choices!
  • Hide or disable choices based on switch value
  • Can set size and position of choice box
  • Can set number of columns
  • Multi-line and long choices
  • Help window to assist player in decision

If you are looking for other features from my VX script of the same name, then see some of the other scripts in the ATS series.

Screenshots



Instructions

Paste the script into its own slot in the Script Editor, above Main but below Materials.

See the header for instructions on configuration and use.

Script



Retrieve it from Pastebin.

Credit




  • modern algebra

Support



Please post in this topic at RMRK.net if you have any questions, suggestions, error reports, or comments about this script. It is perfectly fine to post here even if this topic has not been posted in for a very long time.

Please do not message me privately, as any concerns you have are likely shared by others and they will benefit from our correspondence being public. Additionally, I am occasionally absent, and posting publically will allow other members to assist you when I am unable to do so quickly.

Known Compatibility Issues

I am currently unaware of any compatibility issues.

Demo



See attached.

Terms of Use



I adopt RMRK's default Terms of Use.

Bunni89

Append choices looks very useful! Would there be any way to work something like that where it auto adds a 'next' choice to the bottom and spreads things out throughout several choice windows? Or a scrolling amount of choices that can fit any number?
I've been on the hunt for some script like that for ages, its annoying how it seems impossible to do this sort of thing. Basically my situation is that I have an idea for being able to access a 'Talk' menu with important NPCs and then it fills up with topics of conversation as you progress in the game. But this is impossible to do since I can't have around 30 variable-locked choices and make them appear together in a natural way. Without choice appending I'd have to set them out in groups of 7 or so with a 'next' option, which is just gonna look ridiculous if you've unlocked one choice in group one and six in group two, so on. (It's be like "Choice 1, Next" *tiny window* "Choice 7, Choice 8, Choice 9.." *giant window*) And then with appending I have no clue how I'd be able to manage if you have too many choices to all show on the screen at once, since if it mashes them all together I have no idea where to put the Next choice. (If I put it as every eighth choice and you haven't unlocked any of the first 16 then you'll get "Next, Next, Choice 17", if I put it right at the end then noone will see it unless they only have seven unlocked..)
It's way more complicated than it should be! XD

A girl on each arm... the life of a cookie is never boring!
.:: TOTAL NEWBIE ::.
Divided between ideas for a norse mythology game and a sandbox romp through an original setting...
Gathering resources and learning in preparation!!
My deviantART account: bunni89.deviantart.com

modern algebra

Well, there is no feature where it auto-adds a next line, but it certainly will do the scrolling window which can fit any number of choices, and with switch-conditioned choices it will also allow you to enable the entries in whatever order you want. As well, you can set the size, so the window might be only able to fit four choices at a time (if that is the size you choose), but when the player scrolls down the other choices are available. You wouldn't have to have any "Nexts" at all.

Bunni89

That is badass and I now love you forever. FINALLY, A SOLUTION!! *dance* And one better than my hypothetical, lol!
Scrolling choices are a godsend. *prays at the mighty algebra's feet* Once again I'm throwing out piles of jury rigged lesser scripts to make way for your latest ATS.. how DO you keep being so amazing??

A girl on each arm... the life of a cookie is never boring!
.:: TOTAL NEWBIE ::.
Divided between ideas for a norse mythology game and a sandbox romp through an original setting...
Gathering resources and learning in preparation!!
My deviantART account: bunni89.deviantart.com

modern algebra


Chaos17

I tried your script and I am really pleased to be able to put long choices in my game!  :tpg:


I would like to know if it's possible to make a separation line/space or something like this ?


That the choices seem more distinct from one another.

modern algebra

Hmm, well that would require quite an adjustment to the script. If I were to take the request, I would essentially do it as a separate script, though one that is, of course compatible with this one. It would be fun to play with tones to change the colour of the windowskins for selection.

However, I can't see myself taking this request in the near future however. I'm sorry.

Chaos17

It's okay, you already did a good jo with your scripts.
Thanks to you my dialogues are appearing smothly in my game. 8)

Yin

Choice options gives me an error whenever I try to display a message with a face:

---------------------------
Demon's Revenge Ace
---------------------------
RGSSError occurred!
File: Internal Scripts/002 - Message Stuff/010 - MA - ATS - Choice Options.rb
Line: 541
Method: initialize
Message: failed to create bitmap

Trace:
File 'Internal Scripts/002 - Message Stuff/010 - MA - ATS - Choice Options.rb' line 541 (Method new)
File 'Internal Scripts/002 - Message Stuff/010 - MA - ATS - Choice Options.rb' line 541 (Method mapf_calc_line_width)
File 'Internal Scripts/002 - Message Stuff/007 - MA - ATS - Message Options.rb' line 895 (Block in calc_window_size_by_text)
File 'Internal Scripts/002 - Message Stuff/007 - MA - ATS - Message Options.rb' line 893 (Method each)
File 'Internal Scripts/002 - Message Stuff/007 - MA - ATS - Message Options.rb' line 893 (Method calc_window_size_by_text)
File 'Internal Scripts/002 - Message Stuff/007 - MA - ATS - Message Options.rb' line 880 (Method set_text)
File 'Internal Scripts/002 - Message Stuff/007 - MA - ATS - Message Options.rb' line 820 (Method update)
File 'Internal Scripts/002 - Message Stuff/007 - MA - ATS - Message Options.rb' line 972 (Method update_all_windows)
Script 'Window_Message' line 69 (Method update)
Script 'Scene_Base' line 95 (Block in update_all_windows)
Script 'Scene_Base' line 93 (Method each)
Script 'Scene_Base' line 93 (Method update_all_windows)
Script 'Scene_Base' line 49 (Method update_basic)
Script 'Scene_Base' line 41 (Method update)
File 'Internal Scripts/004 - Gameplay Enhancements/039 - SES - Dynamic Time.rb' line 511 (Method update)
Script 'Scene_Map' line 61 (Method update)
File 'Internal Scripts/003 - Added Functionality/015 - Cutscene Skipper.rb' line 151 (Method update)
Script 'Scene_Base' line 14 (Method main)
File 'Internal Scripts/004 - Gameplay Enhancements/040 - MOG - Weather EX.rb' line 652 (Method main)
Script 'SceneManager' line 23 (Method run)
Script 'Main' line 7 (Block in <main>)
Script 'Main' line 7 (In <main>)
File 'Error Parser.rb' line 307 (Method eval)
File 'Error Parser.rb' line 307 (In <main>)
Script 'Inserter' line 756 (Method eval)
Script 'Inserter' line 756 (In <main>)

---------------------------
OK   
---------------------------

Line 547 is:
self.contents = Bitmap.new(contents_width, 24)

Does this happen for anyone else or is it a compatibility issue?

&&&&&&&&&&&&&

What happens if you change

self.contents = Bitmap.new(contents_width, 24)

to

self.contents = Bitmap.new(24, 24)
&&&&&&&&&&&&&&&&

Yin


modern algebra

If you wouldn't mind, I would like to see a demo with that error recreated. It doesn't happen when I test, and the only reason it should happen is if a window's width is less than even its padding, which really ought to have caused an error earlier than that point in the script. Put more plainly, I'm confused, and I would like to make sure it isn't a flaw in the script itself.

&&&&&&&&&&&&&

&&&&&&&&&&&&&&&&

modern algebra

No, that fixes the problem and there is no reason for the bitmap to be larger than that. It is probably the most efficent way since it avoids creating a large bitmap and I probably should have done it that way in the first place.

However, I'm still worried about it since Window_Base's create_contents method also uses contents_width to determine the width of a bitmap. If contents_width is returning a number less than 0, then the error may repeat itself at other places in the game.

Yin

#14
I didn't really try it in a barebones project with just ATS, I just was checking to see if it was a real bug before I did that. I don't know if it happens without the rest of my scripts (I'm using an external text script by SES, Text control script by Victor Sant and the rest of the ATS series, which could be the only things (to my knowledge) messing with the message window to cause this error). I'll try it and see if it happens though.

Edit:
I tested it using only ATS scripts and it works fine. It must have been an incompatibility problem.

modern algebra

Thanks for testing it out for me Yin!

EmperorAlan

Is it not possible for us to make the choices blend together with the message window like the VX one?

modern algebra

Not yet. I suppose it wouldn't be terribly hard to add though.

exhydra

#18
Hmm, I have a minor feature request ... might the ability to disable a choice using evaluated code (with a boolean value) be added to the script? I certainly could use a switch, but I hate using a switch when a code snippet is easier (ie- 'DataManager.save_file_exists?', and so on).

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

LiTTleDRAgo

Quote from: Exhydra on August 03, 2013, 09:18:52 PM
Hmm, I have a minor feature request ... might the ability to disable a choice using evaluated code (with a boolean value) be added to the script? I certainly could use a switch, but I hate using a switch when a code snippet is easier (ie- 'DataManager.save_file_exists?', and so on).

just want to share

[spoiler]raise "Need MA's ATS: Choice Option" unless($imported||={})[:ATS_ChoiceOptions]
#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - atsco_interpret_command_402
#==============================================================================
class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Append Choice
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def atsco_interpret_command_402(params, index)
    # Accomodate for incorrect configuration of choice_format
    $game_message.choice_format = "" unless $game_message.choice_format.is_a?(String)
    $game_message.choice_format += '%s' unless $game_message.choice_format[/%s/]
    # Choice Plus
    plus_text, help_text = atsco_process_choice_comment(index + 1)
    choice_name = sprintf($game_message.choice_format, @list[index].parameters[1] + plus_text)
    del = false
    # Switch Conditions
    choice_name.gsub!(/\\S(!?)\[\s*(\d+)\s*\]/i) {
      # Set to delete if any condition not met
      cond = $game_switches[$2.to_i]
      del = true if $1.empty? ? !cond : cond
      "" }
    choice_name.gsub!(/\\S#(!?)\{\s*(.+?)\s*\}/i)  {
      cond = eval($2) rescue false
      del = true if $1.empty? ? !cond : cond
      "" }
    if del # If deleting
      @list[index].parameters[0] = -1
      # If cancel branch after this option
      if params[1] > params[0].size && params[1] < 1000
        params[1] -= 1 # Reduce ID of cancel
        params[1] = 0 if params[1] == params[0].size # If this was cancel, disable
      end
    else
      # Set index
      @list[index].parameters[0] = params[0].size
      # Add to choice array
      params[0].push(choice_name)
      # Add to Help Window
      $game_message.choice_help_texts.push(help_text)
    end
    return params, index
  end
end

#==============================================================================
# ** Window_ChoiceList
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - maatsco_choice_enabled?
#==============================================================================

class Window_ChoiceList
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Choice Enabled?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias_method :drg_atsco_choice_enabled, :maatsco_choice_enabled?
  def maatsco_choice_enabled?(index)
    name = command_name(index)
    enabled = drg_atsco_choice_enabled(index)
    name.gsub!(/\e[Dd]#(!?)\{\s*(.+?)\s*\}/i) {
      cond = $game_map.interpreter.send(:eval,$2) rescue false
      enabled = false if $1.empty? ? cond : !cond
      "" }
    enabled
  end
end
[/spoiler]

to use it :

\s#{ get_character(0).x > 3}
\s#!{ $game_party.members.size > 0 }
\d#{ FileTest.file?('Save003.rvdata2') }
\d#!{ $game_self_switches[[@map_id,@event_id,'A']] }

exhydra


UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

CJF

#21
First off, I just wanted to say thanks for making such a wonderful script that really adds a ton of value to VXA.

So far the scripts have worked awesomely, except for one thing. I've tried to change the number of lines for the Help Window. Changing the value within the Editable Region works, but using a script in game has no effect. I've tried;

ats_next(:choice_help_win_lines, 4)
and
ats_all(:choice_help_win_lines, 4)

And it has no effect on the number of lines in the Help Window. Any help would be appreciated. Thanks!

Japhasca

I'm using this script with the default settings (I have changed nothing in the script) and am getting this error when I call a certain common event (it seems to be working fine everywhere else I've used it):

Script 'Appended Choices' line 457: NoMethodError occurred.

undefined method `push' for nil:NilClass

The weird thing is, If I call another event that uses appended choices first, this one works fine afterwards.

This is the offending event (I have stripped out all other code and the error still occurs.)

DrunkDorks.com (us)
Facebook.com/DrunkDorks (us)
Twitter.com/OrihimeWarlock (me)

modern algebra

Hi, it's strange that happens, since that variable should be assigned an array as soon as a new game starts. It may be that you are loading an old save game from before you installed the script.

In any event, you should be able to fix it by pasting the following code into a script call before the choice branch:

$game_message.choice_help_texts = []

If it's not from an old save file, then it may be an incompatibility with another script.

charli3

I have one question, it is possible with that script to break line of text of choice option?
If not, anyone knows some way to do that?

Att,