Hello, everybody I have a problem that I cannot solve.
It's about a dialogues series in which you have to give three right answers, otherwise you will have restart from the beginning.
The first dialogue opens some topics of the second dialogue, depending from the answer given. Then, the second dialogue opens some topics in a third dialogue, always depending from the answer. Because the topics were many, the third dialogue has been split in two dialogues.
If you give the wrong answer in the third dialogue, the options of the last two dialogues are set off and you restart from the first dialogue.
Before I had another problem: if I continued to say the wrong answer, restarting the dialogue for about 15 times, the game crashed displaying a message concerning a recursive call.
I solved this problem by forcing the player to give the solution after a certain number of attempts(and he gets a negative point!), but I felt there was still something to fix.
The new problem shows up in the web version of the game only. If I say the right answer at the first attempt, the problem won't show up. But if I miss the answer just once and then restart the dialogue, a javascript exception gets thrown with these error messages:
Aborted(RuntimeError: unreachable executed)
Uncaught RuntimeError: Aborted(RuntimeError: unreachable executed). Build with -sASSERTIONS for more info.
I'll try to reduce the script removing the recurring parts.
FIRST DIALOGUE(8 AVAILABLE ANSWERS):
Code: ags
SECOND DIALOGUE(3 AVAILABLE ANSWERS):
Code: ags
THIRD DIALOGUE(SPLIT IN 2, 3 AVAILABLE ANSWERS):
Code: ags
Code: ags
FUNCTIONS TO RESET DIALOGUES:
Code: ags
If it can help, I can share a video where you can see the moment in which the game crashes and when the error message shows up.
I know that the question might be complex and I hope I wrote enough to understand how the script works. I tested it a lot and the logic seems to be correct (maybe the script can be reduced as well), I don't know what triggers the error in the web version. I hope there's a solution.
Thank you,
Giacomo
It's about a dialogues series in which you have to give three right answers, otherwise you will have restart from the beginning.
The first dialogue opens some topics of the second dialogue, depending from the answer given. Then, the second dialogue opens some topics in a third dialogue, always depending from the answer. Because the topics were many, the third dialogue has been split in two dialogues.
If you give the wrong answer in the third dialogue, the options of the last two dialogues are set off and you restart from the first dialogue.
Before I had another problem: if I continued to say the wrong answer, restarting the dialogue for about 15 times, the game crashed displaying a message concerning a recursive call.
I solved this problem by forcing the player to give the solution after a certain number of attempts(and he gets a negative point!), but I felt there was still something to fix.
The new problem shows up in the web version of the game only. If I say the right answer at the first attempt, the problem won't show up. But if I miss the answer just once and then restart the dialogue, a javascript exception gets thrown with these error messages:
Aborted(RuntimeError: unreachable executed)
Uncaught RuntimeError: Aborted(RuntimeError: unreachable executed). Build with -sASSERTIONS for more info.
I'll try to reduce the script removing the recurring parts.
FIRST DIALOGUE(8 AVAILABLE ANSWERS):
Spoiler
// Dialog script file
@S // Dialog startup entry point
if(ominoTentativi == 12) //force to skip to final dialogue
{
omino: Dad, I'm tired!
cUomoAppeso: Me too!
omino: You are too weak...
Wait(20);
omino: I want sugar candies...
cUomoAppeso: Finally!
dOminoPapaFinale.Start();
}
else if(ominoTentativi > 0) //after the first attempt, say the following
{
omino: Wrong answer!
omino: Again, what am I thinking about?
}
return
@1 //wrong answer, like options 2, 6
_ominoDialoghi(1, 0); //see functions below
if(ominoGiocattoli) //global var bool, a kind of "if option has been choosen"
omino: Maybe no...
else
omino: Maybe.
dOminoPapa2.Start();
stop
(...)
@3 //right answer
_ominoDialoghi(7, 0);
omino: Maybe.
dOminoPapa2.Start();
stop
@4 //options 4, 5, 7, 8 will return to current dialogue
dOminoPapa1.SetOptionState(4, eOptionOffForever);
return
(...)
[close]
SECOND DIALOGUE(3 AVAILABLE ANSWERS):
Spoiler
// Dialog script file
@S // Dialog startup entry point
return
@1
if(ominoGiocattoli) //same global var bool, used for the three available options
omino: Maybe no!
else
omino: Maybe...
_ominoDialoghiCanc(33); //see function below
_ominoDialoghi(1, 1); //see function below
dOminoPapa31.Start(); //open part one of third dialogue
stop
@2
if(ominoGiocattoli)
omino: Maybe no!
else
omino: Maybe...
_ominoDialoghiCanc(33);
_ominoDialoghi(4, 1);
dOminoPapa31.Start();
stop
@3
if(ominoGiocattoli)
omino: Maybe no!
else
omino: Maybe...
_ominoDialoghiCanc(33);
_ominoDialoghi(7, 1);
dOminoPapa31.Start();
stop
(...)
@6
if(ominoVideogame)
omino: Maybe no!
else
omino: Maybe...
_ominoDialoghiCanc(33);
_ominoDialoghi(16, 1);
dOminoPapa31.Start();
stop
@7
if(ominoCiboCarne)
omino: Maybe no!
else
omino: Maybe...
_ominoDialoghiCanc(33);
_ominoDialoghi(1, 2);
dOminoPapa32.Start(); //open part two of third dialogue
stop
@8
if(ominoCiboPizza)
omino: Maybe no!
else
omino: Maybe...
_ominoDialoghiCanc(33);
_ominoDialoghi(4, 2);
dOminoPapa32.Start();
stop
(...)
@12
if(ominoTravestimenti)
omino: Maybe no!
else
omino: Maybe...
_ominoDialoghiCanc(33);
_ominoDialoghi(16, 2);
dOminoPapa32.Start();
stop
[close]
THIRD DIALOGUE(SPLIT IN 2, 3 AVAILABLE ANSWERS):
Spoiler
// Dialog script file
@S // Dialog startup entry point
return
@1
if(Game.DoOnceOnly("dOminoPapa3101")) //say once when the answer was choosen
{
omino: I don't like that doll...
omino: ...I only like the video-game of Monkey Donk@!
}
if(Game.DoOnceOnly("ominoGiocattoli")) _ominoDialoghiFinale(0); //say once when the previous answer was choosen
else _ominoDialoghiFinale(4); //the second time say another thing
_ominoDialoghiCanc(34);
dOminoPapa1.Start(); //restart
stop
(...)
@10
if(Game.DoOnceOnly("dOminoPapa3110"))
omino: I want it but it's not here.
if(Game.DoOnceOnly("ominoVideogames")) _ominoDialoghiFinale(1);
else _ominoDialoghiFinale(5);
_ominoDialoghiCanc(34);
dOminoPapa1.Start();
stop
(...)
[close]
Spoiler
// Dialog script file
@S // Dialog startup entry point
return
@1
if(Game.DoOnceOnly("dOminoPapa3201"))
omino: That's what YOU want!
if(Game.DoOnceOnly("ominoCibo")) _ominoDialoghiFinale(2);
else _ominoDialoghiFinale(60);
_ominoDialoghiCanc(35);
ominoCiboCarne = true;
dOminoPapa1.Start();
stop
@2
if(Game.DoOnceOnly("dOminoPapa3202"))
{
cOmino.FaceDirection(eDirectionLeft);
omino: Like those?
cUomoAppeso: Yes!
cGiostraia.FaceDirection(eDirectionRight);
giostraia: No way!
cOmino.FaceDirection(eDirectionRight);
cGiostraia.FaceDirection(eDirectionDown);
omino: Dad, I don't like chicken!
}
if(Game.DoOnceOnly("ominoCibo")) _ominoDialoghiFinale(2);
else _ominoDialoghiFinale(60);
_ominoDialoghiCanc(35);
ominoCiboCarne = true;
dOminoPapa1.Start();
stop
(...)
@7
if(Game.DoOnceOnly("dOminoPapa3207"))
omino: I would like it but where can you see it?
if(Game.DoOnceOnly("ominoCibo")) _ominoDialoghiFinale(2);
else _ominoDialoghiFinale(62);
_ominoDialoghiCanc(35);
dOminoPapa1.Start();
stop
@8 //right answer
omino: Yes!
omino: You guessed it, daddy!
dOminoPapaFinale.Start();
stop
@9
if(Game.DoOnceOnly("dOminoPapa3209"))
omino: Maybe but it's not here.
if(Game.DoOnceOnly("ominoCibo")) _ominoDialoghiFinale(2);
else _ominoDialoghiFinale(62);
_ominoDialoghiCanc(35);
dOminoPapa1.Start();
stop
(...)
[close]
FUNCTIONS TO RESET DIALOGUES:
Spoiler
function _ominoDialoghi(int topic, int dialogNumber) //set options state in next dialogue
{
int w = topic;
while(w <= topic + 2) //if I choose 1st answer, set option 1, 2, 3 on, 2nd answer set 4, 5, 6 on etc etc.
{
if(dialogNumber == 0) dialog[33].SetOptionState(w ,eOptionOn);
else if (dialogNumber == 1) dialog[34].SetOptionState(w ,eOptionOn);
else dialog[35].SetOptionState(w ,eOptionOn);
w++;
}
}
function _ominoDialoghiCanc(int dialogNumber) //reset options of the choosen dialogue
{
for(int o = 1; o <= dialog[dialogNumber].OptionCount; o++)
{
if(dialog[dialogNumber].GetOptionState(o) == eOptionOn) dialog[dialogNumber].SetOptionState(o, eOptionOff);
}
}
function _ominoDialoghiFinale(int field) //custom functions for a dialog
{
if(field == 0) //toy
{
//say something
ominoGiocattoli = true;
}
else if(field == 1) //videogame
{
//say something
ominoVideogame = true;
}
else if(field == 2) //food
{
//say something once, this is the right field so I manage it in another way
}
else if(field == 3) //disguise
{
//say something once
ominoTravestimenti = true;
} //say these things if you choose a field twice, the field food has 3 different phrases because it is the right first answer and I reply according to what you chose for as next answer(1st answer: food --> 2nd answer: meat/flours/sweets)
else if(field == 4) cOmino.Say("I said it's not about toys!"); //toy 2nd time
else if(field == 5) cOmino.Say("I can't get any video-game here!"); //videogame 2ndtime
else if(field == 60) cOmino.Say("I don't want meat right now!"); //food/meat
else if(field == 61) cOmino.Say("I don't want anything like pizza, pasta or panini!"); //food/flours
else if(field == 62) cOmino.Say("A sweet may be interesting!"); //food/sweet
else if(field == 7) cOmino.Say("I only want that football shirt and I can't have it!"); //disguises 2nd time
ominoTentativi++; //this function is called when the chose answer is wrong, so I count the attempts at the end
}
[close]
If it can help, I can share a video where you can see the moment in which the game crashes and when the error message shows up.
I know that the question might be complex and I hope I wrote enough to understand how the script works. I tested it a lot and the logic seems to be correct (maybe the script can be reduced as well), I don't know what triggers the error in the web version. I hope there's a solution.
Thank you,
Giacomo