Command variables

Started by GamesFrog on

Topic category: Help with modding (Java Edition)

Last seen on 14:14, 1. Nov 2023
Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Command variables

How do you add variables to commands. If you want a command like /sphere stone 5 (which will create a sphere out of stone with the radius 5) but the command should also work like /sphere stone 9 (which should create a sphere out of stone with the radius 9) so that the number is a variable and can be changed in the command. How do you do that?

Last seen on 14:30, 2. Aug 2022
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use the block command…
Wed, 04/21/2021 - 11:17

Use the block command parameter with index (0) from the advanced tab. It will give you the 1st, 2nd, 3rd, etc. 'variable' of a command, where the index starts at 0. For example, if I have a customsay command setup like this:

https://drive.google.com/file/d/1lqW9KZQAidj0MRhpj58vR09goZ7O8tv2/view?…

then I can make a procedure like this:

https://drive.google.com/file/d/1nmJjnAckWPkvFWGXa7L_3bKptYnd2K7m/view?…

that will send a chat message containing the first thing I add to the command, as you can see in this screenshot:

https://drive.google.com/file/d/11hRPjTAUaViowajFPUzpMafogKP3T0uU/view?…

Two things to note: I don't think there is a way to make the command prompt the user for specific parameters; it will just say [<arguments>]. Also, it always gives the parameter as text, so to get a radius you'll have to use the number from text block from the math tab.