Fixing Infinite Loop...? Help?

So clearly I am having some issue with getting this loop to work. It’s a little difficult to explain what it does but I will try to simplify. Essentially, I have a variable called ‘lsetting,’ this variable tells the game which of the words from each of the dictionary term arrays to use for the variable.

An example of an array for the dictionary looks like this:

*create_array ad_Hui 6 "輝" "辉" "Huī" "Hui" "Hui" "radiance"

So if lsetting is 1 it’ll set Hui to “輝”, if lsetting is 3 it’ll set Hui to “Huī”, etc.

So the loop is something like this…

*temp temp_dictindex (atd_index[1])
*temp temp_wordcount 1
*temp temp_indexcount 1
*temp temp_translatingword ({("atd_" & temp_dictindex) & "_1"})

*label translation_loop

*if temp_wordcount >= {("atd_" & temp_dictindex) & "_count"}
    *set temp_wordcount 1
    *set temp_indexcount + 1
    *if atd_index_count < temp_indexcount
        *return
    *set temp_dictindex (atd_index[temp_indexcount])
    *set temp_translatingword ({("atd_" & temp_dictindex) & ( "_" & temp_wordcount)})
    *goto translation_start

*set {temp_translatingword} {(("ad_") & (temp_translatingword & "_")) & (lsetting)}

*set temp_wordcount + 1

*set temp_translatingword {("atd_" & temp_dictindex) & ("_" & temp_wordcount)}

*if ((temp_indexcount <= atd_index_count))
    *goto translation_start
*else
    *return

atd stands for “array translation dictionary” and they are essentially a set of variable names for translating each of the terms.

*create_array atd_index 3 "cnames" "spclass" "geography"
*create_array atd_cnames 20 "Qing" "Hui" "Xiao" "Jiang" "Min" "Yong" "Yuan" "Wen" "Yuzu" "Fu" "Ru" "Bai" "Yan" "Jiaxian" "Ningyu" "Zhen" "Tang" "Daiyu" "Tao" "Yaoxing"
*create_array atd_spclass 16 "xiantian" "shen" "human" "Huangshi" "Guizu" "Shi" "Seng" "Yishi" "Xiucai" "Jinshi" "Huanguan" "Gongnu" "Nong" "Gong" "ShangP" "ShangM"
*create_array atd_geography 16 "ncity" "wcity" "scity" "ecity" "ccity" "mountainrange" "majordesert" "wsea" "esea" "iisles" "sbcountry" "wbcountry" "outertemple" "citytemple" "market" "rumansion" 
*create_array atd_miscellaneous 5 "lengthli" "lengthzhang" "lengthchi" "timeshi" "timeki"

I’m just not certain on how to get it to stop infinitely looping? Clearly I am missing whatever I need to close the loop?

Can I ask where translation_start label is? And if there is anywhere where you have a *goto translation_loop

2 Likes

It’s at the very top of the file.

4x

On the bright side, that fixed it! :blush:

[A secondary bright side, the actual loop/code wasn’t the issue, and considering this was my first attempt coding a loop I’m kind of happy of that fact that it was just me inputting the wrong goto. :skull: ]

2 Likes

Hey, that’s amazing! :partying_face:

1 Like

Honestly, it is still entirely thanks to the thread I made before on how to pull variables from a string that I was able to even start learning how loops work so I am thankful to you still for your contribution!

CattoBlush

4 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.