[TFS 1.1] Lua map generator (beta)

Discussion in 'Mods & Lua Functions' started by zbizu, Mar 27, 2015.

  1. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,437
    Likes Received:
    1,328
    Best Answers:
    0
  2. Mokerhamer

    Mokerhamer Retired Global Mod

    Joined:
    Aug 6, 2007
    Messages:
    1,764
    Likes Received:
    33
    Best Answers:
    0
  3. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,437
    Likes Received:
    1,328
    Best Answers:
    0
    they're released already -.-
     
  4. Mokerhamer

    Mokerhamer Retired Global Mod

    Joined:
    Aug 6, 2007
    Messages:
    1,764
    Likes Received:
    33
    Best Answers:
    0
    Excuse me Zbizu, that means i need to update my files :) i was already puzzling with editing ids :p

    I'll redownload and check example.lua... Does it generate houses like your screenshots?
     
  5. Leo32

    Leo32 Getting back into it...

    Joined:
    Sep 21, 2007
    Messages:
    711
    Likes Received:
    109
    Best Answers:
    0
    Damn this is crazy cool.
    Too bad the included example is just a plain old cave with some green floor and water.

    I'd love to get my hands on some custom generators you've already done, must take an incredible amount of time to script a detailed map generator file.
     
  6. Codinablack

    Codinablack Dreamer

    Joined:
    Dec 26, 2013
    Messages:
    1,119
    Likes Received:
    347
    Best Answers:
    0
    He has it as open source on github, its not "generators" its a generator, uses the same code, all you have to do is learn to use the configurations if you want to be able to make something more complex than the example
     
  7. Leo32

    Leo32 Getting back into it...

    Joined:
    Sep 21, 2007
    Messages:
    711
    Likes Received:
    109
    Best Answers:
    0
    I know that, but having an example of detailed / decorated dungeons makes it a lot easier to teach yourself the way it works.

    I've pulled the older generator code from the datapack release:
    https://otland.net/threads/10-40-mystera-5-aka-evorpg-final-release.227200/

    The tomb dungeons are a perfect example of what this can do, and its brilliant.
    If you're a not an lua god, you could still splice the code to create new dungeons using walls and doodads with the same limitations:

    Code (Text):
    1.  
    2.     [2] = {
    3.        map_name = "Ancient Tomb",
    4.        map_corner = {x = 690, y = 171, z = 11},
    5.        map_exit = {x = 1041, y = 893, z = 9},
    6.        map_size = {96, 96, 3},
    7.        map_spawn_room_radius = 5,
    8.        map_void = {1071},
    9.        map_floor = {412, 419, 420},
    10.        map_time = 60 * 60 * 1000,
    11.        map_shape = {
    12.          [1] = {GEN_TUNNEL, 50, size = {3, 5}, length = {3, 9}},
    13.        },
    14.        borders = {
    15.          [1] = BORDER_TOMB_WALL,
    16.          [2] = BORDER_TOMB_SAND,
    17.          [3] = BORDER_TOMB_SARC
    18.        },
    19.        structures = {
    20.          [1] = {chance_per_tile = 30, str = {STRUCTURE_TOMB_I, STRUCTURE_TOMB_II, STRUCTURE_TOMB_III, STRUCTURE_TOMB_IV, STRUCTURE_TOMB_V, STRUCTURE_TOMB_VI, STRUCTURE_TOMB_VII, STRUCTURE_TOMB_VIII, STRUCTURE_TOMB_IX}},
    21.        },
    22.        details = {
    23.          [1] = {chance_per_tile = 10, {1549, 12850, 12852, 12853, 1486}},
    24.          [2] = {chance_per_tile = 10, {12950, 12951, 1481, 1482, 1483, 1484}},
    25.          [3] = {chance_per_tile = 8, {13722, 13723, 13733}}, -- 13724, 13725
    26.          [4] = {chance_per_tile = 60, ARRAY_SMALL_ROCKS}
    27.        },
    28.        hangables = {
    29.        [1] = {chance_per_tile = 150, onwall = {1061, 1064}, d = {12215, 12218, 12220, 1888, 1896, 1898, 13688, 13692, 13695, 13696, 13698, 13700, 13702, 2040, 3944, 1829, 1819}},
    30.        [2] = {chance_per_tile = 150, onwall = {1060, 1064}, d = {12216, 12217, 12219, 1889, 1897, 1899, 13691, 13693, 13694, 13697, 13699, 13701, 13703, 2038, 3946, 1830}}
    31.        },
    32.        c_cpt = 8,
    33.        chests = {5675, 5676, 13902, 13903},
    34.        chest_dist_from_spawn = 5,
    35.        m_cpt = 20,
    36.        monsterwaves = 20,
    37.        monsters = {
    38.          {"scorpion", 50},
    39.          {"scarab", 30},
    40.          {"ancient scarab", 20},
    41.          {"skeleton", 70},
    42.          {"ghoul", 50},
    43.          {"mummy", 20},
    44.          {"sandstone scorpion", 20},
    45.          {"nerubian", 40},
    46.          {"undead gladiator", 10}
    47.        },
    48.        fc_cpt = 10,
    49.        floorchangers = {
    50.          [1] = {{action = 2, trapdoor = 369, ladder = 1386}, 2},
    51.          [2] = {{action = 3, small = {1405, 1399, 1403, 1401}, big = {1404, 1398, 1402, 1400}, top = {410, 410, 410, 410}, fix = {1061, 0, 0, 1060}}, 2}
    52.        },
    53.      },
    54.  
    That sort of thing is really helpful for self-teaching, sadly there are no examples like this with his new generator code.

    So you have to really figure it all out yourself...

    EDIT: I've just re-read the thread.
    New generator code doesn't have any advanced functions like item/decoration detail - yet.

    So with that said, using the code from the Mystera release is going to be better at this point.
     
    Last edited: Aug 1, 2015
    Codinablack likes this.
  8. Sizaro

    Sizaro Well-Known Member

    Joined:
    Aug 20, 2007
    Messages:
    4,972
    Likes Received:
    86
    Best Answers:
    0
    I still dont get how to get this working, where do I execute
    Code (Text):
    1. map_demo(map_id, frompos, topos, seed)
    ?
     
  9. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,437
    Likes Received:
    1,328
    Best Answers:
    0
    anywhere - lever, talkaction, movement, whatever
     
  10. LaloHao

    LaloHao Member

    Joined:
    Sep 14, 2008
    Messages:
    73
    Likes Received:
    12
    Best Answers:
    0
    Theres something strange with the folders on @linux
    Code (Text):
    1.  
    2. ERROR: Failed to load script 'init.lua': LUA ERROR:
    3. unable to open file '/data/map_generator/data/map_generator/config.lua': No such file or directory
    4. stack traceback:
    5.  
    Aparently it's concatenating the folder again, so after changing loader.lua:4 to
    Code (Text):
    1.  
    2. local mapGeneratorDir = ""
    3.  
    It now seems to detect file and get a new error instead
    Code (Text):
    1.  
    2. ERROR: Failed to load script 'init.lua': LUA ERROR:
    3. /data/map_generator/loader.lua:13: attempt to index global 'jit' (a nil value)
    4. stack traceback:
    5.  
    which is
    Code (Text):
    1.  
    2. if jit.os == "Windows" then
    3.    dirCommand = {'dir "', '" /b /aa'}
    4. end
    5.  
    Im gonna keep checking in a little while and update post
    EDIT:
    Commenting this will suffice
    Code (Text):
    1.  
    2. -- if jit.os == "Windows" then
    3. --    dirCommand = {'dir "', '" /b /aa'}
    4. -- end
    5.  
    EDIT2:
    I feel really stupid, thinking this was for otclient, how could it? Anyway, leaving aside that
    This works on arch linux
    Code (Text):
    1.  
    2. ------------------------------
    3. -- Loader config
    4. ------------------------------
    5. local mapGeneratorDir = "data/map_generator/"
    6.  
    7. ------------------------------
    8. -- loader
    9. ------------------------------
    10. dofile(mapGeneratorDir .. 'config.lua')
    11. local prefix = ">> "
    12.  
    13. local dirCommand = {'find ', ' -maxdepth 1 -type f'}
    14.  
    15. local folders = {'core', 'resources', 'mods'}
    16.  
    17. local filesCount = 0
    18. for i = 1, #folders do
    19.    if map_lib_cfg.debugOutput then
    20.      io.write(prefix .. 'Loading ' .. map_lib_cfg.generatorName .. ' ' .. folders[i] .. '... ')
    21.    end
    22.  
    23.    for dir in io.popen(dirCommand[1] .. mapGeneratorDir .. folders[i] .. '/' .. dirCommand[2]):lines() do
    24.      filesCount = filesCount + 1
    25.      dofile(dir)
    26.    end
    27.  
    28.    if map_lib_cfg.debugOutput then
    29.      print(filesCount .. ' file(s) loaded')
    30.    end
    31.    
    32.    filesCount = 0
    33. end
    34.  
     
    Last edited: Aug 6, 2015
  11. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,437
    Likes Received:
    1,328
    Best Answers:
    0
    solution which doesn't require LuaJIT:
    Code (Text):
    1. local dirCommand = {'find ', ' -maxdepth 1 -type f'}
    2.  
    3. -- Windows compability
    4. if io.popen("ver"):read("*all"):find("Windows") then
    5.     dirCommand = {'dir "', '" /b /aa'}
    6. end
     
  12. LaloHao

    LaloHao Member

    Joined:
    Sep 14, 2008
    Messages:
    73
    Likes Received:
    12
    Best Answers:
    0
    Its been a while since your last commit, are you still working on it?
     
  13. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,437
    Likes Received:
    1,328
    Best Answers:
    0
    will continue it in october
     
    LaloHao likes this.
  14. silveralol

    silveralol Well-Known Member

    Joined:
    Mar 16, 2010
    Messages:
    1,269
    Likes Received:
    146
    Best Answers:
    2
    how is the progres?
    edit: I get working it <3
    but I need some news "maps" to be created, advanced stuff, can someone give me it?
     
    Last edited: Sep 6, 2015
  15. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,437
    Likes Received:
    1,328
    Best Answers:
    0
    if you're looking for more advanced generator, check my evo datapack
    it has better autoborder and more features
     
    silveralol likes this.
  16. Marceklos

    Marceklos New Member

    Joined:
    Mar 7, 2008
    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Incredibly cool.
    Very useful to roguelikes dungeons
     
  17. silveralol

    silveralol Well-Known Member

    Joined:
    Mar 16, 2010
    Messages:
    1,269
    Likes Received:
    146
    Best Answers:
    2
    I'm sorry for the time to answer :oops: today I see what you said, then I followed what you said about the datapack, but there is different than the code that you post here, how I can install the code from the datapack ? only copying
    Code (Text):
    1.  
    2. 008_gen_lib.lua
    3. 009_gen_cfg.lua
    4. 010_gen_core.lua
    5.  
    also, what the function call the "generation" of maps with these advanced features?
     
  18. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,437
    Likes Received:
    1,328
    Best Answers:
    0
    @silveralol
    all functions are in core file

    example lever script:
    \data\actions\scripts\dungeon\inst_open.lua
     
    silveralol likes this.
  19. silveralol

    silveralol Well-Known Member

    Joined:
    Mar 16, 2010
    Messages:
    1,269
    Likes Received:
    146
    Best Answers:
    2
    ~~ thanks zbizu :)
     
    Last edited: Jun 14, 2016
  20. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,437
    Likes Received:
    1,328
    Best Answers:
    0
    @silveralol
    generator related lines are in pre-1.0 style
    don't expect me to spoonfeed you
     

Share This Page

Loading...