How to disable automap ina floor? (trying to make labyrinth)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Komag
Posts: 3656
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

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

Post by Komag »

This definitely should be integrated into the random dungeon generator project! :)
Finished Dungeons - complete mods to play
User avatar
Komag
Posts: 3656
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

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

Post 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?
Finished Dungeons - complete mods to play
dasarby
Posts: 28
Joined: Sun Dec 30, 2012 10:46 pm

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

Post 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
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

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

Post by msyblade »

Thank you dasarby, this is sure to be helpful to many modders. You put thought and consideration into it, Much appreciated.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Komag
Posts: 3656
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

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

Post 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! :)
Finished Dungeons - complete mods to play
dasarby
Posts: 28
Joined: Sun Dec 30, 2012 10:46 pm

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

Post 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.
Post Reply