#copying array in nodeJS

33 messages · Page 1 of 1 (latest)

finite harbor
#

arrows = [ ...arrowsBuf ]

#

You can do like this.

#

..

slim orchid
#

ill try that rn

#

i dont think it worked

finite harbor
#

Haha. why?
It's correct.
For example.
const arrowsBuf = [1,2,3,4,5,6,7]
const arrows = [ ...arrowsBuf ]
arrows.pop()
console.log(arrowsBuf, arrows)

output
[1,2,3,4,5,6,7]
[1,2,3,4,5,6]

slim orchid
#

ok i redid the test a little diffrently and it seems to work now, but i still have a prob not in this question though

#

how do i close the question?

finite harbor
#

Hm... I don't know.

#

If you have other questions. ask me.

slim orchid
#

alr but it is way more complex than what i just asked

#

how do i send a snippet?

finite harbor
#

screenshot

slim orchid
#

it wont fit

#

ill send it in partions

finite harbor
#

ok

slim orchid
#

so what i just send is a function that tries to use a simple algorithm to pathfind in minecraft using mineflayer

finite harbor
#

This is BFS algorithm?

slim orchid
#

its supposte to spawn arrow blocks around the target outward

#

if theres a block dont spawn

#

idk the name of the algorithm

#

the target is gold and this is the first iteration

finite harbor
#

What is the error here?

slim orchid
#

well when iteration number 2 happens, instead of growing by 1 block it grows in +x and +z like this:

#

and also i had to manually put the gold block because it also gets replaced for some reason

finite harbor
#

Only these button have to show?

slim orchid
#

no, thats the second iteration so 1 more block outward, since the program doesnt work ill try to show aproximently how it should look

finite harbor
#

Hm... I don't know what is what only see this.

slim orchid
#

should i add comments to the code?

slim orchid
#

"close

#

!close

#

.close