Chaosforge Forum

  • March 28, 2024, 09:53
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: [1]

Author Topic: How work with generator?  (Read 3633 times)

Equality

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 174
  • Lost Soul
    • View Profile
How work with generator?
« on: May 06, 2013, 07:15 »

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

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

classic module has a string

Code: [Select]
generator.run( generators.gen_tiled )and it works - but not documented at wiki. How do a proper call to generator methods for dungeons-mazes-arenaes and so?
Logged
Once advanced DoomRL player
Find mysterious sword Dragonslayer
Say "Best thing ever found!" and start jumping around...
But he can't get the sword from the ground

yaflhdztioxo

  • Programmer
  • Local Inquisitor
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 298
  • Lost Sole
    • View Profile
Re: How work with generator?
« Reply #1 on: May 06, 2013, 18:23 »

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: [Select]
gen_tiled
gen_maze
gen_caves
gen_caves_2
gen_arena
gen_warehouse
gen_archi
gen_city
gen_single
gen_single_plus
gen_lava

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...
Logged

Equality

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 174
  • Lost Soul
    • View Profile
Re: How work with generator?
« Reply #2 on: May 06, 2013, 22:57 »

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: [Select]
Create = function ()
DoomRL.OnGenerate()
...
well, I want not fully random level... maze looks more interesting. Thanks for hints, I write the next:

Code: [Select]
  Create = function ()
generator.reset()
generator.run( generators.gen_maze )
...

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
« Last Edit: May 06, 2013, 23:43 by Equality »
Logged
Once advanced DoomRL player
Find mysterious sword Dragonslayer
Say "Best thing ever found!" and start jumping around...
But he can't get the sword from the ground

yaflhdztioxo

  • Programmer
  • Local Inquisitor
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 298
  • Lost Sole
    • View Profile
Re: How work with generator?
« Reply #3 on: May 07, 2013, 05:24 »

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.
Logged
Pages: [1]