List Variables and unified variable types

Published by aidanete on
Status
Duplicate
Issue description

I'm basing this on the AppInventor online software, which has a coding system a lot similar to the MCreator's procedure system.

I would like to have list variables in MCreator. Allowing you to add multiple values to the same variable, most languages allow this. I don't know why MCreator doesn't. Also, I think we need unified variable types. That instead of having float/integer, string and boolean variable types. We have the same variable system allowing to add any type of value to it and the program should transform it, even we could put blocks and items as values in variables.

Here some images of the app inventor list variables etc.

(Sorry to add two suggestions on the same ticket, but I think it's annoying to wait more than 24 hours to create two tickets about very similar things.)

Issue comments

We already plan to support arrays/lists: https://mcreator.net/tracker/issue/48235

For unified variable type, this is not how Java works. If we wanted to add support for this, generated code would become a huge mess. We already simplified things a bit with one numeric type only and this is causing issues already with unnoticed casting from decimal to numerical values.

Hmmmn... Will be a way to put a block/item as value onto a variable?

I think AppInventor it's also java, but Idk.

Anyways, good to see lists are planned.

As I said, it can be done, but the code is a mess and MCreator would loose its transparency in the code this way.

There is a ticket for items/blocks as variables, check the issue tracker.

Ok, I have an idea that maybe will work for item/block as variables. I don't know if putting it here is a good idea or will be better to create a new ticket, but I have still 40 hours to wait so, the idea is a procedure block that returns a string with the ID of an item or block like this :

"Set (string var block_filter) to (return id of the block at x, y, z)" or something like that.

Then, another that converts the string id into itemstack, like this:

"Place (block with id (var block_filter)) at x, y, z."

Might this be easier and possible or I'm wrong?

I was going to open up a new tick however this post is relatively still active so I will post the suggestion here to keep it in the same place.

Could we also have player variables, variables that we can assign to a player like numbers, strings, and booleans so that we can build more advanced things like adding currency to each player rather than global economy? Also, this would be handly for living entities as well if we could have variables for them too. I am sure other people can find more uses for player and entity variables down the line of development as well as it being a useful tool for more advanced mod creations.