Custom Random Block

Started by BittleLit on Tue, 12/28/2021 - 09:59

Topic category: Feature requests and ideas for MCreator

Last seen on 11:19, 30. Apr 2022
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Custom Random Block
Tue, 12/28/2021 - 09:59

Hello, i came here with an idea for a "Custom Random" block:

Random between: (number slot) And: (number slot) Rounding: (logic [true/false] slot)

 

 

 

 

Random between: (number slot) And: (number slot) Rounding: (logic [true/false] slot)

For example: between 5 and 10 would get you random number in between them, for example 7.

Rounding would control whether the number generated could or couldn't have a "decimal place" (0.21 for example). Here's how it would be able to generate:

With rounding:

Math.floor(Math.random(num1,num2))

Or something like that, since it causes compilation errors.

Without rounding:

(Math.random(num1,num2))

Should work like that. I can make compilation code in Java.

Last seen on 11:19, 30. Apr 2022
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Here's the Java compiler…
Tue, 12/28/2021 - 10:09

Here's the Java compiler code:

Java code

(Not really compiler code, but a way it could work.)

Last seen on 11:19, 30. Apr 2022
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Rounding, num1 and num2…
Tue, 12/28/2021 - 10:21

Rounding, num1 and num2 would be fetched from the procedure block for this, and also it alredy exists in Tinkercad when coding serial microcontrollers such as Arduino Uno R3:

Code

(C++ code)