ID:149280
 
Ok here is the error it gives me
proc name: AllocateBattleMapRoom (/proc/AllocateBattleMapRoom)
source file: Turfs.dm,45
runtime error: Cannot read null.len

here is the code

turf/grass
icon = 'Turfs.dmi'
icon_state = "grass"
Enter(M/mob)
AllocateBattleMapRoom()

var/list/battlemaps // this is a list of z-levels
var/list/battlemap_roomsinuse
var/battlemap_width
var/battlemap_height
var/const/battlemap_room_width=9
var/const/battlemap_room_height=9

proc/AllocateBattleMapRoom(turf/where)
if(!battlemaps)
battlemap_width=round((world.maxx+1)/(battlemap_room_width+1))
battlemap_height=round((world.maxy+1)/(battlemap_room_height +1))
var/roomx
var/roomy
var/roomz
if(!battlemap_roomsinuse)
battlemap_roomsinuse=list()
var/zindex
this is the error
for(zindex=1,zindex<=battlemaps.len,++zindex)

roomz=battlemaps[zindex]
for(roomy=1,roomy<=battlemap_height,++roomy)
for(roomx=1,roomx<=battlemap_width,++roomx)
if(!("[roomx],[roomy],[roomz]" in battlemap_roomsinuse)) break // this room is free
if(!zindex)
CreateBattleMap(++world.maxz)
roomz=world.maxz
roomx=1
roomy=1
// use turf/where's type to fill in scenery
var/cornerx=(roomx-1)*battlemap_room_width+1
var/cornery=(roomy-1)*battlemap_room_height+1
for(var/turf/T in block(\
locate(cornerx,cornery,roomz),
locate(roomx*battlemap_room_width,roomy*battlemap_room_heigh t,roomz)))
new where.type(T)
//if(hascall(where,"Decorate")) // to decorate a battle map
// this is one of the few really valid uses of :
// where:Decorate(locate(cornerx,cornery,roomz))
// return SW corner of room
var/turf/swcorner=locate(cornerx,cornery,roomz)
battlemap_roomsinuse["[roomx],[roomy],[roomz]"]=swcorner
return swcorner

proc/LeaveBattleMapRoom(turf/T) // T is a turf in the room
var/roomx=round(T.x/(battlemap_room_width+1))+1
var/roomy=round(T.y/(battlemap_room_height+1))+1
battlemap_roomsinuse-="[roomx],[roomy],[T.z]"
// save memory by deleting maps when demand is low
if(T.z==world.maxz && .len<=battlemap_width*battlemap_height*(battlemaps.len-3/ 2))
--world.maxz
battlemaps.Cut(battlemaps.len) // delete the last map

proc/CreateBattleMap(zlevel)
var/i
var/j
var/k
var/turf/T
// draw horizontal walls
for(i=1,i<=battlemap_height,++i)
j=i*battlemap_room_height
k=battlemap_room_width*battlemap_width
for(T in block(locate(1,j,zlevel),locate(k,j,zlevel)))
new /turf/battlemap_wall(T)
// draw vertical walls
for(i=1,i<=battlemap_width,++i)
j=i*battlemap_room_width
k=battlemap_room_height*battlemap_height-1
for(T in block(locate(j,1,zlevel),locate(j,k,zlevel)))
new /turf/battlemap_wall(T)

turf/battlemap_wall
opacity=1
icon='black.dmi'
Enter() return 0

if you see the problem let me know plz
Thrain wrote:
proc/AllocateBattleMapRoom(turf/where)
if(!battlemaps)
battlemap_width=round((world.maxx+1)/(battlemap_room_width+1))
battlemap_height=round((world.maxy+1)/(battlemap_room_height +1))

I think this is the part I messed up in the original code.
Try inserting this line under the if() (indented with the other two lines):
battlemaps=list()

Lummox JR