ID:144559
![]() Oct 29 2006, 7:10 am (Edited on Oct 29 2006, 8:22 am)
|
|
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?
|
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. |
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. |
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" |
omg
obj/sheild 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. <.< |
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. |
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 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 - GhostAnime |
if(src.immortalitoy==1)
src<<"Sorry you cant pass"
return
else
src<<"You can pass"
*Then u run whatever after that*.