Array/table support in procedures

Upvotes: 5
Issue description

Add Arrays Under Logic and Loops

for a mod i am making i want to create a light dimmer and a array would work well for this instead of a bunch of else if or for statements. the array should have the option to choose the number of rows and column's for values and procedures to be used inside of

a good piece of a example mock up pseudo code procedure that would use this would be

Custom Variable Power Level = 7

Array named "Power Level" tied to "Custom Variable Power Level" with two rows and columns named [1],[2] and [A],[B]) 
{
Custom Variable Power Level [1] = Set Provided Blocks Light Value to 1
Custom Variable Power Level [2] = Set Provided Blocks Light Value to 2
Custom Variable Power Level [3] = Set Provided Blocks Light Value to 3
Custom Variable Power Level [4] = Set Provided Blocks Light Value to 4
Custom Variable Power Level [5] = Set Provided Blocks Light Value to 5
Custom Variable Power Level [6] = Set Provided Blocks Light Value to 6
Custom Variable Power Level [7] = Set Provided Blocks Light Value to 7
Custom Variable Power Level [8] = Set Provided Blocks Light Value to 8
Custom Variable Power Level [9] = Set Provided Blocks Light Value to 9
Custom Variable Power Level [10] = Set Provided Blocks Light Value to 10
Custom Variable Power Level [11] = Set Provided Blocks Light Value to 11
Custom Variable Power Level [12] = Set Provided Blocks Light Value to 12
Custom Variable Power Level [13] = Set Provided Blocks Light Value to 13
Custom Variable Power Level [14] = Set Provided Blocks Light Value to 14
Custom Variable Power Level [15] = Set Provided Blocks Light Value to 15
}
If ((Get Custom Variable Power Level) = (Array "Power Level")) / Picks the Current Power Value and what it's tied to from the array
Else 
Set Provided Blocks Light Value to 0

// Upon execution this should pull the current set Power Level of 7 from the defined values in the array which can be between 0 and 15 and then Set the Provided Blocks Light Value to 7 based upon Power Level 7 = Light Value 7.

Some things that should be added to arrays are a Goto procedure that if put in the array somewhere tells the interpreter to goto the defined row and column in the array for the goto procedure in the array. a pseudo example of goto would be if goto [5,B] was placed in the array at [2,B] or Set Provided Light Value to 2 it would goto [5,B] or set provided light value to 5 if Power level was set to 2.

Issue comments

Goto is a bad practice in programming so this definitely won't be added. Java doesn't even have real goto support.

For arrays, this is a nice idea. We will consider adding array support in the future.

Yes we need this! Glad to see that this didn't exist anywhere else.



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.