ID:144559
 
I keep trying to make it that if you have a specific variable, like if your immortality == 1, you can't pass an area, but if it is 0, however, you can. What should I do to do that?
just like that
if(src.immortalitoy==1)
src<<"Sorry you cant pass"
return
else
src<<"You can pass"
*Then u run whatever after that*.
In response to KillerGrand
Not quite just like that.

if(immortality) //src actually isn't necessary. Not giving it a reference defaults to src

That's a lot better than
if(immortality==1)


This is because if you're checking a boolean var, the former example checks for all true conditions- 1, 2, any number above 0, if there's text in a text string, even lists and so on. It's more robust.

The same goes for
if(!immortality)

which should be used instead of
if(immortality==0)


It checks for all false values, like 0, "", null and so on.
In response to Elation
It didn't work. Don't know why.
shield
icon_state="invis"
density=0
if(usr.immortality == 1)
usr<<"Can't pass!"
return
else
usr<<"Made it!"
First it says that the immortality is a duplicate definition, then it says that Can't pass and Made it are duplicates, followed by it saying that << is not allowed in the program, and now I'm confused.
In response to Aleksa6
Maybe make it for(var/obj/Shield in src.contents)src.imortality+=1 if(src.imortality==1) src<<"Can Pass"
else
src<<"Sorry Cant Pass"
In response to KillerGrand
src.contents?

don't have that.
In response to Aleksa6
omg

obj/sheild
icon='icon.dmi'
icon_state="invis"
density=0
verb/immortal()
if(usr.immortality == 0)
usr<<"You are now immortal"
usr.immortality = 1
else
usr<<"You are no longer immortal"
usr.immortality = 0


That will make it so if the sheild is in your inventory it will give you a verb to make yourself immortal. You need to put the location of the iventory in it though because you said it wasn't .contents

Also you will need an area with an Enter() to return 0 if they are immortal. <.<
In response to CYN
K, this might be useful too. Thx.

What I really need though is a code that acts as a shield that keeps a specific form of character away from an area, like a force field around a secret lair.
In response to Aleksa6
area
thatarea
Enter(mob/M)
if(M.badguy == 0)
return 0
else
return 1
In response to CYN
1) In movement procs, such as Enter() and it's cousin, it doesn't check for the specified type so MAKE SURE YOU SAFETY CHECK BEFORE PRECEDING:
if(!ismob(M))return
if(M....)


2) Do yourself a favour and read about boolean and it's shortcuts because if badguy was null instead of 0... well you know, you have a problem on your hands in which you didn't want >_>

3) return automatically stops the rest of the code from happening.. what does that mean? If the mob (M) was a badguy, it would return 0, meaning you do not really need the else there
if(!M.badguy)return 0//stops from going lower
return 1


- GhostAnime
In response to KillerGrand
KillerGrand wrote:
Maybe make it if(src.imortality==1)

Stop sucking.