Page 1 of 1

Change to better support multiple up/downs?

Posted: Fri Jul 30, 2010 12:20 am
by yufra
First off, the more I get into the T-Engine and ToME code the more I appreciate the great work you have done DG. Thanks!

I am working on the first chapter of my Viral Resistance RL (zombie-fallout-ish) and it is going to be set in a military hospital. Modern buildings have multiple staircases throughout the building, and trying to add multiple up/downs and have them link correctly between levels brought me to the following observation: the level.ups and level.downs only contain one position each, and adding additional stairs is not directly supported. This can be traced to engine.Generator.generate, which has the following return signature: startx, starty, endx, endy, spots. These are taken by engine.Zone and dropped into level.ups, level.downs, and level.spots. Is there any interest in having engine.Generator.generate directly return a table ups, a table downs, and a table spots?

Maybe engine.generators.Static could have two additional functions addUp and addDown to populate the tables and also accept the index of the corresponding exit on the connected level? I can try to submit a patch updating the example module first to test it out if you want, and if you like it port ToME over as well.

I believe this would help generalize the API to handle multiple up/downs. Of course, I could just be overlooking the obvious way to handle this. :)

Re: Change to better support multiple up/downs?

Posted: Fri Jul 30, 2010 12:25 am
by darkgod
I kinda thought that spots would be used to store the additional stairs, since it allows to give a type and to force a connectivity check.
Then the module must know what to do with them but in any case that is needed.
And the Static generator knows how to add spots already.
But I am open to suggestions if you think your way is better try it and send a patch :)

Re: Change to better support multiple up/downs?

Posted: Fri Jul 30, 2010 4:58 pm
by yufra
darkgod wrote:I kinda thought that spots would be used to store the additional stairs, since it allows to give a type and to force a connectivity check.
Then the module must know what to do with them but in any case that is needed.
And the Static generator knows how to add spots already.
But I am open to suggestions if you think your way is better try it and send a patch :)
That makes sense, and the only reason I was looking at level.ups and level.downs was the plurality, thinking that you intended to have all of the stairs collected in those variables. Maybe a simple refactor of level.ups (and level.downs) to be a single table instead of a table of currently one table, and renaming the variable to level.up or level.main_up or level.default_up? I will attach a patch for level.default_up. You will have to edit the diff a bit since I did it using file.old versus file and cobbled the multiple files together into one file. Cheers!

Re: Change to better support multiple up/downs?

Posted: Fri Jul 30, 2010 11:43 pm
by darkgod
Done :)