#(cyrulean) updating flag value runs into race conditions, unless using a server flag

93 messages · Page 1 of 1 (latest)

burnt kettle
#

This is a script that uses a recursive function to emulate a "virus" that spreads through wool and eats it up, with a maximum of like 20 blocks

https://paste.denizenscript.com/View/111023

it works flawlessly, the only issue I have is that it requires a server flag for the appetite to function correctly, when attempting to anything else at all to flag, it causes race conditions, where one block will modify the appetite from 14 to 13, and at the same time another block will also do that, and so when debugging the appetite value over time, it will read 13 twice, meaning the spores are eating one extra block than they should.

This happens every cycle, so having a string of wool, and starting the spore at the center will essentially double it's appetite.

coral zephyrBOT
#

(cyrulean) updating flag value runs into race conditions, unless using a server flag

coral zephyrBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

burnt kettle
#

bump

unreal sleet
burnt kettle
#

it's supposed to spread block by block

#

if I make a U-shape of wool it starts from 1 end and curves around

#

it shouldn't just do it based on proximity

unreal sleet
#

!t flood_fill

analog cradleBOT
# unreal sleet !t flood_fill
Cannot Specify Searched Tag

Multiple possible tags: <LocationTag.flood_fill[<limit>]>, <LocationTag.flood_fill[<limit>].types[<matcher>]>.

unreal sleet
#

!t flood_fill.types

analog cradleBOT
# unreal sleet !t flood_fill.types

Returns the set of all blocks, starting at the given location,
that can be directly reached in a way that only travels through blocks that match the given LocationTag matcher.
This will not travel diagonally, only the 6 cardinal directions (N/E/S/W/Up/Down).
As this is potentially infinite for some block types (like air, stone, etc.) should there be any opening however small, a limit must be given.
The limit value can be: a CuboidTag, an EllipsoidTag, or an ElementTag(Decimal) to use as a radius...

Group

world

Returns

ListTag(LocationTag)

final spadeBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@burnt kettle

burnt kettle
# unreal sleet !t flood_fill

if I use the spores on a center block, the 2 blocks on either side of it will spread and dissapear at the same time, and then the 2 blocks next to those 2 ticks later

#

how would I use flood_fill here to have this work?, as it returns a 1-dimensional list

burnt kettle
#

it's not even ordered

ancient wedge
#

it is ordered

burnt kettle
# ancient wedge foreach loop

the 2 blocks on either side of it will spread and dissapear at the same time
when I say it's a 1-dimensional list i mean the return value has no understanding of 2 blocks equal distance from each other

#

i know how to use a basic progamming concept that is not my issue here

ancient wedge
#

so I'm not sure what the issue is then

#

do you want to modify 2 blocks at the same time?

burnt kettle
#

This is a script that uses a recursive function to emulate a "virus" that spreads through wool and eats it up, with a maximum of like 20 blocks

burnt kettle
ancient wedge
#

create sublists

#

then loop through that

#

!t list.sublists

analog cradleBOT
#
Possible Confusion

Did you mean to search for listtag.sub_lists?

analog cradleBOT
burnt kettle
#

how does this solve my issue??

#

i don't want to sound rude but did you read my original message?

#

maybe i can send a video demonstration of what i'm trying to do, that might help you

ancient wedge
#

Ye

burnt kettle
#

dunno how im going to be able to send it in a discord tho

ancient wedge
#

upload it on youtube or some other service?

#

could also record a gif it it's short enough

burnt kettle
#

notice how when it branches off, the blocks dissapear at the same time

#

because the recursive function is called for every block it spreads to during the same frame

burnt kettle
#

@ancient wedge btw ^

ancient wedge
#

Iiii think I understood the issue now

#

can you post your items script you're using here <script[items].parsed_key[it_wool_spores.appetite]>

#

what you want is a definition instead of a server flag which you can toss to the ev_burn_wool task via def. argument

#

you can modify it later via define

#

!c define

analog cradleBOT
# ancient wedge !c define
Group

queue

Syntax

define [<id>](:<action>)[:<value>]

Short Description

Creates a temporary variable inside a script queue.

Description

Definitions are queue-level 'variables' that can be used throughout a script, once defined, by using the <[<id>]> tag.
Definitions are only valid on the current queue and are not transferred to any new queues constructed within the script,
such as by a 'run' command, without explicitly specifying to do so.

