ID:871019   Jul 14 2012, 9:45 pm (Edited on Jul 14 2012, 10:16 pm) Keywords: datum, runtimeerror, src (See the best response by DarkCampainger.) Code: ```mob var Dungeon/d verb CreateDungeon() d = new(50, 50)//////////Dungeon var sizeX // Amount of tiles along the x axis. sizeY // Amount of tiles along the y axis. list/matrix // Two-dimensional matrix containing the tiles. /* New() The arguments define the 'sizeX' and 'sizeY' of the dungeon. The proc automatically creates the 'matrix' based upon those dimensions, and fills it with WALL tiles, surrounded by a single layer of PERMAWALL. */ New(sizeX, sizeY) src.sizeX = max(sizeX, MIN_DUNGEON_SIZE) src.sizeY = max(sizeY, MIN_DUNGEON_SIZE) matrix = new/list(sizeX,sizeY) FillRectangle(PERMAWALL) FillRectangle(WALL, 2, 2, sizeX-1, sizeY-1) proc /* FillRectangle() Fills the 'matrix' from coordinates ('x1', 'y1') up to ('x2', 'y2') with the specified argument 'tile'. Default values for coordinates are 1, 1, sizeX, and sizeY. If any of the coordinates are illegal, the proc stops and nothing is done. */ FillRectangle(tile, x1 = 1, y1 = 1, x2 = src.sizeX, y2 = src.sizeY) if(x1 < 1) return else if(x2 > src.sizeX) return // RED FLAG HERE else if(y1 < 1) return else if(y2 > src.sizeY) return for(var/x = x1, x <= x2, x ++) for(var/y = y1, y <= y2, y ++) matrix[x][y] = tile ``` Problem description: After creating an instance of a /Dungeon, when I try calling that dungeon's FillRectangle(), I get a runtime error: runtime error: Cannot read null.sizeX proc name: FillRectangle (/Dungeon/proc/FillRectangle) source file: Dungeon.dm,58 usr: Gooseheaded (/mob) src: /Dungeon (/Dungeon) call stack: /Dungeon (/Dungeon): FillRectangle("#", 2, 2, 49, 49) /Dungeon (/Dungeon): New(50, 50) Gooseheaded (/mob): CreateDungeon() Line 58 of Dungeon.dm being the line that's commented as "RED FLAG HERE" on the code above. I considered the possibility of the /Dungeon object being disposed by the garbage collector, but that shouldn't be the case -- because I'm making reference to that instance under mob/Dungeon/d. What is going on here, exactly? Why is src null? Thanks in advance!
 Jul 14 2012, 10:08 pm Best response Try removing the src. from the arguments: x2 = src.sizeX, y2 = src.sizeY That can sometimes confuse the compiler, I think. Also, your New() process is mixing up the variables (otherwise it won't apply the minimum values): matrix = new/list(src.sizeX,src.sizeY) // ... FillRectangle(WALL, 2, 2, src.sizeX-1, src.sizeY-1)
 Jul 14 2012, 10:16 pm Removing the 'src' from the arguments fixed it; Thank you very much!