Page 3 of 3

Re: How to disable automap ina floor? (trying to make labyri

Posted: Sat Jan 19, 2013 12:08 pm
by Komag
This definitely should be integrated into the random dungeon generator project! :)

Re: How to disable automap ina floor? (trying to make labyri

Posted: Sat Jan 19, 2013 12:28 pm
by Komag
...but I can't get it to work, I need more clear instructions I think.

I made a script called MazeBuilder, pasted the huge code into it
I made another script called script_entity_1 (didn't name it), and put in:

Code: Select all

maze = MazeBuilder:Create()
maze:Initialize(1, 2, 2, 28, 28)
maze:RandomizeMap()
didn't work, gave error "attempt to call method 'Initialize' (a nil value)" next to line 2
after reading more, and this thread, changed code to:

Code: Select all

maze = MazeBuilder:Create()
MazeBuilder:Initialize(maze,1, 2, 2, 28, 28)
MazeBuilder:RandomizeMap()
didn't work, gave error "attempt to modify a read only value" next to "maze.width = w"

What do I EXACTLY need to do?

Re: How to disable automap ina floor? (trying to make labyri

Posted: Sat Jan 19, 2013 6:50 pm
by dasarby
Komag, try this for your script_entity_1:

Code: Select all

maze = MazeBuilder:Create()
MazeBuilder.Initialize(maze,1, 2, 2, 28, 28)
MazeBuilder.RandomizeMap(maze)
The differences here being the calls to Initialize and RandomizeMap are made using dots (MazeBuilder.Initialize) instead of colons (MazeBuilder:Initialize), also, you need to pass the maze object to RandomizeMap.

For Lua, calling foo:method() is equivalent to calling foo.method(foo), so using the colons here actually passes the script entity to the function calls as the first parameter instead of the maze object.

Initially i wanted the Initialize and Mapping functions to be on the maze object, but tables with methods on them are not savable in LoG, so I had to do it this way.

Edit: and heres a 28x28 random generated map. Took me like a half hour to uncover every cell!
SpoilerShow
Image

Re: How to disable automap ina floor? (trying to make labyri

Posted: Sat Jan 19, 2013 11:03 pm
by msyblade
Thank you dasarby, this is sure to be helpful to many modders. You put thought and consideration into it, Much appreciated.

Re: How to disable automap ina floor? (trying to make labyri

Posted: Sun Jan 20, 2013 12:15 am
by Komag
Ah, it's working.

- I didn't know you needed to carve out the area first (but I guess that makes sense, doesn't it)
- You might consider updating or rewording the setup notes in the script itself as they show:

Code: Select all

--        maze:Initialize(1, 5, 5, 10, 10) -- 10x10 maze located at (5,5)
--  5. By default, all doors will be open.  Set the map to a preset one or a random one:
--        maze:SetMap(mapString)
--        maze:RandomizeMap()
which was confusing to me since I really am not a coder at heart

This is pretty cool, a full maze as large or small as you want, new every time the level is played! :)

Re: How to disable automap ina floor? (trying to make labyri

Posted: Sun Jan 20, 2013 2:57 am
by dasarby
Ah right, thanks Komag. That help text was from a older version (one that works in the editor, but not in an exported map), I've updated the script to the correct usage.