GUI Procedure Random Item in Slot

Started by ATrain4 on

Topic category: Help with MCreator software

Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
GUI Procedure Random Item in Slot

I am making a shop's GUI in MCreator. Though this one is unique, I am using procedures to check that there is enough money then adding a random item to collect. I have made sure abut the money pare, but I need help in the randomization part.

My code is;

If get items from slot 0 of the currently opened GUI of Event/target entity = money:

          If get number of items from slot 0 of the currently opened GUI of Event/target entity < 24:

                    set 1 {help here with random item (needs to be item block)} in slot 1 of the currently opened GUI of Event/target entity

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make a number variable. Name…
Sun, 04/10/2022 - 11:29

Make a number variable. Name it "Random".

Then, delete the last line from your code, and put this instead:

 

{Set Local:Random to: [[Random (0,1)] * [10]]}

If [[Get Local:Random] = [0]]

do {Set 1 [<Your firs item>] in slot 0 of the currently opened GUI of Event/target entity}

 

Put the last if there 10 times, each with a different item. It will pick one random from 10 different items and put it in the slot.

I hope this was helpful!