ID:138879
 
Code:
obj
water
icon = 'test.dmi'
icon_state = "water"
New()
for(var/turf/a in view(2))
if(a.density == 0)
world << "lol"
new/obj/water(a.loc)
else
..()


Problem description:well this is probably me being dumb again but with this code i was thinking using
for(var/turf/a in view(1)

to find all the turfs near it and
if(a.density == 0)

to make sure the water dosnt go through anything solid
but it didnt work at all :/ so i made a click verb and when i clicked it it made all the water go to the bottom left corner

so can someone tell/show me what i did wrong?


new/obj/water(a.loc) is the issue.

Just use:

new/obj/water(a)

You don't add objects to a turf's loc, you add them to the turf.
In response to Robertbanks2
i tryed that and didnt work i just now noticed that whenever i click it to start the flood it spawns the water in my location
In response to Shwb1
Show me the code you use to spawn in the first water.
In response to Robertbanks2
i just put it in the map :o
and then when i click it the code starts
In response to Robertbanks2
i think it has to do with view()
In response to Shwb1
Have you already tried removing the else statement?
In response to Robertbanks2
yup
In response to Shwb1
Well, aside from the fact that you're causing an infinite loop, I don't see any other obvious errors in what is displayed.
In response to Shwb1
obj
water
icon = 'test.dmi'
icon_state = "water"
Click()
for(var/turf/ain view(2))
if(a.density == 0)
world << "lol"
new/obj/water(a)
else
..()
New()
for(var/turf/a in view(2))
if(a.density == 0)
world << "lol"
new/obj/water(a)
else
..()


this is my full water code atm
In response to Robertbanks2
i think im not selecting the turfs next to me right like first time i had

for(var/turf/a in view(2))

and it spawned a water on me everytime i clicked the water
then i had

for(var/turf/a)

and it spawned it on the bottom left corner of map
In response to Shwb1
Shwb1 wrote:
i think im not selecting the turfs next to me right like first time i had

for(var/turf/a in view(2))

and it spawned a water on me everytime i clicked the water
then i had

for(var/turf/a)

and it spawned it on the bottom left corner of map

i mean next to the water
In response to Robertbanks2
Robertbanks2 wrote:
<dm>
>Well, aside from the fact that you're causing an >infinite loop, I don't see any other obvious errors in what >is displayed.

</dm>
mind telling how i can fix this loop?
In response to Shwb1
You're creating new waters in view(2), but that creates a new water on the same location as the original, which then creates a new water on the same location, and so on and so forth. You can fix this by checking to see if there's a water already in a turf.
In response to Shwb1
New()
for(var/turf/a in view(9,src))
if(a.density == 0)
if(!(src in a))
world << "lol"
new/obj/water(a)
else
..()
else
..()



ok i got inf loop fixed but now the New() proc dosnt work :/

when the water spawns it goes straight diagnal down-left til a wall then goes down til it can go down-left again then at very bottom of map/where it cant go down-left or just down it goes right then stops after 1 block :/
In response to Shwb1
Shwb1 wrote:
>   for(var/turf/a in view(9,src))


Is it supposed to spread 9 tiles at a time?
In response to Shwb1
LOL, just figured out the problem. Southwest is the first tile checked by view(), so you're creating a new one, activating THAT New() and creating another. See, this is why you need to not put this kind of thing in New().

My suggestion is to make a proc for your spreading, then spawn() it whenever you create a new water.
In response to Immibis
no not 9 i was just testing something there lol