MODULE: OptionChosen

Started by cat, Sun 01/07/2012 10:49:20

Previous topic - Next topic

cat

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

   @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
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

Download here: http://cat.agser.me/modules/OptionChosen.zip
     

Ponch

Downloaded this last night. For dialog heavy games like mine, this will come in very handy. Thanks, cat.  :)

Knox

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

@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?
--All that is necessary for evil to triumph is for good men to do nothing.

monkey0506

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
@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();
 

Knox

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:
--All that is necessary for evil to triumph is for good men to do nothing.

cat

Thanks Monkey for clarifying! I edited the first post, I hope it is now easier to understand how this module works.

Knox

...and thanks Cat for this module! ;-D
--All that is necessary for evil to triumph is for good men to do nothing.

Crimson Wizard

Just a note, by Radiant's request, I am adding "Dialog.SetHasOptionBeenChosen(int option, bool chosen)" to AGS 3.3.0.

SMF spam blocked by CleanTalk