This doesn't work anymore

How, what and why to code in BYOND.
Post Reply
User avatar
Aranclanos
Joined: Tue Apr 15, 2014 4:55 pm
Byond Username: Aranclanos

This doesn't work anymore

Post by Aranclanos » #40299

Code: Select all

/mob/verb/stuff()
	var/list/L = list()
	var/obj/O = new(src)
	L += O
	for(var/obj/P in L)
		var/obj/N = new(src)
		L += N
Basically, this chunk of code would make the for loop continue because of new additions (and create an infinite loop, but it's not important). Apparently this doesn't work anymore, the new additions to the list won't be part of the loop.
Dunno if this is a bug or not, I'll forward it to the byond forums but I guess I should make this thread, because I'm sure we use this thing in several places of the code, those are bugged now. (I think Linda uses it, might be wrong).
I did't test making the list somewhere else.
I accept donations, click here
User avatar
Aranclanos
Joined: Tue Apr 15, 2014 4:55 pm
Byond Username: Aranclanos

Re: This doesn't work anymore

Post by Aranclanos » #40305

I accept donations, click here
User avatar
Spacemanspark
Joined: Thu Apr 17, 2014 7:45 pm
Byond Username: Spacemanspark
Location: Paradise

Re: This doesn't work anymore

Post by Spacemanspark » #40525

This is why you don't use Byond forums for anything.
:^)
Miauw
Joined: Sat Apr 19, 2014 11:23 am
Byond Username: Miauw62

Re: This doesn't work anymore

Post by Miauw » #40594

wait then how does the recursive hear check work
<wb> For one, the spaghetti is killing me. It's everywhere in food code, and makes it harder to clean those up.
<Tobba> I stared into BYOND and it farted
User avatar
Remie Richards
Joined: Thu Apr 17, 2014 7:11 pm
Byond Username: CrimsonVision
Location: England, UK, Earth, Sol, Milky Way, Local Group, Virgo Supercluster, Known Universe
Contact:

Re: This doesn't work anymore

Post by Remie Richards » #40598

Miauw wrote:wait then how does the recursive hear check work

Code: Select all

/proc/recursive_hear_check(var/atom/O)
	var/list/processing_list = list(O)
	var/list/processed_list = list()
	var/list/found_atoms = list()

	while(processing_list.len)
		var/atom/A = processing_list[1]

		if(A.flags & HEAR)
			found_atoms |= A

		for(var/atom/B in A)
			if(!processed_list[B])
				processing_list |= B

		processing_list.Cut(1, 2)
		processed_list[A] = A

	return found_atoms
The only "for In" happening here is with a different list.
私は完璧
User avatar
oranges
Code Maintainer
Joined: Tue Apr 15, 2014 9:16 pm
Byond Username: Optimumtact
Github Username: optimumtact
Location: #CHATSHITGETBANGED

Re: This doesn't work anymore

Post by oranges » #40787

I told you it couldn't work
Miauw
Joined: Sat Apr 19, 2014 11:23 am
Byond Username: Miauw62

Re: This doesn't work anymore

Post by Miauw » #41143

Remie Richards wrote:
Miauw wrote:wait then how does the recursive hear check work

Code: Select all

/proc/recursive_hear_check(var/atom/O)
	var/list/processing_list = list(O)
	var/list/processed_list = list()
	var/list/found_atoms = list()

	while(processing_list.len)
		var/atom/A = processing_list[1]

		if(A.flags & HEAR)
			found_atoms |= A

		for(var/atom/B in A)
			if(!processed_list[B])
				processing_list |= B

		processing_list.Cut(1, 2)
		processed_list[A] = A

	return found_atoms
The only "for In" happening here is with a different list.
oh right it uses while(len)
<wb> For one, the spaghetti is killing me. It's everywhere in food code, and makes it harder to clean those up.
<Tobba> I stared into BYOND and it farted
Post Reply

Who is online

Users browsing this forum: No registered users