ID:148343
 
nevermind fixed it
Jinjo21 wrote:
i have a var under turfs var/dig which has a value of 3 when the value reached zero it sets T's density to 0 but the problem is it sets the density of all the turfs in that type to zero and not that specific turf :-\

Nope, it shouldn't be doing that at all. Nothing in your code shows it to be changing the var of any turf besides T, which is just one specific turf.

A lot of this code could be vastly improved though. For one thing, setting T.density=1 is redundant. The icon_state for when T.dig==0 is the same for every turf. The various icon_state settings could be made into a formula. T.dig==3 is a case that will never even happen. (Think about it; if T.dig starts at 3, and you subtract 1 before checking it each time, the highest it'll be when you check is 2.) And finally, you should really check for T being null in case the mob tries to dig out the side of the map.
mob/verb/Dig()
set category = "Game Commands"
var/turf/nest/T = get_step(src,src.dir)
// if /turf/nest only has diggable turfs, this is good
// otherwise, put all your dirt in a new category like /turf/nest/dirt
if(!T || !T.density || !istype(T,/turf/nest)) return
if(--T.dig <= 0)
T.icon_state="Nback1"
T.density=0
else
T.icon_state=initial(T.icon_state)+(3-T.dig)
The whole result ends up being much cleaner.

Lummox JR