[SOLVED] How to run a procedure upon first joining the world only?

Started by Constant Constantine on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED] How to run a procedure upon first joining the world only?
Mon, 07/10/2023 - 22:05 (edited)

Basically, I want a procedure to run only when the player joins the world for the first time.. (Meaning if they rejoin the same world, the procedure doesn't run again.)

For context, the mod I'm making lowers the player's max health to 1 point and only a certain item can increase their max health. This means I don't want their max health to be reset back to 1 point upon rejoining the world.

 

Post-solved edit: Fixed the wording of the first sentence. Original wording was confusing.

Edited by Constant Constantine on Mon, 07/10/2023 - 22:05
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
A basic idea untested idea,…
Thu, 06/22/2023 - 04:41

A basic idea untested idea, you can try using nbt tag to save a logic variable in a player. Then check it every time player joined. 

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I literally have no idea how…
Thu, 06/22/2023 - 04:46

I literally have no idea how to do that.

Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try creating a global "logic…
Thu, 06/29/2023 - 21:27

Try creating a global "logic" variable (scope: GLOBAL_MAP) that starts out as "false", and then have a procedure whose global trigger is "on player tick update". If the variable is false, reduce the player's max health and set the variable to true. This way, it only happens the first time the player joins.

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There is a procedure trigger…
Thu, 06/29/2023 - 21:57

There is a procedure trigger called "Player joins"

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@sillypantscoder Please show…
Fri, 06/30/2023 - 22:17

@sillypantscoder Please show me an example, because I don't quite understand what you mean. Because the procedure I made will just set the variable back to false every single tick and thus, make the procedure run again. Even if I set it to "Player Joins World," it will still set the variable back to false.

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I will create an example.
Thu, 07/06/2023 - 10:34

I will create an example.

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@SpyCoder77 Okay, please…
Thu, 07/06/2023 - 22:01

@SpyCoder77 Okay, please show me it as soon as you can.

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
once u go to create a…
Fri, 07/07/2023 - 15:07

once u go to create a procedure event trigger- that says no additional trigger change that to player joins world 

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@lavadabman Thanks, I…
Fri, 07/07/2023 - 22:18

@lavadabman Thanks, I plugged in the "player_join" variable as a player persistent variable into the procedure that Sillypantscoder suggested and then tweaked it to my liking. It works in the way I wanted it to, perfectly. Though I wasn't sure how to use the "player_heart" variable to change the player's max health, so I just had the procedure change it via /attribute. Nonetheless, I'm happy with how it works, now.

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@SpyCoder77 I really must…
Mon, 07/10/2023 - 22:08

@SpyCoder77 I really must apologize for failing to mention that I already had the trigger set to "player joins" beforehand. That being said, it takes more than just that trigger to make a procedure run only on the first time that a player joins the world, not every single time. You only suggested to change the trigger to "player joins" and didn't give me any information related to rest of what I wanted.

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if it's on a server, is it…
Sun, 08/27/2023 - 14:57

if it's on a server, is it possible to make it check if a certain player joined for the first time? because this will basically be "when a player joins for the first time, do something, then never run again even if its a different player"