Skip to content
Snippets Groups Projects
Commit 11895eb4 authored by dg's avatar dg
Browse files

table.concatNice for .. nice formating

Sher'tul Fortress rooms name is shown before the zone name


git-svn-id: http://svn.net-core.org/repos/t-engine4@5853 51575b47-30f0-44d4-a5cc-537603b46e54
parent a1d48917
No related branches found
No related tags found
No related merge requests found
......@@ -885,6 +885,47 @@ function _M:import(map, dx, dy, sx, sy, sw, sh)
self.seens(x, y, map.seens(i, j))
self.lites(x, y, map.lites(i, j))
self:updateMap(x, y)
end end
self.changed = true
end
--- Import a map into the current one as an overlay, only replacing defined entities
-- @param map the map to import
-- @param dx coordinate where to import it in the current map
-- @param dy coordinate where to import it in the current map
-- @param sx coordinate where to start importing the map, defaults to 0
-- @param sy coordinate where to start importing the map, defaults to 0
-- @param sw size of the imported map to get, defaults to map size
-- @param sh size of the imported map to get, defaults to map size
function _M:overlay(map, dx, dy, sx, sy, sw, sh)
sx = sx or 0
sy = sy or 0
sw = sw or map.w
sh = sh or map.h
for i = sx, sx + sw - 1 do for j = sy, sy + sh - 1 do
local x, y = dx + i, dy + j
if map.attrs[i + j * map.w] then
self.attrs[x + y * self.w] = self.attrs[x + y * self.w] or {}
table.merge(self.attrs[x + y * self.w], map.attrs[i + j * map.w] or {})
end
for z, e in pairs(map.map[i + j * map.w] or {}) do
self.map[x + y * self.w][z] = map.map[i + j * map.w][z]
if e.move then
e.x = nil e.y = nil e:move(x, y, true)
end
end
if self.room_map then
self.room_map[x] = self.room_map[x] or {}
table.merge(self.room_map[x][y], map.room_map[i][j] or {})
end
self.remembers(x, y, map.remembers(i, j))
self.seens(x, y, map.seens(i, j))
self.lites(x, y, map.lites(i, j))
self:updateMap(x, y)
end end
......
......@@ -275,7 +275,7 @@ function _M:generate(lev, old_lev)
end
end end
self:triggerHook{"mapGeneratorStatic:subgenRegister", mapfile=self.data.map, list=self.subgen}
self:triggerHook{"MapGeneratorStatic:subgenRegister", mapfile=self.data.map, list=self.subgen}
for i = 1, #self.subgen do
local g = self.subgen[i]
......@@ -293,7 +293,11 @@ function _M:generate(lev, old_lev)
)
local ux, uy, dx, dy, subspots = generator:generate(lev, old_lev)
self.map:import(map, g.x, g.y)
if g.overlay then
self.map:overlay(map, g.x, g.y)
else
self.map:import(map, g.x, g.y)
end
table.append(self.spots, subspots)
......
......@@ -28,6 +28,18 @@ function lpeg.anywhere (p)
return lpeg.P{ p + 1 * lpeg.V(1) }
end
function table.concatNice(t, sep, endsep)
if not endsep then return table.concat(t, sep) end
local str = ""
for i, s in ipairs(t) do
if i == #t then str = str..endsep..s
elseif i == 1 then str = s
else str = str..sep..s
end
end
return str
end
function table.min(t)
local m = nil
for _, v in pairs(t) do
......
......@@ -21,7 +21,7 @@ return {
name = "Yiilkgur, the Sher'Tul Fortress",
display_name = function(x, y)
local zn = game.level.map.attrs(x or game.player.x, y or game.player.y, "zonename")
if zn then return "Yiilkgur, the Sher'Tul Fortress ("..zn..")"
if zn then return zn.." (Yiilkgur, the Sher'Tul Fortress)"
else return "Yiilkgur, the Sher'Tul Fortress" end
end,
variable_zone_name = true,
......
......@@ -38,6 +38,9 @@ function _M:init(source)
local recur = false
if not profile.auth or not tonumber(profile.auth.donated) or tonumber(profile.auth.donated) <= 1 then
local donation_features = { "#GOLD#Custom character tiles#WHITE#", "#GOLD#Exploration mode (infinite lives)#WHITE#"}
self:triggerHook{"DonationDialog:features", list=donation_features}
-- First time donation
desc = Textzone.new{width=self.iw, auto_height=true, text=[[Hi, I am Nicolas (DarkGod), the maker of this game.
It is my dearest hope that you find my game enjoyable, and that you will continue to do so for many years to come!
......@@ -45,7 +48,7 @@ It is my dearest hope that you find my game enjoyable, and that you will continu
ToME is free and open-source and will stay that way, but that does not mean I can live without money, so I have come to disturb you here and now to ask for your kindness.
If you feel that the (many) hours you have spent having fun were worth it, please consider making a donation for the future of the game.
Donators are also granted a few special features: #GOLD#Custom character tiles#WHITE# and #GOLD#Exploration mode (infinite lives)#WHITE#.]]}
Donators are also granted a few special features: ]]..table.concatNice(donation_features, ", ", " and ").."."}
else
-- Recurring donation
recur = true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment