ID:158153
Oct 20 2009, 11:10 am
|
|
How would I, for example...say you flew into the skies, and were re-located into the skies map, how would you re-locate yourself back to the exact same spot as where you were when you land?
|
Oct 20 2009, 12:17 pm
|
|
Store the location in a variable, then move back to it.
|
well, this is the coding for a portal
turf #1 icon='#1.dmi' Enter() usr.loc=locate(X,Y,Z) #1 is the name of the icon X,Y,Z is the map coordinates |
In response to Darkjohn66
|
|
Darkjohn66 wrote:
well, this is the coding for a portal No it's not. I'm not trying to sound degrading, but that is not even a coding for a portal let alone the coding for a portal. Doing it like that can (and has) caused bugs in games. Also, I do believe the OP has a situation where an object is at location A and (s)he is successfully relocating it to location B, and later wants to return it to location A. For portals, the following may be overkill, but it should work well for pretty much any circumstance and is clean and bug-reduced. portal And, if you wanted to use this method for the OP's problem, you could implement a subtype of portal. portal/specialPortalThatTakesYouBackWhereYouStarted Then he could use it like this, for example... turf/warpToSpecialPlace Don't use usr in most things, including Enter(), unless you're sure that's what is appropriate (which it's usually not). Also, Enter() is what checks to see if you are allowed to make a move; use Entered() to do things that are supposed to trigger when a move is successful. Hope all this helps. |
In response to Loduwijk
|
|
Thanks for the help, but not exactly what i'm looking for. I'm looking for something that will make it to where you will be Taken EXACTLY back to where you were before you started flying, no matter how much you moved.
EDIT: Nevermind, I understand it now. |
In response to Xorbah
|
|
My last example addressed that issue. The "portal/specialPortal" keeps track of exactly where you were when you were moved so it can later move you back to the same spot.
|
In response to Loduwijk
|
|
How do I use it, though? It keeps saying that the proc is undefined.
stuff.dm:184:error:movable:undefined var stuff.dm:184:error:M:undefined var stuff.dm:184:error:warp:undefined proc stuff.dm:187:error:M:undefined var stuff.dm:187:error:M.loc:undefined var stuff.dm:189:error:movable:undefined var stuff.dm:189:error:M:undefined var stuff.dm:189:error:proc/returnWarp:undefined var stuff.dm:190:error:M.loc:undefined var stuff.dm:190:error:M:undefined var stuff.dm:191:error:M:undefined var stuff.dm:185:if :warning: if statement has no effect stuff.dm:192:if :warning: if statement has no effect stuff.dm:182:portal :warning: unused label stuff.dm:182:backtolocation :warning: unused label |
In response to Xorbah
|
|
That last example was a use of it. I made a turf/warpToSpecialPlace that used it and an obj/coolWarperThing that used it.
In the following, I'm going to call the special portal "returnTripRelocator" instead of "specialPortalThatTakesYouBackWhereYouStarted" like I did in the previous post. The following code snippet is the thing that does the relocating, and the second code snippet is an example of how to use it. The "roundTripRelocator" is what handles the "bring me back to exactly where I started" /** The roundTripRelocator is what handles the part you want. Now, as for an example of using that, I will assume you have a verb for flying, as you didn't specify (at least not that I remember) how the flight is initiated. var/relocator/roundTripRelocator/flyRelocator Or, if you have a turf that triggers the flight, here's an example for that too. In the following example, you step onto a special turf, it sends you into the fly zone, and you get a "stop flying" verb to click when you want to land, and, when you land, you return to the spot you were on just before you started flying. turf/flyPad You can also do other fun stuff when you set systems up like this. For example, I could override relocate() for the following fun use. The next example does not address your issue directly, but I'm just showing more fun stuff you can do. relocator/randomRelocator And I had a couple other neat examples in my other post too. When you set stuff up like this, taking advantage of object oriented programming, it's easy to adapt what you make to lots of cool uses. Again, go back to the first two for the examples specifically for what you're doing. |
In response to Loduwijk
|
|
Loduwijk wrote:
For portals, the following may be overkill, but it should work well for pretty much any circumstance and is clean and bug-reduced. Shame on you for saying this while that code uses direct modifying of loc (and nothing else) to do movement! Although you did say "bug-reduced" and not "bug-free", you should still try not to spread a bad practice. |