How would I code for when you enter a certain spot,
*like stepping on a button*
which I know that would use the Entered() proc,
at
locate(src.x,src.y+1,src.z)
it will place
/obj/switchopen
and when they step off the spot *Exited() proc*, it will remove the object that was placed at
locate(src.x,src.y+1,src.z)
I'm not sure how I would code that.
ID:160457
Sep 6 2008, 10:46 am
|
|
In response to Andre-g1
|
|
Andre-g1 wrote:
> turf/button Hope that's what you were trying to do. :D well the Entered() part is what i need, but the Exited() is a lil off, becasue in a game which there are multiple people, instead of the "in view(src)" it would have to be a remove it at the "locate(M.x,M.y+1,M.z)" otherwise, using the above code u stated, becasue if someone else in the game triggers the button that is right next to the other button, when they exit it would remove the switch that appeared for you also. since they will be in the same view as you. only way the above would work, is if the /obj/switchopen/ was only visible to the person who triggered the button, which that would work, but I wouldn't know how to do that. |
In response to ElderKain
|
|
Ah, I didn't know that.
Then hmm ; turf/button I think that'd work. *shrug* |
In response to ElderKain
|
|
You could make it look for objs (or one obj) in that turf above it easily enough as well, ironically the latter with another usage of the locate() proc (look up locate() and mind the 'in Container' syntax).
var/obj/myobj/O = locate() in locate(x,y+1,z) Confused much? >_>" You could also switch that last locate(coordinates) for get_step() to make it slightly more convenient, as only one step away is needed (otherwise, you couldn't really use it). Or, to make it basically as robust as possible, you could assign the turf a reference to the obj it created, so it is 100% sure which obj was created by it and not by something else. turf/button Actually another thing you should do for complete robustness is make sure the location turf you're using actually exists, since if the turf is accidentally at the top y-coordinate on the map or something, it will break as there won't be another turf above it. EDIT: Ah, Andre beat me to it, kinda. =P |
In response to Andre-g1
|
|
Andre-g1 wrote:
Ah, I didn't know that. > turf/button I think that'd work. *shrug* hmmm, but how does that place the /obj/switchopen icon because, I don't know how it woul call the object that is supposed to appear. |
In response to ElderKain
|
|
It will create an obj of type /obj, because Andre defined that var as that type. My similar code creates it as /obj/switchopen.
The following: var/obj/switchopen/O = new /obj/switchopen(Location) is equivalent to var/obj/switchopen/O = new (Location) It's just a shortcut (look up new() for more detail). |
In response to Kaioken
|
|
Kaioken wrote:
It will create an obj of type /obj, because Andre defined that var as that type. My similar code creates it as /obj/switchopen. var/obj/switchopen/O = new /obj/switchopen(Location) is equivalent to var/obj/switchopen/O = new (Location) It's just a shortcut (look up new() for more detail). i have this now obj/switchopen |
In response to ElderKain
|
|
You've got 2 things wrong there. First, you defined your mob variable as of type /obj, not /obj/switchopen. It's just a var named "switchopen" but its defined type is /obj. Read here to see how to properly define a var.
Second, the obj you're creating has no location, so of course it doesn't show up. Due to you falling to change its location properly, it will also be deleted due to garbage collection. M.switchopen = new() As you can see you are setting the same variable twice... first it's set to a reference to the obj which is right, bu then you change the switchopen variable to a turf at specific coordinates, overwriting the value of the obj. You're not changing anything's actual location. You should also just use new()'s argument to put the object at a location instead of doing it manually (with the loc var). You can use the code I posted previously as reference. |
Hope that's what you were trying to do. :D