Simplest way of making example_module load a static map

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
Kruno
Posts: 4
Joined: Fri Jun 17, 2011 1:56 pm

Simplest way of making example_module load a static map

#1 Post by Kruno »

It is rather late, so I will have to update my post as to what I am really doing a little later.

At this moment I am having issues finding code that loads a single static map from initialisation. The ToME module is long and complex and I haven't really made heads or tails on how it is loading static maps. I have downloaded a module to compare but am not sure it is even using static maps. The documentation on static maps via TileEd, while did explain what the data/maps/[insert_city_name].lua file format is like, so I do not have trouble understanding this.

Main issue is just doing a trivial:

farm.lua (copy/paste from ToME module with modifications):

Code: Select all

defineTile('^', "HARDMOUNTAIN_WALL")
defineTile('#', "HARDWALL")
quickEntity('<', {show_tooltip=true, name='portal back', display='<', color=colors.WHITE, change_level=1, change_zone=game.player.last_wilderness, image="terrain/stone_road1.png", add_displays = {mod.class.Grid.new{image="terrain/worldmap.png"}},}, nil, {type="portal", subtype="back"})
defineTile(".", "GRASS")
defineTile("t", {"TREE","TREE2","TREE3","TREE4","TREE5","TREE6","TREE7","TREE8","TREE9","TREE10","TREE11","TREE12","TREE13","TREE14","TREE15","TREE16","TREE17","TREE18","TREE19","TREE20"})
defineTile('*', "ROCK")
defineTile('~', "FOUNTAIN")
defineTile('-', "FIELDS")
defineTile('_', "COBBLESTONE")

defineTile('2', "HARDWALL", nil, nil, "JEWELRY")
defineTile('4', "HARDWALL", nil, nil, "ALCHEMIST")
defineTile('5', "HARDWALL", nil, nil, "LIBRARY")
defineTile('6', "HARDWALL", nil, nil, "STAVES")

defineTile('@', "GRASS", nil, "SUPREME_ARCHMAGE_LINANIIL")
defineTile('T', "GRASS", nil, "TARELION")

startx = 2
starty = 4

return [[
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^........................................--------^
^...@....................................--------^
^........................................--------^
^........................................ttt.....^
^..........................***...........ttt.....^
^..........................***...................^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]]
and loading it as the default starting map.

Thanks.

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Simplest way of making example_module load a static map

#2 Post by Grey »

This is easy enough to do. If you want a simple example check out Broken Bottle's startingroom (link to my module is in my sig).

1. In data/zones/startingroom/zone.lua I have declared level_scheme = fixed, and under generator defined map = {class = "engine.generator.map.Static", map = "zones/startingroom",}

2. In data/map/zones/ I have a file called startingroom.lua which is essentially the same as the code you have posted.

For your module just make sure that the data/zones/farm/zone.lua file includes generator = { map = {class = "engine.generator.map.Static", map = "zones/farm",}, },

Oh, and you'll also want to make sure that the width and height declared in zone.lua matches your prepared map.

Edit: And I guess I should point out that you'll want each terrain type defined in data/general/grids/basic.lua or wherever you're keeping map tile info.

Edit2: Oh yeah, and you'll want self:changeLevel(1, "farm") declared in class/Game.lua under function_M:newGame()
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

Post Reply