Calling a variable procedure using custom code snippet

Started by CluelessWanderer on

Topic category: Help with modding (Java Edition)

Last seen on 02:15, 29. Apr 2024
Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Calling a variable procedure using custom code snippet

Is it possible to get the name of a procedure from a string variable and use it in a custom code snippet to call a the procedure specified by the variable?

Last seen on 06:31, 3. May 2024
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Not that I know of (at the…
Wed, 04/24/2024 - 23:31

Not that I know of (at the moment), no you cannot.

But you could set the variable to the name of the procedure by simply setting it to the name of the procedure (by actually typing out the procedure), and then using an if/elseif/else chain to recognize different values of the string and then calling different procedures. You could also use an integer variable to determine which procedure to call.

Last seen on 02:15, 29. Apr 2024
Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I appreciate the response,…
Thu, 04/25/2024 - 00:43

I appreciate the response, but that doesn't really work for what I was thinking of though. I'm working on making a card game, so my idea was I could create new procedures for new card effects and just have it get the name of the procedure from the card to do the effect. That way it's modular and I don't have to go in and add new stuff to the procedures to account for a new effect.

Last seen on 02:15, 29. Apr 2024
Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I suppose an if/elseif/else…
Thu, 04/25/2024 - 01:00

I suppose an if/elseif/else chain would be a good placeholder until a feature like that is added though. Thanks!

Last seen on 06:31, 3. May 2024
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, in your case it is a…
Fri, 04/26/2024 - 12:35

Yes, in your case it is a very inefficient way of calling procedures. I have a feeling (even though i can't code in text) that there would be a way to do it in text based format though.