Unending loop
Laifsyn opened this issue ยท 3 comments
Issue description
val Textmyarray = [ "torch", "coal"] as string[];
for index in 0 .. Textmyarray.length {
craftingTable.removeByName(Textmyarray[index]);
craftingTable.addShapeless("test_" + Textmyarray[index] ,<item:minecraft:${Textmyarray[index]}>,[<item:minecraft:dirt>, <item:minecraft:torch>]);
continue;
}
Steps to reproduce
No response
Script used
The crafttweaker.log file
Minecraft version
1.18
Modloader
Fabric
Modloader version
0.14.7
CraftTweaker version
9.1.153
Other relevant information
No response
The latest.log file
Will be tracked here:
ZenCodeLang/ZenCode#99
It seems any usage of continue
will lead to this, not sure why you are using it here though, it is the end of the loop, so it would do nothing anyway.
Your code should look like:
val Textmyarray = [ "torch", "coal"] as string[];
for index in 0 .. Textmyarray.length {
craftingTable.removeByName(Textmyarray[index]);
craftingTable.addShapeless("test_" + Textmyarray[index] ,<item:minecraft:${Textmyarray[index]}>,[<item:minecraft:dirt>, <item:minecraft:torch>]);
}
Actually, it could even look like:
val Textmyarray = ["torch", "coal"] as string[];
for text in Textmyarray {
craftingTable.removeByName(text);
craftingTable.addShapeless("test_" + text, <item:minecraft:${text}>, [<item:minecraft:dirt>, <item:minecraft:torch>]);
}
About that, I was kinda lazy to comment out the unneeded second half of the loop, so I just threw a continue;
there to simulate commenting that out
Ah in that case you could do
val Textmyarray = ["torch", "coal"] as string[];
for text in Textmyarray {
craftingTable.removeByName(text);
craftingTable.addShapeless("test_" + text, <item:minecraft:${text}>, [<item:minecraft:dirt>, <item:minecraft:torch>]);
if false {
// other code here
}
}
if false
will never pass so the code will never run