problem with local variable... doesnt increase number..

Started by mangamaniacs2064 on

Topic category: Help with MCreator software

Last seen on 14:53, 13. Mar 2022
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
problem with local variable... doesnt increase number..

here is the picture of what i did

https://serving.photos.photobox.com/32109569d6343994f7bb364b510ce9acfa0…

when i use a global variable it work.. the number seem to increase the variable.. but wheni put it with local variable it doesnt stop

the number burnspeed should be more than 0 so no more text and no more adding gold ingot...

why this doesnt work?

only local variable dont work

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
A local variable only exists…
Sun, 09/29/2019 - 09:10

A local variable only exists for the instance of that call. So this is what happens:

1. (behind the scene's: Local variable = Null so it is 0)

2. If local variable = 0 do. (which is true)

3. Set local variable to 1.

4. Procedure ends. Local variable gets cleared. Now gets called again:

5. (behind the scene's: Local variable = Null so it is 0)

6. If local variable = 0 do. (which is again true...) etc.

----------------------------

So obviously, you want a local variable that exists for the duration the block/entity/item exists and persists between procedure calls.

This variable you're looking for is called an NBT tag. Either a LOGIC nbt tag (which is true/false) or a number nbt tag.

If you use a block and want to use an NBT tag, make sure to enable inventory as that also allows you to store NBT data (which is basically the local variable you were searching for)

Last seen on 14:53, 13. Mar 2022
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
what i want to do is a…
Sun, 09/29/2019 - 15:05

what i want to do is a furnace that takes 5 seconds before giving gold...

just that... after ive done that i will add more recipe etc.. but for testing.. just giving gold ingot after 5 seconds

i thought i would use a local variable to increase by 1 each tick.. but doesnt work 

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The local variable does work…
Sun, 09/29/2019 - 16:58

The local variable does work. It increases every tick. However it increases from 0 to 1 every tick. That's because local variables only exist until the procedure ends. At the end the value is (null/) 0 again.

What you mean/need by local variable is called number NBT tag in mcreator. Don't use a local variable. Use a number NBT tag.

Last seen on 14:53, 13. Mar 2022
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
can you give me an…
Sun, 09/29/2019 - 17:27

can you give me an examplehow to use nbt tag...

for example the number must start from 0 an every tick  go +1

when reach 10 do somethings... like add gold ingot or anything

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if Get NBT number tag …
Sun, 09/29/2019 - 18:45
if Get NBT number tag "Counter" of block at xyz if it has tile entity < 10

do Set NBT number tag "Counter" of block at xyz if it has tile entity to Get NBT number tag "Counter"  of block at xyz if it has tile entity + 1 (Basically adding 1 to itself)

else

"like add gold ingot or anything"

Set NBT number tag "Counter" to 0 (Optional: only if you want to keep it going)

https://ibb.co/fXHL4vk

Can be found in Block Procedures when scrolling down. Do note that when adding a "local variable" (nbt tag) to a block, it needs to have inventory enabled. Set inventory to 0 if you don't want to block to have any slots.

Last seen on 14:53, 13. Mar 2022
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
thanks a lot... it worked…
Sun, 09/29/2019 - 19:26

thanks a lot... it worked..

you see i am making a dirt furnace that works with hot_dirt block..