Started by
helioorigin
on
Topic category: Help with MCreator software
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
Use NBT tags for block specific variables.
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 session global variable at the time of opening the GUI, this was explained before on these forums.
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
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.