Global Variables reset after each test client

Started by Kylebutter123 on Thu, 08/08/2019 - 20:18

Topic category: Help with MCreator modding

Last seen on 15:11, 7. Sep 2019
Joined Dec 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Global Variables reset after each test client
Fri, 08/09/2019 - 17:56 (edited)

I think i wrote the NBT read and write code correctly so the variable saves when i save and quit the world and rejoin..

But if i close the client and reopen it it resets the variable entirely. I saw that the code was resetting the variable back to 0 each time but i have no idea how to remove that. 

Any help with this problem now?

Edited by Kylebutter123 on Fri, 08/09/2019 - 17:56
Last seen on 18:50, 23. Sep 2019
Joined Apr 2010
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
  • developer
This happens because you are…
Fri, 08/09/2019 - 09:37

This happens because you are using GLOBAL_SESSION which is only persistent per session.

Last seen on 15:11, 7. Sep 2019
Joined Dec 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
I tried using the other…
Fri, 08/09/2019 - 17:53

I tried using the other variable scopes but now it doesnt save at all when i exit and rejoin my world.

 

Last seen on 18:50, 23. Sep 2019
Joined Apr 2010
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
  • developer
Which procedure trigger do…
Sat, 08/10/2019 - 07:23

Which procedure trigger do you use to set the values of these variables?

Last seen on 15:11, 7. Sep 2019
Joined Dec 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
On block right click which…
Sat, 08/10/2019 - 15:29

On block right click which adds 1 to the variable each time i right click the block

 

Last seen on 18:50, 23. Sep 2019
Joined Apr 2010
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
  • developer
Where do you read the value…
Sat, 08/10/2019 - 16:21

Where do you read the value of this variable after you set it? By where, I mean how is the procedure which reads this value triggered?

Last seen on 15:11, 7. Sep 2019
Joined Dec 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
i have a gui that also opens…
Sun, 08/11/2019 - 01:10

i have a gui that also opens when I right click the block which helps me track how much i right clicked the block.

Last seen on 18:50, 23. Sep 2019
Joined Apr 2010
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
  • developer
And you show the value in…
Sun, 08/11/2019 - 09:29

And you show the value in GUI label or where?

Last seen on 15:11, 7. Sep 2019
Joined Dec 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
i show to value of the…
Sun, 08/11/2019 - 17:54

i show to value of the variaible on the top of the gui

Last seen on 18:50, 23. Sep 2019
Joined Apr 2010
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
  • developer
GUI works on the client side…
Mon, 08/12/2019 - 05:26

GUI works on the client side, while global map and world variables work on server side. I will make a wiki page explaining this soon. What you need to do is set global map/world variable in the procedure like you do now, but then copy the value of global map variable by getting its value and set global session variable to its value. Global session variables work on the client side too and can be then used in GUIs for display.

Last seen on 15:11, 7. Sep 2019
Joined Dec 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
This worked extremely well!…
Mon, 08/12/2019 - 15:08

This worked extremely well! Thanks Klemen