DoomRL > Modding

How work with generator?

(1/1)

Equality:
Well, old tutorial not actual any more. If I try call


--- Code: --- generator.reset()
generator.generate_caves_dungeon()
--- End code ---
then get an error "generator.lua:21: attempt to index local 'gen' (a nil value)"

classic module has a string


--- Code: ---generator.run( generators.gen_tiled )
--- End code ---
and it works - but not documented at wiki. How do a proper call to generator methods for dungeons-mazes-arenaes and so?

yaflhdztioxo:
Generators have changed significantly.  And they've always been one of the newer, least understood features.  We're doing what we can when we can but the modding community is limited and only a small group of people have shown any interest in documenting things...

That said, you're not completely blind in the Generator department--Shark20061 has documented the functions and written descriptions when possible over at http://doom.chaosforge.org/wiki/Modding:generator_API.  The generators themselves are declarable objects and I don't think anyone has studied them enough to really know how they work.  They are:

--- Code: ---gen_tiled
gen_maze
gen_caves
gen_caves_2
gen_arena
gen_warehouse
gen_archi
gen_city
gen_single
gen_single_plus
gen_lava

--- End code ---

Defining your OWN generators is doable but I honestly don't know much about that.  If you are interested I'll make you a deal--come to IRC and release a mod that showcases level generators and in return I'll help you figure them out with some source diving.  Otherwise you'll have to wait for me or someone else to get round to it...

Equality:
well, it better than nothing )

I try to make a special level (i.e. accessed by red stairs) with some properties (AoD effect for instance) that I need. But totally random as ordinary random level.
First semi-successful attempt was


--- Code: --- Create = function ()
DoomRL.OnGenerate()
...
--- End code ---
well, I want not fully random level... maze looks more interesting. Thanks for hints, I write the next:


--- Code: ---  Create = function ()
generator.reset()
generator.run( generators.gen_maze )
...
--- End code ---

and it works well. But... in both cases (first and last) I get a strange situation - TWO players on map! One is controllable and the second just standing somewhere. But it is a full clone, with same health, same equipment. And if I shoot him, then hurt myself. Well, it's funny but how make a proper 1-player random level? from level create proc.

Added:
understand. I need a not "all-inclusive" function for make layout but not place beings, items and player. Then spawn enemies, set player coordinates, set stairs, add items. All as separate calls. And use level.player for initial positioning

yaflhdztioxo:
For your needs you'll need to break things down and not use the generators or run.

It just so happens that the maze generator offloads most of the work to the maze_dungeon.  So you'd want to call that and whatever other generation functions you want.  You'll have to experiment with what's there.

Navigation

[0] Message Index

Go to full version