[SOLVED]Javascript exception is thrown when jumping from a dialogue to another

Started by Giacomo, Fri 18/10/2024 13:50:53

Previous topic - Next topic

Crimson Wizard

Quote from: Giacomo on Wed 30/10/2024 12:23:31Still I wonder if it's ok in this case to use dAnotherDialog.Start().

This is your game, so it's your decision. Personally, I would not use a function that is known to work incorrectly inside a dialog script, even if it happens to achieve result in this case. And I do not see any real reason to use this function, since there's another variant that works correctly.

Giacomo

https://ko-fi.com/giacomo97557 To support Falco's adventures

Giacomo

This seems to work, I hope it can be useful for other users.

Code: ags
bool _checkAvailableOptions(Dialog* myDialog)
{
  for(int i = 1; i <= myDialog.OptionCount; i++)
  {
    if(myDialog.GetOptionState(i) == true) return true;  
  }
  return false;
} 
https://ko-fi.com/giacomo97557 To support Falco's adventures

Crimson Wizard

Quote from: Giacomo on Wed 30/10/2024 14:27:40
Code: ags
    if(myDialog.GetOptionState(i) == true) return true;

I'm sorry, but this is not accurate, although might work by coincidence. GetOptionState does not return a boolean, it returns enum:
https://adventuregamestudio.github.io/ags-manual/Dialog.html#dialoggetoptionstate

The correct way of checking would be
Code: ags
if(myDialog.GetOptionState(i) == eOptionOn) return true;

SMF spam blocked by CleanTalk