ID:139176
 
Code:
turf
TLvlGo
Enter()
if(usr.town1=="None")
if(usr.TLvl>=4)
usr.town1="Enabled"
density=0
if(usr.TLvl<=5)
density=1
usr<<"<font color=red><b>You aren't experienced enough!"
if(usr.town2=="None")
if(usr.TLvl>=8)
usr.town2="Enabled"
density=0
if(usr.TLvl<=9)
density=1
usr<<"<font color=red><b>You aren't experienced enough!"
if(usr.town3=="None")
if(usr.TLvl>=14)
usr.town3="Enabled"
density=0
if(usr.TLvl<=15)
density=1
usr<<"<font color=red><b>You aren't experienced enough!"
if(usr.town4=="None")
if(usr.TLvl>=19)
usr.town4="Enabled"
density=0
if(usr.TLvl<=20)
density=1
usr<<"<font color=red><b>You aren't experienced enough!"
if(usr.town5=="None")
if(usr.TLvl>=25)
usr.town5="Enabled"
density=0
if(usr.TLvl<=26)
density=1
usr<<"<font color=red><b>You aren't experienced enough!"
if(usr.town6=="None")
if(usr.TLvl>=30)
usr.town6="Enabled"
density=0
if(usr.TLvl<=31)
density=1
usr<<"<font color=red><b>You aren't experienced enough!"
if(usr.town7=="None")
if(usr.TLvl>=36)
usr.town7="Enabled"
density=0
if(usr.TLvl<=37)
density=1
usr<<"<font color=red><b>You aren't experienced enough!"


Problem description: I want it so just like in PWO, you need a trainer level to switch through different towns. But as you can see, this code is messed up, I don't know how. You need to be lvl 5 to go through the first town, so I tried coding that in as: if(usr.TLvl>=4) .. . I reached level 5 and still blocks me with the "You arent experienced enough" quote. . Basically it still restricts me from moving through even though I reached the level.

Enter() returns a value(true or false) to Move(). When it returns true, Move() may continue. You do not need to modify the turf's density at all, it should stay undense.

In your case, you want to return 0 when your level isn't high enough, and return 1 when it is.
In response to Kaiochao
Thanks trying it out now.
Well . . It's still dense when I try to walk through. . I made the restriction levels from anything less than 5, you cant go to town 1. I'm Level 5, and I cant walk through it, it's dense and i put return 1.


This is the new code:

turf
TLvlGo
Enter()
if(usr.town1=="None")
if(usr.TLvl>=4)
usr.town1="Enabled"
return 0
if(usr.TLvl<=5)
usr<<"<font color=red><b>You aren't experienced enough!"
return 1
In response to HaxRp
HaxRp wrote:
Well . . It's still dense when I try to walk through. . I made the restriction levels from anything less than 5, you cant go to town 1. I'm Level 5, and I cant walk through it, it's dense and i put return 1.


This is the new code:

turf
> TLvlGo
> Enter()
> if(usr.town1=="None")
> if(usr.TLvl>=4)
> usr.town1="Enabled"
> return 0
> if(usr.TLvl<=5)
> usr<<"<font color=red><b>You aren't experienced enough!"
> return 1

because you are using if(usr.TLvl<=5) which should be if(usr.TLvl<5)
In response to Hassanjalil
Actually, the OP is using usr in a proc, which is generally very bad.

As the DM Reference states:

Format:
Enter(atom/movable/O)
Returns:
1 to permit; 0 to deny.
When:
Called when an object attempts to enter the contents list.
Args:
O: the object attempting to enter.


Now, it doesn't have to be O or atom/movable/O, but in your case, it should probably be mob/M. Instead of checking the level of "usr," you should be checking the level of what's attempting to enter the turf. "usr" doesn't exist in this case.