ID:266733
 
my map is 120x120
and thisi s how I'm doing it...

which doesn't work... for Some reason it won't even load...
proc
tr()
for(var/turf/a as turf in world)
switch(rand(1,100))
if(1 to 10)
a.icon = 'ground5.dmi'
a.density=0
a.land=1
if(11 to 30)
a.icon = 'ground9.dmi'
a.density=1
if(31 to 35)
a.icon = 'ground2.dmi'
a.density=1
if(36 to 45)
a.icon='Shields.dmi'
a.icon_state="mountainL"
a.density=1
if(46 to 50)
a.icon='Shields.dmi'
a.icon_state="mountainR"
a.density=1
if(51 to 55)
a.icon = 'mountains.dmi'
a.density=1
if(56 to 60)
a.icon = 'mountains2.dmi'
a.density=1
if(61 to 65)
a.icon = 'mountain.dmi'
a.density=1
if(66 to 70)
a.icon='Turfs.dmi'
a.icon_state="Mountains"
a.density=1
if(71 to 100)
a.icon = 'ground.dmi'
a.density=1



I know how inefficient this probably is I was just trying to think of a way to do it and I thought this would be easiest...
Hiya.

Gotta couple of pointers for you.

the smallest range is a 5 point spread. The largest you use is 30. Because you were clever, and limited it to numbers divisible by five, you can divide all the ranges by five, and reduce that rand(1,100) to rand(1,20). This will keep the chances of each terrain the same.


so you'd have
(1 to 2)
a.icon = 'ground5.dmi'
a.density=0
a.land=1

Now, turf density defaults to 0, so you dont have to explicitly set it. so you can leave that out, and save some clock ticks.

The next thing that you can do to make it more efficient is to learn about lists, and just make a list with x times y elements in it. you know that you need 120x120 turfs, so you just fill in the list with a number or name representing the turf type.

After you do that, then you cycle through the turfs in the world and fill them in, using the list for a reference.

The reason you do it this way is because then you have a list of the turfs, and you can save them easily, or make small changes and then implement them at the best possible times... for example, in animation graphics, you store the next image and rapidly blast it onto the screen, rather than computing it on the fly. This reduces apparent lag.

In response to ThreeFingerPete
you'rem issing what I'm trying to do though hehe, I already have a turf down and what I'm doing is changing the icon and density of the turf (which as default is water)