Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: cat on Sun 01/07/2012 10:49:20

Title: MODULE: OptionChosen
Post by: cat on Sun 01/07/2012 10:49:20
Important: This module becomes obsolete with AGS 3.3.0 or higher since it is now possible to use "Dialog.SetHasOptionBeenChosen(int option, bool chosen)"

However, for older versions this might still be useful, so I'll keep it here for now.

When using custom dialog rendering, you can use HasOptionBeenChosen, to check if this option has been chosen yet. However, it is not possible to reset this value (i.e. mark it as not chosen).

Use this module if you write custom dialog rendering, use HasOptionBeenChosen and want to set or reset the value for this.
   
You can use this directly in dialog:
   
Code (AGS) Select

   @1
   ego: I don't want to have this option marked as read.
      this.SetNotChosen(1);
   return

   
   In 'dialog_options_render' you can check for the saved value:
Code (AGS) Select
if (info.DialogToRender.IsChosen(i)) ds.DrawingColor = 5;

DO NOT CHECK FOR HasOptionBeenChosen IN YOUR SCRIPT BUT FOR IsChosen

I based this module on the code from GuyAwesome which was posted here:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37949.msg498961#msg498961 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37949.msg498961#msg498961)

Download here: http://cat.agser.me/modules/OptionChosen.zip (http://cat.agser.me/modules/OptionChosen.zip)
     
Title: Re: MODULE: OptionChosen
Post by: Ponch on Sat 14/07/2012 15:32:16
Downloaded this last night. For dialog heavy games like mine, this will come in very handy. Thanks, cat.  :)
Title: Re: MODULE: OptionChosen
Post by: Knox on Sat 21/09/2013 19:01:28
Sorry for re-opening, but I've got a question on this module.

I was able to get the previously read options "greyed out" (added the proper lines in 'dialog_options_render'), however I wasn'tt able to set the options back to "Not Chosen" so they no longer are greyed-out.

To debug, I wrote these lines in a certain dialog, and I never get "HasOptionBeenChosen" reset to 0.

Code (ags) Select

@3
  player.GSay("Blah blah");
  cGeorgeStorm.GSay("Blah blah");
  player.GSay("Blah blah");
  //debug lines
  player.GSay(String.Format("%d", dGeorgeStorm_01.HasOptionBeenChosen(3))); //result = 1 (as it should be)
  dGeorgeStorm_01.SetNotChosen(3); //set this current 3rd option to Not Chosen so it will revert back to "normal" color (not greyed out)
  player.GSay(String.Format("%d", dGeorgeStorm_01.HasOptionBeenChosen(3)));  //result = 1 (it SHOULD be 0...but its not)
 
  endConvo();


Am I trying to reset the options in the wrong area/wrong way?
Title: Re: MODULE: OptionChosen
Post by: monkey0506 on Sat 21/09/2013 19:37:53
General Knox, there's no way (currently) to reset the built-in tracking for whether the option has been chosen, so with this module you cannot use Dialog.HasOptionBeenChosen. The module provides the method Dialog.IsChosen instead.

Code (ags) Select
@3
  player.GSay("Blah blah");
  cGeorgeStorm.GSay("Blah blah");
  player.GSay("Blah blah");
  //debug lines
  player.GSay(String.Format("%d", dGeorgeStorm_01.IsChosen(3)));
  dGeorgeStorm_01.SetNotChosen(3); //set this current 3rd option to Not Chosen so it will revert back to "normal" color (not greyed out)
  player.GSay(String.Format("%d", dGeorgeStorm_01.IsChosen(3)));
 
  endConvo();
Title: Re: MODULE: OptionChosen
Post by: Knox on Sat 21/09/2013 21:29:45
Ok changing this line: (info.DialogToRender.HasOptionBeenChosen(current_option)) info.Surface.DrawingColor = game.read_dialog_option_color;
to (info.DialogToRender.IsChosen(current_option)) info.Surface.DrawingColor = game.read_dialog_option_color fixed it the problem.

Thanks Monkey! :grin:
Title: Re: MODULE: OptionChosen
Post by: cat on Sat 21/09/2013 22:05:12
Thanks Monkey for clarifying! I edited the first post, I hope it is now easier to understand how this module works.
Title: Re: MODULE: OptionChosen
Post by: Knox on Sat 21/09/2013 22:57:26
...and thanks Cat for this module! ;-D
Title: Re: MODULE: OptionChosen
Post by: Crimson Wizard on Sun 29/09/2013 18:36:52
Just a note, by Radiant's request, I am adding "Dialog.SetHasOptionBeenChosen(int option, bool chosen)" to AGS 3.3.0.