Ok I've got some of my own code to show now for random placement of turfs. The only problem now is I need to check to see if anything in the turf with the name other than "stars" is there if so it will use the continue command to skip it and not place anything there. I'm getting the following error for the loc.turf.name area.
error:loc.turf.name:undefined var
error::unknown variable type
LJR
UPDATE: I've now tested this code and it seems to work fine, just want to make checks so no other planets or other turfs are overlayed.
world/New()
var/i = 0
var/px, pz, pitem, loc
while(i <= total_planets)
px = (rand(1,500))
pz = (rand(1,500))
loc=locate(px,pz,1)
if(px > 239 && px < 261 && pz >239 && pz <261) continue
if(!istype(loc.turf.name=="stars")) continue
else
pitem = (rand(1,8))
switch(pitem)
if(1)
new/turf/planets/Class_M(loc)
i++
if(2)
new/turf/planets/Class_L(loc)
i++
if(3)
new/turf/planets/Class_V(loc)
i++
if(4)
new/turf/planets/Class_O(loc)
i++
if(5)
new/turf/planets/Class_K(loc)
i++
if(6)
new/turf/planets/Class_C(loc)
i++
if(7)
new/turf/planets/Class_U(loc)
i++
if(8)
new/turf/planets/Class_S(loc)
i++</261>
ID:149667
![]() Mar 13 2002, 12:39 am (Edited on Mar 13 2002, 12:46 am)
|
|
Ok I made the changes you suggested. One thing though I'm wonder does this code with the "continue" skip and still count as a i++ or will it break the while() statement?
if(T.contents.len>0) continue LJR |
LordJR wrote:
Ok I made the changes you suggested. One thing though I'm wonder does this code with the "continue" skip and still count as a i++ or will it break the while() statement? In a for() loop like this...
for(i=0,i<5,++i)
...then the ++i would be executed. In a while() loop, continue always skips back to the beginning of the loop. The continue statement always skips over the rest of the code you write within the loop, and will only execute anything else if you've defined it as an integral component of the loop. Lummox JR |
cool then I got code now that is checking the space for its and if nothing is there placeing things there..
I should have 500 space stations, 250 planets in my game. Since they're done dynamically its kinda hard to tell if its working right LJE |
Thanks but I think I've got everything working fine, and it was my own code!!! I didn't see anyone else's demo or example!!! Just needed that check part to work was all.
LJR |
I know you got yours working you should still look at mine it has some useful techniques that you can learn from it.
|
Lummox JR wrote:
Back to the switch, I think you should set up a list of planet types and use that instead: // this list var can be global too I'm curious, why not use typesof instead? ptype = pick(typesof(/turf/planets)-/turf/planets) /Andreas |
I was wondering about this also, typesof() is your friend, USE IT! icon_states() is also another friend use that too =P.
|
var/planets = 0 |
Foomer wrote:
if(typesof(T,/turf/planet)) planets++ I think you mean istype(). Lummox JR |
Next, there's the istype() call in there: You've only got one argument, and it's completely wrong. I'd change the loc var to something more constructive like var/turf/T=locate(...), which guarantees you'll get a turf, and then you only need to check if T.name!="stars" or T.contents.len>0.
Back to the switch, I think you should set up a list of planet types and use that instead:
Lummox JR