CraftTweaker

CraftTweaker

151M Downloads

For loop script problems

drago87 opened this issue ยท 2 comments

commented

Issue Description:
Trying to iterate a String array with material names and add each ore in a Modular Machine to make makansim clumps

have disable all but iron in the array and the disabled in the for loop is the expected input/output

What happens:

Get an error that it cant cast the string to a IOreDict

What you expected to happen:

recipes being added

Script used (Please Pastebin or gist your script, posting an unpasted or ungist'd script will automatically close this issue):

https://pastebin.com/KhmHVbzd

crafttweaker.log file (Please Pastebin or gist your file, posting an unpasted or ungist'd file will automatically close this issue):

crafttweaker.log


Affected Versions (Do not use "latest"):

  • Minecraft: 1.12.2
  • Forge: 14.23.5.2847
  • Crafttweaker: CraftTweaker2-1.12-4.1.19
  • Mekanism: 9.8.2.389
  • mekores: 2.0.12 (needed for full script)
  • Modular Machinery: 1.11.1
  • Using a server: No

Your most recent log file where the issue was present:

https://pastebin.com/r7r5AR93

commented

Do not upload your CrT log directly, please.

Okay, first of all, there's a huge differenve between "<ore:ingotIron>" and <ore:ingotIron>
One of them is a string. A String is a list of characters, so the GT char, then the o char, then the r char etc.

Second one is a Bracket Expression.
A bracket expression is a call to a Java Method and returns a type, in this case an IOreDictEntry object.
You can't directly cast from one to the other.

You can however create an IOreDictEntry object using the oreDict keyword:

val ironOreDict1 = <ore:ingotIron>;
val ironOreDict2 = oreDict["ingotIron"];

They do essentially the same.
So use latter if you need to dynamically build a string.
There's no way to use variables inside a Bracket handler (at least not in 1.12, in 1.14 there also is none... yet)

commented

that worked. would be nice if there was an exaple on the wiki