Substring custom variable parameters don't work

Published by DaanMC on Wed, 02/13/2019 - 01:17
Issue description

Basically MCreator automatically makes custom variables a double, and that causes an error to happen when it is used as a 'from' or 'to' parameter in a substring block, as that block only accepts int's as parameters (makes sense). After a bit of research I have found a solution for this problem but it requires editing the code and therefore locking the element in the workspace, which can be quite frustrating if you're troubleshooting the procedure and constantly have to change the code again to remove overwritten pieces.

It would be nice if this gets fixed in a future update, it's a bug after all...

But anyways, here's the solution:

You want to go into the custom code of your element, having locked it, and change this:

CustomString.substring(CustomVariable, CustomVariable)

into this:

CustomString.substring((int)CustomVariable, (int)Customvariable)

forcing minecraft to read your variable as an int there instead of a double.

Issue comments

I can confirm that we have forgotten to add typecast. We will fix this bug in the next update.

Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.