How do I make a variable be a certain location on map?
Some thing like "respawnloc = (45,4,1)" But how do I do it with working code? :P
ID:163321
Sep 10 2007, 4:45 am
|
|
In response to KirbyAllStar
|
|
On the firt example (locate(##,##,##)) I get this error "error:= :expected a constant expression"
I will try the other one. EDIT: I don't think the second one would work since I want to change the position sometimes :/ |
In response to Syltmunk
|
|
Set the variable when it is created (such as New()).
If you want to have it respawn the same loc as it was placed on the map, look up initial() :o |
You can use the locate() proc to obtain the turf that has a specific x,y,z coordinate.
var/turf/T=locate(1,1,1) would set the variable T to the most bottom-left turf on the map. The loc variable of atoms is simply a reference to a turf. Except for turfs: their loc variable is a reference to an /area. Areas could be seen as a collection of turfs. -- Data |
In response to Android Data
|
|
you cant save a turf though can you o.O
|
In response to Falacy
|
|
Falacy wrote:
you cant save a turf though can you o.O You can, but it ain't as easy as saving a non-turf. -- Data |
In response to Android Data
|
|
what if I want to save "T" as the players current position? :/
Should it be "T = usr.loc"? (This starts to go to code problems...) |
In response to Syltmunk
|
|
You can't save turfs like that. Turfs need a location on the map in order to be able to survive. The only way to save turfs is to save their variables & type, and reinitialize those when the world boots up (overwriting the default turf present on that tile).
In order to save the players' location, you will have to save the x,y,z coordinates. By default the variable equivalent of those don't save, but you can override this behavior using Read() (get the x,y,z from the savefile and set loc=locate(x,y,z))and Write() (write the x,y,z variables to the savefile). -- Data |
In response to Android Data
|
|
ok, think I know how I should do now but I still get this error "error:= :expected a constant expression" when I define that "respawnloc = T".
Also "respawnloc" is a mob/var. |
In response to Syltmunk
|
|
Variables must be set to a constant expression at compile-time. T is a turf, and therefore not constant.
You must define the variable within a proc like New() for it to work. mob/var/respawnloc=locate(1,1,1) will return this error, because it can't run procs at compile-time like that. -- Data |
In response to Android Data
|
|
if I get you right I supposed to do this:
New() But that doesn't work. |
In response to Syltmunk
|
|
mob/var/respawnX=5 |
In response to Syltmunk
|
|
Syltmunk wrote:
if I get you right I supposed to do this: > New() But that doesn't work. Well, duh. Look at your code: all you're doing is defining a variable called T in the New() proc. Do you actually do anything with it? No. Before ..(), put loc=T or respawnloc=T to actually use it for something. Also, the ..() should become return ..(), incase you're ever going to use a return value in the future. It's not much, but it's good to know you accounted for such things already, so you don't have to rewrite your code in the future (when it's all cluttered and unreadable because of your lack of comments). -- Data |
The first one actually is a turf, So I don't think thats what you want. I'm not sure if the second one would have what you want, but it might.