create variables based on the block

Started by helioorigin on

Topic category: Help with MCreator software

Joined Dec 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
create variables based on the block
Mon, 12/02/2019 - 22:41 (edited)

 

Hello, I'm creating my own mod (which is pretty obvious since I'm on this forum, but ok),
and I should create a variable for every block I place (Example. I have a block called
compressor and inside it has a variable that counts the item inside it, I used a global variable since
I had to connect it to the GUI, but so, having only one variable, all the compressor sees only 1 item) to avoid
this I should create a global variable for each placed compressor, so I should create it in the 'When block added
event but I don't know how to create a variable through procedures (block diagram, not code)

Thanks in advance

sorry for english

Edited by helioorigin on Mon, 12/02/2019 - 22:41
Joined Dec 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
  thanks, now we have found…
Tue, 12/03/2019 - 19:03

 

thanks, now we have found another problem, I should take the value inserted in the NBT in the block and display it in a label in the connected gui, but I cannot use global variables because the problem preceding this would be found

You can pass them to the…
Tue, 12/03/2019 - 19:20

You can pass them to the session global variable at the time of opening the GUI, this was explained before on these forums.

Joined Dec 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I tried to do as you say but…
Tue, 12/03/2019 - 23:02

I tried to do as you say but now I have another problem, here I send photos and videos about

PHOTO OF PROCEDURE

https://imgur.com/mtSTDT1

https://imgur.com/XwYa35O

https://imgur.com/pNmZnup

VIDEO IN GAME

https://imgur.com/RRU0gIN

 

the "0.0" as soon as I insert an item it should increase to 1, and the writing in red remain cool the name of the item inserted in the block, but it conflicts with the other compressor

Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I haven't looked at all the…
Thu, 12/05/2019 - 10:35

I haven't looked at all the pictures, but this is what I think you should do:

The Block NBT tag is the variable you are looking for when it comes to each block saving their own data.

But since you're using GUI, you need a global variable. Since only 1 GUI is open at 1 time, you should use 1 global variable to display the variable and have that variable get it's information from the NBT tags. Since you're only using the global variable for the GUI, all behaviour in your block code should use NBT tags, and whenever the GUI is opened, the Global variable should get the value of the NBT tag from that block.