Mirreski / Skript

Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
http://njol.ch/projects/skript
7 stars 2 forks source link

Very long lasting and nasty loop bug #34

Open Pilvinen opened 9 years ago

Pilvinen commented 9 years ago

I don't know the exact circumstances where this bug always happens but I will try my best to explain it as I see it.

When you have several nested loops - sometimes "exit x sections" or "exit x loops" does not exit the code sections properly and as a result the code does strange things.

Like for example I have this code for a moving reactor which uses entities, arrows, to track it's movement and to update the block-location based variables. The code should run flawlessly but instead I have - I think - the last reactor on the reactor list which is suddenly spawning new entity trackers every 0.1 seconds. I break the reactor and another one starts exhibiting this same behaviour.

Finally afters hours of debugging I come to the conclusion that this is - again - the Skript issue which sometimes makes "exit section" bug out with nested loops. So instead of using exit section I use variables to stop the code - and sure enough, the code runs as it should.

I'm not able to provide a code that can reproduce this issue as I'm not 100% sure of the circumstances it requires. But. I have a code snippet here of the loops that caused it to happen. I cannot post the whole code because it's almost 3000 lines long, but this should be the relevant part:

This is the snipped from the code that experiences the bug: http://pastebin.com/LLfnAShM

This is the same code that has worked around the bug by using variables (for comparison): http://pastebin.com/Bsz8DPqC

This bug has been present in Skript for a long time and it would be really super cool to get it finally nailed down and fixed.

If this example is not enough for you to track it then please ask for more information and I will try to answer your questions as best as I can.

Mirreski commented 9 years ago

I will be attempting to reproduce the problem and see internally what happens.

I am working on RandomSK this week/until I have released a version so this will be tested later. If I have any questions when I do this I will be replying here or on bukkit:)

Pilvinen commented 9 years ago

This works: http://pastebin.com/MSaFDuz9

This doesn't work: http://pastebin.com/faX32ARt

To test make a chest, put in the chest: 64 dirt 64 cobble 64 grass 64 iron ingots

Take a stick and right click the chest once.

The relevant part which bugs out is at the end of the code, the last part.

I tried "exit 1 sections" and "exit 1 loops" and they both fail in similiar manner.

What SHOULD happen is:

Every time you right click the chest once with the stick it removes 6 from each category, ie. "dirt/grass", "cobble/stone", "ironingots/iron blocks".

To clarify: It should not take 6 grass + 6 dirt. It will just take 6 from either dirt or grass or like 3 dirt and 3 grass.

What happens with the loop bug is that you get totally random strange and unpredictable amounts of items removed from the chest.

Sorry about the messy code. I was testing something and this bug creeped up again.

Mirreski commented 9 years ago

Thanks for the examples. When I start working on Skript Fixes again I will start with this and see if I can find the problem.

(Currently I am working on a side project of mine and learning JavaFX)