Definitions are lighter and faster than creating a temporary flag.
Definitions are also automatically removed when the queue is completed, so there is no worry for leaving unused data hanging...

ancient wedge
#

ie:
- run ev_burn_wool def.location:<context.location> def.wool_spore_appetite:<script[items].parsed_key[it_wool_spores.appetite]>

so you can use
define appetite:-- in your task, to substract 1

burnt kettle
#

I can't use a definition because multiple cues will be modifying the appetite variable at the same frame

#

That's why I'm using a server flag right now but it's a little too global

#

remember it's a recursive function so even if I subtract 1 from the appetite each time the for each runs, That's still two more cues that each have their own individual appetite variable

ancient wedge
#

I can only see two relevant queues here,

the queue of your event and the one of your task script

if your task script is ran by run command it creates a new queue, so - determine cancelled will absolutely have zero effect of the outcome of your event

#

so either I'm missing something or you haven't posted the full script

#

where are the other script that tinker with the wool_spore_appetite flag?

#

oo

ancient wedge
#

so definitions will work

#

or alternatively use inject instead of run so the queue and all definitions keeps the same

#
      - if <server.flag[wool_spore_appetite].is_more_than[0]>:
        - flag server wool_spore_appetite:<server.flag[wool_spore_appetite].sub[1]>
        - run ev_burn_wool def:<[spread_location]>

here ^

#

!c inject

analog cradleBOT
# ancient wedge !c inject
Group

queue

Syntax

inject [<script>] (path:<name>) (instantly)

Short Description

Runs a script in the current queue.

Description

Injects a script into the current queue.
This means this task will run with all of the original queue's definitions and tags.
It will also now be part of the queue, so any delays or definitions used in the injected script will be accessible in the original queue.

burnt kettle
burnt kettle
ancient wedge
#

@burnt kettle could you provide a debug of your script please

#

!debug

analog cradleBOT
# ancient wedge !debug
Info: debug

If you need help with a script issue, one of the most powerful tools Denizen has to offer is full debug output. This is displaying in your console whenever scripts are running until you turn debug off. To share a debug log quickly and easily with helpers, simply run the command /denizen debug -r in-game to begin recording, then run through the part of the script you need help with, then run the command /denizen submit. This will give you a link to a paste of the debug log, which you can then copy/paste back to us!

burnt kettle
#

it's up above

burnt kettle
#

oh debug

#

why do u need it again ?

ancient wedge
burnt kettle
#

ignore all the per-second scoreboard tasks

burnt kettle
#

@ancient wedge

ancient wedge
#

!rule 3 @burnt kettle

analog cradleBOT
# ancient wedge !rule 3 <@610139623196459019>
Rule 3

Don't ping for help. https://denizenscript.com/discord_rules#rule3
"Pinging" refers to using an @ to alert somebody to your post.
Generally only ping somebody if your message is very specifically directed at them (meaning, only that person has anything to do with the information in your message, and it would be confusing who it was for without the ping).

If you're asking a question, please just make a forum post and ask.
If you have a bug report or a feature request, please just make a forum post about it.

If this is pulled up for you by a helper, your ping was unneeded.
If you're arguing about it, you're wrong.

ancient wedge
#

I'm aware that you're currently waiting for an answer, but I barely have time at the moment

burnt kettle
#

ah apologies

steady vale
#

Had a look at this and here's my suggestions:

  • Easiest solution is to add a waitable ~ to your run command as a simple fix for the race condition.
  • Don't use recursive and make it a proper loop as was suggested. You can look at a "spreading" script I've made as inspiration:
    https://paste.denizenscript.com/View/113001
burnt kettle
#

oops i already fixed this a while ago

  1. basically take a list with 1 starting location
  2. create a new list that contains each of the blocks around each of the locations in the list
  3. run the burn_wool script
  4. loop at step 2 with this new list
deep craneBOT
final spadeBOT
#
Resolved

Thread closed as resolved.

burnt kettle
#

also your script doesn't even solve my issue lol,
which is that i need a global server flag for a local item state, which.. is the entire reason i am moving away from recursion in the first place

final spadeBOT
#
Thread Reopened

Thread was manually reopened by @burnt kettle.