ID:148361
 
I have made a swimming code and when you decide to swim your density goes to 0 and when you stop it goes to 1 again. Now the problem is to get it so that the player doesnt just walk over everything. I need it so that when he tries to stop swimming or leave the water for it to set his density back to one. Help would be appreciated.
turf
water
Enter(mob/M)
if(ismob(M))
if(M.swimming)
return ..()
return 0

mob
verb
swim()
swimming = 1 - swimming
turf
water
icon = 'water.dmi'
Entered(mob/M)
if(ismob(M))
if(M.client)
M.density = 0
M.icon_state = "swim"
Exited(mob/M)
if(ismob(M))
if(M.client)
M.density = 1
M.icon_state = ""

Siientx
In response to Siientx
Thanks for your help.
In response to Siientx
Actually changing density is a much worse solution than simply changing Enter() to allow swimmers. In fact, the best possible solution is to make water non-dense, but make Enter() disallow any non-swimmers from entering the water.

Lummox JR
In response to Garthor
Garthor wrote:
swimming = 1 - swimming

Uh... no. Bad move.

Better:
swimming = !swimming

Lummox JR
In response to Lummox JR
Lummox, the only problem im having is with the Enter() part of the code. whenever i compile it says Inconsistent Indention for all the lines. I've tried to fix this as much as i can but still no luck. Any ideas??
In response to Jackiechun302
That means your indentation is inconsistent, like my spelling of inconsistant. If you copied and pasted it, then it would be inconsistent. Type it in manually, and it should fix the inconsistant indentation errors.