Code:
obj/teleporter
density = FALSE
icon = 'invis_teleporter.dmi'
opacity = FALSE
var
obj/dest
message = ""
New()
..()
spawn(1)
check_teleport()
proc/check_teleport()
for(var/mob/M in view(0, src))
var/obj/target = locate(dest)
M.loc = target.loc
M << output("[src.message]", "Main.system_output")
spawn(1)
check_teleport()
Problem description:
This code was designed so that when a mob is in the same location as this object, it will get teleported to a target location. However, I'm having a problem where only some mobs get teleported and others do not and I don't understand why it would do that.</<>
ID:141236
May 10 2009, 9:15 am
|
|
In response to Naokohiro
|
|
More info: I created this as an object, not a turf, for reasons I won't get into here. Your idea sounds solid though, so perhaps I'll see what I can do about changing into a turf and using Enter.
And you're right - F1 does have a lot of useful information, which I use extensively, this one just didn't seem to make any sense to me. Also, to answer your other question, I set the dest var using the map editor. I create the object and set the dest var to the tag of another object that serves as the destination for that teleporter. |
In response to Lachre
|
|
Lachre wrote:
More info: I created this as an object, not a turf, for reasons I won't get into here. Your idea sounds solid though, so perhaps I'll see what I can do about changing into a turf and using Enter. Be sure you understand the difference between Enter() and Entered(), they are two distinctly different procs. Enter() is only useful if you are potentially denying entrance to the turf (aside from the built-in density, etc. checks), which is not the case here, so stick with Entered(). You can still use an obj. When the turf's Entered() proc is called, it just has to loop through the specific teleporter obj type in that turf. e.g. for(var/obj/teleporter/T in src)... And you're right - F1 does have a lot of useful information, which I use extensively, this one just didn't seem to make any sense to me. The dest var, then should not be defined as an obj, and shouldn't have a defined type at all for that matter. (And now the use of the locate() proc makes sense too.) |
In response to Naokohiro
|
|
OK let me just make sure I understand you:
You're saying keep both the teleporter and destination objects. Remove the check_teleport stuff completely. Add an Entered() action that loops through obj/teleporter in the turf (so anytime a player enters the turf I define this for, it will check if any teleporters are there). If a teleporter is found, use locate(dest) on the teleporter's var/dest? |
In response to Lachre
|
|
I think that sounds about right.
|
obj I put some code together to show what can be done. You can look at it and maybe get some ideas on how to build things into cool systems. |
Look into using the Entered() proc. You're using locate() incorrectly.
You shouldn't be using locate() there at all. locate() isn't supposed to have an obj as an argument. There's also no reason to create a new obj/target var when the obj is already stored in the obj/dest var.
You shouldn't have it looping to check the teleport repeatedly, when it probably only needs to be checked when something actually moves onto it. You can check that with the Entered() proc.
Would you explain what you're setting the dest var equal to and how you're doing it?
Also, have you tried looking things up by pressing F1 while in Dream Maker? If you read things carefully, you can learn from them there.
Hope I helped.