ID:154246
 
I need help on the code needed to check a tile for any objects or turfs. If there is a is anything in that tile besides the default tile of name = "stars" then it should return. Otherwise it will place a turf or object there.

LJR
LordJR wrote:
I need help on the code needed to check a tile for any objects or turfs. If there is a is anything in that tile besides the default tile of name = "stars" then it should return. Otherwise it will place a turf or object there.

There should be only one turf per specific x,y,z loc, since that's their nature. Therefore I'd try this:
if(theturf.name=="stars" && !theturf.contents.len)
... // place a turf/obj here

Lummox JR
In response to Lummox JR
You didn't say "this belongs in Newbie central"! For shame ,Lummox. For shame..
In response to Nadrew
Nadrew wrote:
You didn't say "this belongs in Newbie central"! For shame ,Lummox. For shame..

Eh. I can see some justification for it being on this thread. LordJR may see it more as a question of how best to go about a particular task than as a question asking "How do I...?"

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Nadrew wrote:
You didn't say "this belongs in Newbie central"! For shame ,Lummox. For shame..

Eh. I can see some justification for it being on this thread. LordJR may see it more as a question of how best to go about a particular task than as a question asking "How do I...?"

Lummox JR

But he did say "the code [for]".
In response to Nadrew
aw Play my game and shad up! :P

LJR
In response to Lummox JR

There should be only one turf per specific x,y,z loc, since that's their nature. Therefore I'd try this:
if(theturf.name=="stars" && !theturf.contents.len)
> ... // place a turf/obj here

Lummox JR

I don't just like to get code.. like any good programmer, I I want to know.. What does the !theturf.contents.len do??

contents.len = something is already there or not?
otherwise contents would not have a len to begin with?

LJR
In response to LordJR
LordJR wrote:
I don't just like to get code.. like any good programmer, I I want to know.. What does the !theturf.contents.len do??

Since a turf is an atom, it has a contents list. By checking contents.len, I'm seeing if there's actually anything in that list or not. (When you say if(contents.len) you're really saying if(contents.len!=0), which works just as well.)

Lummox JR
In response to Lummox JR
Actually, I believe you can have multiple turfs at one loc, so long as the successive turfs have transparent areas.

-James
In response to Jmurph
Jmurph wrote:
Actually, I believe you can have multiple turfs at one loc, so long as the successive turfs have transparent areas.

-James

Nope. The map editor will allow you to place turfs with transparency on top of other turfs, but this simply creates one turf at that location with underlays of the previously placed turfs (or at least I believe that's what happens; you could try this and then check the turf's underlays var). Only the topmost turf actually exists as a turf.
In response to Leftley
Leftley wrote:
Jmurph wrote:
Actually, I believe you can have multiple turfs at one loc, so long as the successive turfs have transparent areas.

-James

Nope. The map editor will allow you to place turfs with transparency on top of other turfs, but this simply creates one turf at that location with underlays of the previously placed turfs (or at least I believe that's what happens; you could try this and then check the turf's underlays var). Only the topmost turf actually exists as a turf.

I believe the icons are meshed into one, not treated as actual underlays. It definitely only makes one turf, though.
In response to Skysaw
I believe they are actually underlays. At some point in the past, I complained about them not being in the actual underlays list, and Tom fixed it. An old map-saving routine of mine relied on this.

I think. I could just be making this all up.

-AbyssDragon
In response to AbyssDragon
AbyssDragon wrote:
I believe they are actually underlays.

Oops .. not yet. But that's the plan. :)
In response to Tom
Well, I did leave open the possibility of me having made that all up :-)

Heh, I wonder what I did to work around that, then...

-AbyssDragon