ID:171254
 
In my game, there is flying + swimming. Now for swimming to work ive had to use Enter().

The problem is my turf code is all cluttered up, because, for each turf i have put Enter() so when u enter the turf anything that isnt water, if your swimming then u stop swimming.

Now is there a way to make this all one code block.

I have tried if(T == "water"), this doesnt work, i have also tried if(isturf(/turf/terrain/water)) again this doesnt work.

i have,
turf/terrain/Enter(atom/movable/A)
//code here


I want to make it so,
turf/terrain/Enter(atom/movable/A)
if(T == "water")
//blahhhhh
else
return 1


Is this the right way to go about it?

Thanks,

Farkas
Farkas wrote:
In my game, there is flying + swimming. Now for swimming to work ive had to use Enter().

The problem is my turf code is all cluttered up, because, for each turf i have put Enter() so when u enter the turf anything that isnt water, if your swimming then u stop swimming.

Now is there a way to make this all one code block.

I have tried if(T == "water"), this doesnt work, i have also tried if(isturf(/turf/terrain/water)) again this doesnt work.

i have,
> turf/terrain/Enter(atom/movable/A)
> //code here
>

I want to make it so,
> turf/terrain/Enter(atom/movable/A)
> if(T == "water")
> //blahhhhh
> else
> return 1
>

Is this the right way to go about it?

Thanks,

Farkas

Actually you should use istype to check if the turf is of teh type water(if that's how you defined the water turfs) like so:
if(istype(T,/turf/water)//if T is water
src.icon_state = "swim"


of course this should be in the Move() proc for mobs. That way it only has to be in one place. You can also at that time make it so you need something to swim, if not the Move() proc returns 0(or needing wings to fly or what ever)
In response to Jik
Yeah, if you wanted to make life easy, you could divide up your turfs logically into ground, air, water, etc...

ie.

turf
ground
Enter()
//Enter() stuff for ground types go here
Grass
icon = 'grass.dmi;

water
Enter()
//Water Enter() stuff goes here
ShallowWater
icon = 'water1.dmi'


That way all of your turfs of a certain type inherit a specific Enter() function. If you wanted to do it all in a single function, you could make it in the turf root, and just do a check on the type of turf being entered (which is what Jik suggested, except that he states that it may do better in the mob Move() function). I hope one of these methods helps you out.