ID:262412
 
Code:
turf
Shop
Entered(atom/M)
if(istype(M,/mob/Player))
var/mob/Player/P = M
P.Show_Shop = 1
M:Show_Shop = 1
Exited(atom/M)
if(istype(M,/mob/Player))
var/mob/Player/P = M
P.Show_Shop = 0
M:Show_Shop = 0


Problem description:
It wont set the Show_Shop to 1, but I sets it to 0...

EDIT, I have the M: to test if that worked if the P didnt..
Do you have world/mob=/mob/layer or something?
In response to Hell Ramen
No..I have overlays on the mob though, they have layer = MOB_LAYER + 1
In response to ITG Master
if(istype(M,/mob/Player))

Is your mob the type of /mob/player?
Do world<<M.type above that if statement
In response to Hell Ramen
_>
world
name = "Dragon Ball Kaiku"
view = 6
mob = /mob/Player
status = "Beta Testing"
<dm>
It's times like these I resort to the tried-and-tested "print statement debugging" method. =)

Obviously DM has no print statement, but that's a minor technical detail. =P

Make these alterations:

turf
Shop
Entered(atom/M)
world << "DEBUG: [M.type] has entered the building"
if(istype(M,/mob/Player))
world << "DEBUG: [M.type] (entering) is a player"
var/mob/Player/P = M
P.Show_Shop = 1
Exited(atom/M)
world << "DEBUG: [M.type] has left the building"
if(istype(M,/mob/Player))
world << "DEBUG: [M.type] (leaving) is a player"
var/mob/Player/P = M
P.Show_Shop = 0


Now try entering the shop tile again, and see which (if any) of those messages appear. That should help to narrow down the problem.
Well, since you're only checking for one type, why not do this instead:

turf
Shop
Entered(mob/Player/M)


Type checking won't even be neccessary. Also, you won't have to use the : operator, as it's best to avoid ever using it.

Entered and Exited checks to make sure whatever atom Entered or Exited it was of the type used in it's arguments, or else it will return.

Prodigal Squirrel

In response to Prodigal Squirrel
You dont listen...I said I was using the M: to test something.
I am no begginer to coding. Let me ASK YOU, Lets say I changed it to /mob/Player in the Enter(), What if I Ki Blast enters it? >_> Other things enter it I am calling procs and things for also...

- ALSO, I FIXED IT BEFORE THESE LASTS POSTS thanks -

*EDIT* This is ITG Master, and also, Sorry I didnt mean to come across mean, I am just agrivated V_V'
In response to Prodigal Squirrel
Prodigal Squirrel wrote:
Well, since you're only checking for one type, why not do this instead:

turf
> Shop
> Entered(mob/Player/M)

Type checking won't even be neccessary.

Well, no -- that's not true at all.

See, DM is a loosely-typed language, so here, when we define M as a /mob/Player, it means that the compiler will think of M as a /mob/Player, but doesn't actually guarantee that M will really be a /mob/Player.

You still need to make sure that M is the type it was declared to be:

turf/Shop/Entered(mob/Player/M)
if(!istype(M)) return
//...
In response to Sniper Joe
No harm done. I must also apologize; I didn't read your post fully through.

Prodigal Squirrel
In response to Wizkidd0123
That's an eye opener. I had something very similar in some of my own code, and I assumed that by giving the variable a type path like that, that type checking wouldn't be neccesary. I better go fix that.

So when you declare a variable with a certain type, it assumes that whatever gets assigned to it is of that type, but doesn't prove it?

Prodigal Squirrel
In response to Prodigal Squirrel
Prodigal Squirrel wrote:
So when you declare a variable with a certain type, it assumes that whatever gets assigned to it is of that type, but doesn't prove it?

Yeah -- that's pretty much it. =P

One handy thing to know is that istype()'s second argument, type, defaults to the declared type of istype()'s first argument -- the object. It'll save you some typing. =)
In response to Wizkidd0123
One handy thing to know is that istype()'s second argument, type, defaults to the declared type of istype()'s first argument -- the object. It'll save you some typing. =)

I knew that one... at least.

Prodigal Squirrel