ID:1810562
 
(See the best response by Kaiochao.)
Code:
jp_DungeonRoom

cavern
place()
var/list/all = range(centre,size)
var/list/poss = gen.getAdjacent(centre)
turfs += new gen.floortype(centre)

var/count = round(size**2)
while(count>0 && poss.len)
var/turf/t = pick(poss)
poss-=t
for(var/turf/k in gen.getAdjacent(t))
if(gen.isWall(k))
if(k in all)
if(!(k in poss))
poss+=k
turfs += new gen.floortype(t)
count--

for(var/turf/t in turfs) for(var/turf/t2 in gen.getAdjacent(t)) if(gen.isWall(t2) && !(t2 in border)) border+=t2


turf/Open_World_1/Random_Gen_caves_prior
name = "Caves"
icon = 'Caves2.dmi'
icon_state = "13"
pheight=32
pwidth=32
density=1
Click()
if(src in oview(1))
src.icon = 'Caves2.dmi'
src.icon_state="0";src.density=0
turf
Open_World_1
Bonderies
layer=MOB_LAYER
B1
B2
turf/Open_World_1/Random_Gen_caves
name = "Caves"
icon = 'Caves2.dmi'
icon_state = "13"
autojoin = 13
pheight=32
pwidth=32
density=1
layer=OBJ_LAYER
New()
..()
spawn(10)
if(src.icon_state=="13")
src.density=0
return //13
if(src.icon_state=="7")
src.icon='Caves.dmi'
src.icon_state="ground1"
src.pwidth=32
src.pheight=32
src.density=1
Click()
if(src in oview(1))
src.icon = 'Caves2.dmi'
src.icon_state="0";src.density=0


var/jp_DungeonGenerator/generate = new()//generate = caves()//new()

mob
var
seed=null




mob
verb
caves()
src.client.view="100x100"
generate.setArea(/turf/Open_World_1/Bonderies/B2, /turf/Open_World_1/Bonderies/B1)
generate.setWallType(/turf/Open_World_1/Random_Gen_caves)
generate.setFloorType(/turf/Open_World_1/Random_Gen_caves)
generate.setAllowedRooms(list(/jp_DungeonRoom/cavern))
generate.setNumRooms(3)
generate.setExtraPaths(1)
generate.setMinPathLength(3)
generate.setMaxPathLength(45)
generate.setMinLongPathLength(0)
generate.setLongPathChance(0)
generate.setPathEndChance(100)
generate.setRoomMinSize(4)
generate.setRoomMaxSize(8)
generate.generate()
var/const/EROSION_PROB = 30
var/jp_DungeonRegion/r = generate.out_region
for(var/turf/t in r.getBorder()) if(prob(EROSION_PROB)) new generate.floortype(t)
src.display()

generate.setArea(/turf/Open_World_1/Bonderies/B2, /turf/Open_World_1/Bonderies/B1)


This line is what is currently causing the generator tool to crash, I set B1 at 2,2 and B2 at something like 200,100.


Problem description:

I'm having a devil of a time trying to use jp_DungeonGenerator. The library is exactly what my game needs, a means to randomly generate caves as well as pre-made rooms in the open world cave system. More or less, I want my caves to be similar to the game Terraria's caves. Randomly generated rooms with baddies, resources and loot. Some rooms will be large, others small, and you may need to dig to get from one to another.

Eventually, I want to set an area from 1 corner of the map to another and have all random caverns with like I mentioned, loot, resources and baddies. Right now I'm using the example, from the jp_DungeonGenerator demo to try and create one temporary cavern before I delve into making something more complex.

For testing purposes, I'm making mining as simple as just pressing click(). This click behavior is not refreshing foomer's autojoin library and simply making the turf clicked no longer dense and a particular icon_state. I'm creating the dungeon over the non-autojoining turfs, that being, turfs that will remain the same icon_state whatever the case, and making the dungeon use the autojoining turfs when creating the dungeon.

Anyway, I read through the helpfile and still can't get this baby working. Is there anyone out there that can give me insight on how to use this library, fix my ongoing problem or point me in the direction of an easier library to use?

Here's a link to library: http://www.byond.com/developer/Jp/ jp_DungeonGenerator?tab=related#tab=index
Best response
1. Paste your runtime error(s)!
2. jp_DungeonGenerator.setArea() takes two turf instances, not turf types. This means you might just wrap those types in locate(), or give them tags and use locate().
Runtime errors:

runtime error: Cannot read /turf/Open_World_1/Bonderies/B... (/turf/Open_World_1/Bonderies/B2).z
proc name: check params (/jp_DungeonGenerator/proc/check_params)
source file: jp_DungeonGen.dm,718
usr: Blue (/mob/player/Good/Blue)
src: /jp_DungeonGenerator (/jp_DungeonGenerator)
call stack:
/jp_DungeonGenerator (/jp_DungeonGenerator): check params()
/jp_DungeonGenerator (/jp_DungeonGenerator): generate(null)
Blue (/mob/player/Good/Blue): caves()
runtime error: Cannot execute null.getBorder().
proc name: caves (/mob/verb/caves)
source file: Random Caves.dm,149
usr: Blue (/mob/player/Good/Blue)
src: Blue (/mob/player/Good/Blue)
call stack:
Blue (/mob/player/Good/Blue): caves()
mob
var
seed=null
verb
caves()
//reset()
src.client.view="100x100"
for(var/turf/Open_World_1/Bonderies/B2/B2 in world)
for(var/turf/Open_World_1/Bonderies/B1/B1 in world)
generate.setArea(B2,B1)//(/turf/Open_World_1/Bonderies/B2, /turf/Open_World_1/Bonderies/B1)
generate.setWallType(/turf/Open_World_1/Random_Gen_caves)
generate.setFloorType(/turf/Open_World_1/Random_Gen_caves)
generate.setAllowedRooms(list(/jp_DungeonRoom/cavern))
generate.setNumRooms(3)
generate.setExtraPaths(1)
generate.setMinPathLength(3) //3
generate.setMaxPathLength(45) //45
generate.setMinLongPathLength(0)
generate.setLongPathChance(0)
generate.setPathEndChance(100)
generate.setRoomMinSize(4)
generate.setRoomMaxSize(8)
generate.generate()
var/const/EROSION_PROB = 30
var/jp_DungeonRegion/r = generate.out_region
for(var/turf/t in r.getBorder()) if(prob(EROSION_PROB)) new generate.floortype(t)
//var/turf/t
src.display()


I was able to make a small 2x2 popup this time around.
Results:
Number of rooms generated: 3
Number of paths generated: 0
Number of long paths generated: 0
Error string: Maximum iterations was reached while ensuring connectivity. No guarantees can be made about reachability. This dungeon is likely unusable
Time taken: 0 seconds
Random seed used: 54715
Rooms generated:
/jp_DungeonRoom/cavern: 3
Yeah, I'm currently only spawning circles. Which is better than nothing, but, still, circles.
Yeah, no matter which of jp's demos I use, I just make rooms, no paths.
Problem solved: Paths cannot be made if the floor type and the wall type match one another. Also, generating a new "Floor Turf" rather than permanently changing a turf works better with foomer's autojoining library.