ID:159642
 
Well i want to make a move delay when you are walking on a certain turf if some var is 1 and not allow someone to step on it if the same var is 2 but i have no idea where to start....so is it possible and how?
Use turf/Enter() for that.

And yes, it is possible.

turf/Slow_Stop
var/state
Enter(mob/M)
if(istype(M,/mob))
switch(state)
if(1) // slow them down

if(2) return 0
..()


Something like that should give you a head start.
In response to Andre-g1
turf
water
icon = 'turf.dmi'
icon_state = "water"
Enter(mob/M)
if(istype(M,/mob))
switch(M.Water)
if(0)
M.Move_Delay = 0
if(1)
M.Move_Delay = 0
if(2)
M.Move_Delay = 10
if(3) return 0


Ok so it does all ok with the delay but I still need to code somehow that he walks to the turf...right now he only gets the delay and the water acts as density = 1
In response to Destrojer
You forgot to call the parent, ..().

And also, on a switch if statement, you can use multiple values, so instead of :

          if(0)
M.Move_Delay = 0
if(1)
M.Move_Delay = 0


You can just do this :

          if(0,1) M.Move_Delay = 0

In response to Andre-g1
turf
water
icon = 'turf.dmi'
icon_state = "water"
Enter(mob/M)
if(istype(M,/mob))
switch(M.Water)
if(0,1)
M.Move_Delay = 0
if(2)
M.Move_Delay = 10
if(3) return 0
..()


I tried placing it everywhere but still the same problem.
In response to Andre-g1
You can also use to's in switch if statements which I didn't know you could before :o

mob/verb/Verby(n as num)
switch(n)
if(1 to 9) usr<<"This number is between 1 and 9! :D"
if(10 to 19) usr<<"This number is between 10 and 19!"
else usr<<"This number is greater ot equal to 20! :D"
In response to Spunky_Girl
You can use 'to' even if it isn't in a switch statement, however that's irrelevant to this topic.
In response to Andre-g1
It's totally relevant :)

switch(M.water)
if(0 to 1) //...
if(2) //...
else //...


:)
... any chance of getting a better description of this? If so, I might be able to write up something for you. What you have now is borderline nonsense.
In response to Popisfizzy
turf
water
icon = 'turf.dmi'
icon_state = "water"
Enter(mob/M)
if(istype(M,/mob))
switch(M.Water)
if(0,1)
M.Move_Delay = 0
if(2)
M.Move_Delay = 10
if(3) return 0
..()


well....it's supposed to if Water = 0 or 1 you can move on it with no delay,if Water = 2 you can move on it but with a delay,and if 3 you are not able to move on it.....but with this code i have,move delay is ok,but water turf acts as density = 1
In response to Destrojer
Note that the following code is dependent on the stuff laid out here, which is also in my pif_MovementSystem library.
mob/var/swim_skill = 0

turf
var
//Multiplier, to make it easier or harder to swim.
//Decimal values indicate easier (and, therefore,
//shallower waters), while higher numbers make it
//tougher. 1 is neutral.
swim_difficulty = 1

//A value at or above this point won't be able to
//enter.
swim_bound = 3

Enter(mob/m)
if(istype(m))
//If the thing entering is a mob, then
//do the following.

//Just gets the swim_skill. If it's 0, then the
//logical or here will return 1, setting it to
//one.
var/s = swim_skill || 1

if(s >= swim_bound)
//If the skill is at or above the bound,
//don't let them in.
return 0

//This matches it to what you have right now.
var/d = (s - 1) * 10 * swim_difficulty
m.SetDelay(d) //Set the mob's delay.

return 1 //And, finally, indicate they can enter.

return 1 //If they aren't a mob, let them enter.
//There's no reasons objs shouldn't be
//able to come in.

Exit(mob/m)
if(istype(m))
//This assures they aren't stuck with the delay.
m.SetDelay(0)

return 1
In response to Popisfizzy
Thank you...."return 1" works in this case....unlike "..()" >.<
In response to Destrojer
... that would be because ..() returns nothing. In most things, Enter() and other similiar procs do nothing but return 1 by default, so there's no need to call the parent proc.
In response to Popisfizzy
Exit() does just return 1 by default, but returning 1 in an Enter() override like you did breaks the normal movement rules of density, since that what its default behavior governs. Unless you want everything to be considered nondense in water, you should return ..() so the final return value allows or disallows the movement according to density of objects.

Also, watch your wording. =P
Popisfizzy wrote:
..() returns nothing. [...] Enter() and other (simil<s>i</s>ar) procs [...] return 1
<font color=red>Word</font> <font color=#33CCFF>Police</font>
In response to Kaioken
I don't believe I was thinking very clearly when I wrote that statement.
In response to Popisfizzy
Now i have another question >.<

turf
water
icon = 'turf.dmi'
icon_state = "water"
Enter(mob/M)
if(istype(M,/mob))
switch(M.Water)
if(0,1)
M.Move_Delay = 0
return 1
if(2)
M.Move_Delay = 10
return 1
if(3) return 0
Exit(mob/M)
if(istype(M,/mob))
M.Move_Delay = 0
return 1
verb
Dive(mob/usr)
//removed because the rest is useless to this matter
Surface(mob/usr)
//removed because the rest is useless to this matter


The verbs Dive/Surface.....when you use then then if there is someone in your view it shows that screen to select who you want to do it on,and i want to make it only be used on the user. (well...either way it is only used on the user but that screen is annoying.....how to remove it?)
In response to Destrojer
Um, this is because you did it right there yourself by defining a mob argument in the verb, and verb arguments require the player to supply a suitable value by choosing. It's also essentially useless there seeing as the usr var is a var that is already pre-declared and exists on all procs; in fact it's weird and perhaps buggish if that code actually compiles, as it declares a new var with a name already used; I'll rather assume you used a different actual var name.

What you want in a verb like that is probably the src setting, to make the verb only available when in water and as such as desired (though that would be the case by default with turfs), and using the usr var to denote the player running the verb, as that's what that var does. You should probably read the DM Guide on verbs, and look them up (and verb arguments) in the Ref as well.
In response to Popisfizzy
We all have those moments, but a nice way to put it, there. >.>