ID:149760
 
Im trying to finish up my project i started a while back and i need some questions answered..

  • Can you use vars and locate? Example: var/my_var = locate(usr.x,usr.y+1,usr.z) and then use it like, my_var.density = 1.

  • Can you use for() in the following way?: for(var/turf/T in locate(usr.loc))

    There are more, i just need some ways to get the turf (or atom) in a certain x,y,z coordinates, into a var, do i can edit thier vars.

    Thank you

    -Rcet
Rcet wrote:
Can you use vars and locate? Example: var/my_var = locate(usr.x,usr.y+1,usr.z) and then use it like, my_var.density = 1.

Yes, that's perfectly acceptable. locate(x,y,z) should always return a turf, but it will at any rate be an atom; use var/atom/my_var and then density is a known var belonging to it.

Can you use for() in the following way?: for(var/turf/T in locate(usr.loc))

No, because locate() returns a turf, and a turf won't have other turfs within its contents. (Also, locate(usr.loc) is redundant; usr.loc should do well enough as long as it's a turf.)

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Rcet wrote:
Can you use vars and locate? Example: var/my_var = locate(usr.x,usr.y+1,usr.z) and then use it like, my_var.density = 1.

Yes, that's perfectly acceptable. locate(x,y,z) should always return a turf, but it will at any rate be an atom; use var/atom/my_var and then density is a known var belonging to it.

This is funny. I tried doing this for a test, and it gives me errors:
client
Move()
..()
var/my_var = locate(usr.x+1,usr.y,usr.z)
my_var.opacity = 0

error:my_var.opacity:undefined var
my_var :warning: variable defined but not used


What is wrong? I also tried doing this under mob.Move() but still gives me the same errors.

-Rcet
In response to Rcet
Because my_var doesn't have a opacity var because it's not defined as an atom.

var/turf/my_var = locate(x,y,z)
my_var.opacity = 1
In response to Nadrew
D'OH! *smacks himself with an anvil* i shoulda seen that. Im so embarassed -.-;

Thanks

-Rcet
In response to Nadrew
I did that, and at runtime, when i press an arrow key, it gimes me this:
runtime error: Cannot modify null.opacity.
proc name: Move (/client/Move)
usr: Rcet (/mob)
src: Rcet (/client)
call stack:
Rcet (/client): Move(null, 4)


Thanks

-Rcet
In response to Rcet
Rcet wrote:
I did that, and at runtime, when i press an arrow key, it gimes me this:

proc name: Move (/client/Move)
usr: Rcet (/mob)
src: Rcet (/client)
call stack:
Rcet (/client): Move(null, 4)

You have to check on the value returned by locate() to be sure it's not null. If you try to get a location off the edge of the map, locate() returns null instead of a turf.

Lummox JR
In response to Rcet
Rcet come on msn or are you ignoring me :|.