[TUTORIAL] Call prodecures with custom dependencies (no plugins needed!)

Started by RedWirePlatinum on

Topic category: User side tutorials

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] Call prodecures with custom dependencies (no plugins needed!)
Mon, 08/28/2023 - 18:59 (edited)

Ever wanted to call procedures with custom dependencies but don't know how? well now you can! Unlike my other post (https://mcreator.net/forum/97750/how-call-procedure-custom-variables-file-manager-plugin), custom values aren't just limited to strings, numbers, or booleans (json objects too if using File Manager plugin) and is more simple to follow!
Step 1: Create some kind of procedure you want custom dependencies on. As an example, this procedure will simply send a chat with the value of noomber

Step 2: in another procedure, create a local variable with the same name as the custom dependency added.
You're also going to want to add some extra procedure blocks just to define any extra dependencies you need (if it's not already showing under "Required Dependencies"). For example, I created a local a entity variable just to define the target entity. You can always manually add the dependencies by editing and locking procedure code, but this works as well.

Step 3: Use a custom code snippet and put the following code in:

  1. NameofProcedure.execute(insert dependencies here);

    NameofProcedure must be the exact name of the procedure you're executing, with "Procedure" added at the end. For example, since the procedure I made is named "Test", the custom code and dependencies are as such:

    TestProcedure.execute(entity, noomber);

Aaand.. you're done! Now, you can get more creative with procedures

P.S. when calling a procedure and getting the return value, use the other custom code snippet and remove the semicolon at the end

Edited by RedWirePlatinum on Mon, 08/28/2023 - 18:59
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Update: technically you don…
Tue, 08/29/2023 - 20:40

Update: technically you don't even need to do TestProcedure.execute(entity, noomber);, you could just do TestProcedure.execute(entity, 30); and it will automatically make 30 the value for noomber, but making local variables would still be easier i think

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Update 2: The dependencies…
Tue, 08/29/2023 - 22:18

Update 2: The dependencies provided in the custom code snippet also have to be in the exact order as the list of required dependencies show

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
^ nevermind i was wrong,, my…
Tue, 08/29/2023 - 22:22

^ nevermind i was wrong,, my bad

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(ACTUAL) Update 2: world…
Tue, 08/29/2023 - 22:38

(ACTUAL) Update 2: world always comes first (if required), x,y,z is defined right after. after that, the list of dependencies are exactly as the list of required dependencies go from up to down.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(procedure code for proof)
Tue, 08/29/2023 - 22:41

(procedure code for proof)

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
W tutorial, thanks for the…
Mon, 05/13/2024 - 13:17

W tutorial, thanks for the help Redwire

Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is great. Obviously…
Tue, 07/30/2024 - 09:56

This is great. Obviously still have to test it, but I'm currently still stuck on 2024.1 and this is a great way to write procedure parameters before their official addition.

Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Update: This works like a…
Tue, 07/30/2024 - 10:29

Update: This works like a charm. Many thanks!