[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,430
  2. Mokerhamer

    Mokerhamer Retired Global Mod

    Joined:
    Aug 6, 2007
    Messages:
    1,764
  3. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,430
    they're released already -.-
     
  4. Mokerhamer

    Mokerhamer Retired Global Mod

    Joined:
    Aug 6, 2007
    Messages:
    1,764
    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
    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
    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
    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:
        [2] = {
           map_name = "Ancient Tomb",
           map_corner = {x = 690, y = 171, z = 11},
           map_exit = {x = 1041, y = 893, z = 9},
           map_size = {96, 96, 3},
           map_spawn_room_radius = 5,
           map_void = {1071},
           map_floor = {412, 419, 420},
           map_time = 60 * 60 * 1000,
           map_shape = {
             [1] = {GEN_TUNNEL, 50, size = {3, 5}, length = {3, 9}},
           },
           borders = {
             [1] = BORDER_TOMB_WALL,
             [2] = BORDER_TOMB_SAND,
             [3] = BORDER_TOMB_SARC
           },
           structures = {
             [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}},
           },
           details = {
             [1] = {chance_per_tile = 10, {1549, 12850, 12852, 12853, 1486}},
             [2] = {chance_per_tile = 10, {12950, 12951, 1481, 1482, 1483, 1484}},
             [3] = {chance_per_tile = 8, {13722, 13723, 13733}}, -- 13724, 13725
             [4] = {chance_per_tile = 60, ARRAY_SMALL_ROCKS}
           },
           hangables = {
           [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}},
           [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}}
           },
           c_cpt = 8,
           chests = {5675, 5676, 13902, 13903},
           chest_dist_from_spawn = 5,
           m_cpt = 20,
           monsterwaves = 20,
           monsters = {
             {"scorpion", 50},
             {"scarab", 30},
             {"ancient scarab", 20},
             {"skeleton", 70},
             {"ghoul", 50},
             {"mummy", 20},
             {"sandstone scorpion", 20},
             {"nerubian", 40},
             {"undead gladiator", 10}
           },
           fc_cpt = 10,
           floorchangers = {
             [1] = {{action = 2, trapdoor = 369, ladder = 1386}, 2},
             [2] = {{action = 3, small = {1405, 1399, 1403, 1401}, big = {1404, 1398, 1402, 1400}, top = {410, 410, 410, 410}, fix = {1061, 0, 0, 1060}}, 2}
           },
         },
    
    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,973
    I still dont get how to get this working, where do I execute
    Code:
    map_demo(map_id, frompos, topos, seed)
    ?
     
  9. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,430
    anywhere - lever, talkaction, movement, whatever
     
  10. LaloHao

    LaloHao Member

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

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,430
    solution which doesn't require LuaJIT:
    Code:
    local dirCommand = {'find ', ' -maxdepth 1 -type f'}
    
    -- Windows compability
    if io.popen("ver"):read("*all"):find("Windows") then
    	dirCommand = {'dir "', '" /b /aa'}
    end
     
  12. LaloHao

    LaloHao Member

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

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,430
    will continue it in october
     
    LaloHao likes this.
  14. silveralol

    silveralol Well-Known Member

    Joined:
    Mar 16, 2010
    Messages:
    1,227
    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,430
    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
    Incredibly cool.
    Very useful to roguelikes dungeons
     
  17. silveralol

    silveralol Well-Known Member

    Joined:
    Mar 16, 2010
    Messages:
    1,227
    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:
    008_gen_lib.lua
    009_gen_cfg.lua
    010_gen_core.lua
    
    also, what the function call the "generation" of maps with these advanced features?
     
  18. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,430
    @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,227
    ~~ thanks zbizu :)
     
    Last edited: Jun 14, 2016
  20. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,430
    @silveralol
    generator related lines are in pre-1.0 style
    don't expect me to spoonfeed you
     

Share This Page