ID:157356
 
This problem is solved
refer to this post which has the solution to my problem
http://www.byond.com/developer/forum/?id=743632
thanks ^.^

P.S. This was actually suppose to be in the "Code Problems" subforum
---------------------------------------------------
I'm trying to make it where in my code where when the user steps onto a button, an arrow appears to the right of them to show them that they can exit to a different location from that direction.

here is what I have
mob/var/obj/ArrowEnter = new /obj/ArrowE()

turf/Enters/ArrowEnter
name=""
Entered(mob/M)
M.ArrowEnter = new(locate(M.x-1,M.y,M.z))
Exited(mob/M)
if(M.ArrowEnter) del M.ArrowEnter

obj/ArrowE
icon='Truck.dmi'; icon_state="32"; name=""; density=1


I made a topic with something similar a long while back, but I didn't get an answer I didn't understand what was told to me in the last reply to complete it from what was told to me there.
http://www.byond.com/developer/forum/?id=662279

I got it to work at some point but I forgot and my computer had crashed since then, so I don't have a working completed example, so that's why I'm asking here. >.<


Please help if some1 can.
And why did you post here? Even though you didn't say so, I'm going to at least assume that something about it does not work since you posted here about it. So now, what doesn't work? More specifically, what does it do that it shouldn't or what does it not do that it should, or what does it do in a different way that it is supposed to?

What you have isn't how I would do it, and it has some redundant stuff that could be removed (no need in what you've shown to initialize ArrowEntere to "new /objArrowE()", and you only need "locate(x-1,y,z)" since the turf will have the same coordinates as M), but still, it should do what you want it to do.

So how is it not working properly?
You could use the image() proc, you said A user, image() lets you show the arrow to that 1 person.

Just use the image() proc to show an image of the arrow at the location when you have Entered() the turf, then take it away when you Exited().

However, if you don't care that the arrow is showed to everyone in game, go ahead and just create the arrow object there for all users to see.

Either way, this looks like you want a handout, otherwise, if you wanted a code FIX, you should've posted under code problems instead, code problems is where you should post when you can't get code to work, how-to is to figure out possible code, not to get some fixed.
In response to Loduwijk
@Dan0971:
Ok, I admit I posted it in the wrong section.
I'm making a clone of the Pokemon Ruby game so I'm trying to get it's effects the same as in the actual game which what i'm trying to do.

It's suppose to be when a person steps on the location called "turf/Overlays/ArrowEnter", in the x+1, it will place the object called "obj/ArrowE" at that x+1 location.
And when the user exits from that location, that "obj/ArrowE vanishes.

@Loduwijk:
Like I said above, I posted in the wrong section by accident. I noticed some of the redundancies like that, but i have some of thoes redundancies there becasue in my mind I can notice what goes where
like the
M.ArrowE = new(locate(M.x-1,M.y,M.z))
I know it can be
M.ArrowE = new(locate(x-1,y,z))
but, having it with the "M." in front of each of them helps me recognize that that it's in relevance to the mob/M even tho it's not really needed

Well what's not going on, is what i'm wanting it to do as I stated above, lol.
In response to ElderKain
(edit)
Ok, I feel kind of dumb now.

You aren't telling it what type of object to make; you're just doing "new(location)" Normally that would be fine, as new will default to create whatever type of object that the variable it's being set to is supposed to hold. In your situation, you didn't tell it that the ArrowEnter variable is of type /obj/ArrowE, you only specified /obj. So you need to change your ArrowEntered variable declaration to be
mob/var/obj/ArrowE/ArrowEntered

so that it knows to create an ArrowE for ArrowEntered variable to reference. Right now, it's just creating an /obj, not an /obj/ArrowE.
(/edit)

<s>You could start by making sure Entered() is getting called.
turf/Enters/ArrowEnter
Entered(mob/M)
world << "[M] entered ArrowEnter"
M.ArrowEnter = new(locate(M.x+1, M.y, M.z))

Then, if that code is happening properly, you will see the debug output message. If you don't see it, you know the problem is that the section of code there is not happening.

Likewise, you could also do a ArrowE/New()
ArrowE
New(atom/loc)
world << "new ArrowE being created at ([loc.x], [loc.y], [loc.z])"


If both of the debug messages show, and it shows that it is creating the arrow in the correct place, then you know that the arrow is there but you just can't see it (invalid icon_state, perhaps?). If you don't a debug message from a certain section that should be happening, you know that section is not being called for some reason, and we have to dig deeper into the code.
</s>
In response to Loduwijk
Gotcha I understand now Loduwijk.
I got it to work now thanks to what you just said. ^.^
In reality it was a stupid overlook on my part on the new() in the entered() proc >.<

Here is what I used & it works just fine ^.^
mob/var/obj/ArrowE = new /obj/ArrowE

turf/Enters/ArrowEnter
Entered(mob/M)
M.ArrowE = new /obj/ArrowE(locate(M.x+1, M.y, M.z))
Exited(mob/M)
if(M.ArrowE) del M.ArrowE

obj/ArrowE
icon='Truck.dmi'; icon_state="32"; name=""; density=1


looking at what you stated, I looked at which what I had and I had
 M.ArrowE = new(locate(M.x+1, M.y, M.z))

So I added the /obj/ArrowE before the locate() area in the new() and it worked ^.^

I forgot to add the obj reference in the new call like you stated Loduwijk, thanks for your help ^.^
In response to ElderKain
One more tip: you can use get_step() instead of locate() if you want better readability, since that's what you said you were going for.
get_step(object, EAST)

That will get the tile to the right, just like
locate(object.x+1, object.y, object.z)

So you could also do the following.
new /obj/ArrowE(get_step(M, EAST))
In response to Loduwijk
Loduwijk wrote:
One more tip: you can use get_step() instead of locate() if you want better readability, since that's what you said you were going for.
get_step(object, EAST)

That will get the tile to the right, just like
locate(object.x+1, object.y, object.z)

So you could also do the following.
new /obj/ArrowE(get_step(M, EAST))

------------------------------------------------------------
Your right.
I think I'll use the third one you mentioned. It seems a lot cleaner & easier to understand ^.^

Thanks ^.^
Note that Entered(mob/M) does not filter out anything that isn't a mob. It simply tells the compiler to trust you that it will be a mob. As it is not necessarily the case that M would be a mob, you should check it before doing mob-specific, or you'll get a runtime error:

turf/Entered(mob/M)
if(!istype(M)) return
M.mobthing = stuff
In response to Garthor
Garthor wrote:
Note that Entered(mob/M) does not filter out anything that isn't a mob. It simply tells the compiler to trust you that it will be a mob. As it is not necessarily the case that M would be a mob, you should check it before doing mob-specific, or you'll get a runtime error:

turf/Entered(mob/M)
> if(!istype(M)) return
> M.mobthing = stuff


--------------------------------------------------------------

Well for the situation in the code i'm using, it's just involves mobs anyways, so there isn't a time when anything other than a mob would enter that area.

Thanks for the idea though.