From 0e81a91664eabc64a38765392960405218e9a8f1 Mon Sep 17 00:00:00 2001 From: gumi Date: Sun, 19 Nov 2017 16:10:04 -0500 Subject: fix the stranger quiz --- world/map/npc/002-2/stranger.txt | 9 +++++++++ world/map/npc/functions/quiz.txt | 15 +++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/world/map/npc/002-2/stranger.txt b/world/map/npc/002-2/stranger.txt index e323293e..9616763b 100644 --- a/world/map/npc/002-2/stranger.txt +++ b/world/map/npc/002-2/stranger.txt @@ -58,6 +58,9 @@ L_Towel: mes "\"The first one is easy.\""; next; + cleararray @quiz_questions$[0], "", getarraysize(@quiz_questions$[0]); + cleararray @quiz_answers$[0], "", getarraysize(@quiz_answers$[0]); + setarray @quiz_questions$[0], "What two words are written in big friendly letters on the back cover?", "What's the name of the paranoid robot?", @@ -88,6 +91,9 @@ L_Towel: mes "\"You're absolutely right. The next one will be more tricky.\""; next; + cleararray @quiz_questions$[0], "", getarraysize(@quiz_questions$[0]); + cleararray @quiz_answers$[0], "", getarraysize(@quiz_answers$[0]); + setarray @quiz_questions$[0], "What is the name of the rock group claiming to be the loudest band in the universe?", "What star is near Ford's home planet?", @@ -122,6 +128,9 @@ L_Towel: mes "\"Not bad, not bad. Let's see if you can answer an even more difficult one.\""; next; + cleararray @quiz_questions$[0], "", getarraysize(@quiz_questions$[0]); + cleararray @quiz_answers$[0], "", getarraysize(@quiz_answers$[0]); + setarray @quiz_questions$[0], "Drinking what drink is like having your brain smashed out by a slice of lemon wrapped round a large gold brick?", "How many pints of beers should you drink before hitchhiking?", diff --git a/world/map/npc/functions/quiz.txt b/world/map/npc/functions/quiz.txt index 0f2f7c87..3deddd0a 100644 --- a/world/map/npc/functions/quiz.txt +++ b/world/map/npc/functions/quiz.txt @@ -5,10 +5,10 @@ function|script|MultiQuiz { - if((getarraysize(@quiz_answers$) != getarraysize(@quiz_questions$)) || + if((getarraysize(@quiz_answers$[0]) != getarraysize(@quiz_questions$[0])) || (@quiz_answers$[0] == "") || (@quiz_questions$[0] == "")) goto L_ArrayError; set @setindex, 1; - set @index, rand(0,(getarraysize(@quiz_answers$) - 1)); + set @index, rand(0,(getarraysize(@quiz_answers$[0]) - 1)); set @question$, @quiz_questions$[@index]; mes "\""+ @question$ + "\""; next; @@ -19,25 +19,24 @@ function|script|MultiQuiz L_ArrayError: if(@quiz_answers$[0] == "") debugmes "@quiz_answers$ is empty"; if(@quiz_questions$[0] == "") debugmes "@quiz_questions$ is empty"; - if(getarraysize(@quiz_answers$) != getarraysize(@quiz_questions$)) debugmes "Size of @quiz_answers$ is not equal to size of @quiz_questions$"; - mapexit; + if(getarraysize(@quiz_answers$[0]) != getarraysize(@quiz_questions$[0])) debugmes "Size of @quiz_answers$ is not equal to size of @quiz_questions$"; + close; } function|script|Quiz { if((@choices_nr < 1) || (@choices_nr > 8)) set @choices_nr, 3; - if(@choices_nr > getarraysize(@quiz_answers$)) set @choices_nr, getarraysize(@quiz_answers$); + if(@choices_nr > getarraysize(@quiz_answers$[0])) set @choices_nr, getarraysize(@quiz_answers$[0]); if(@quiz_answers$[0] == "") goto L_ArrayError; set @success, 0; if(@setindex < 1) set @index, @answer; set @good, rand(0,(@choices_nr - 1)); - setarray @choices$, ""; - cleararray @choices$, "", getarraysize(@choices$); + cleararray @choices$, "", getarraysize(@choices$[0]); set @loop, 0; goto L_Shuffle; L_Shuffle: - set @nindex, rand(0,(getarraysize(@quiz_answers$) - 1)); + set @nindex, rand(0,(getarraysize(@quiz_answers$[0]) - 1)); if(@nindex == @index) goto L_Shuffle; // do not get the good definition set @loop2, 0; goto L_Search; -- cgit v1.2.3-70-g09d2