Update tile-material.lua (#2218)

* Update tile-material.lua

* Update changelog.txt

* Update changelog.txt

* Update changelog.txt

* Update tile-material.lua
develop
quarque2 2022-06-20 21:38:37 +02:00 committed by GitHub
parent 88ae50b9ae
commit f33c9bc881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 86 deletions

@ -46,6 +46,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## API ## API
## Lua ## Lua
- ``tile-material``: fix the order of declarations. The ``GetTileMat`` function now returns the material as intended (always returned nil before). Also changed the license info, with permission of the original author.
# 0.47.05-r6 # 0.47.05-r6

@ -1,25 +1,7 @@
-- tile-material: Functions to help retrieve the material for a tile. -- tile-material: Functions to help retrieve the material for a tile.
--[[ --[[
Copyright 2015-2016 Milo Christiansen Original code provided by Milo Christiansen in 2015 under the MIT license. Relicensed under the ZLib license to align with the rest of DFHack, with his permission.
This software is provided 'as-is', without any express or implied warranty. In
no event will the authors be held liable for any damages arising from the use of
this software.
Permission is granted to anyone to use this software for any purpose, including
commercial applications, and to alter it and redistribute it freely, subject to
the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product, an
acknowledgment in the product documentation would be appreciated but is not
required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
]] ]]
local _ENV = mkmodule("tile-material") local _ENV = mkmodule("tile-material")
@ -85,73 +67,6 @@ local function fixedMat(id)
end end
end end
-- BasicMats is a matspec table to pass to GetTileMatSpec or GetTileTypeMat. This particular
-- matspec table covers the common case of returning plant materials for plant tiles and other
-- materials for the remaining tiles.
BasicMats = {
[df.tiletype_material.AIR] = nil, -- Empty
[df.tiletype_material.SOIL] = GetLayerMat,
[df.tiletype_material.STONE] = GetLayerMat,
[df.tiletype_material.FEATURE] = GetFeatureMat,
[df.tiletype_material.LAVA_STONE] = GetLavaStone,
[df.tiletype_material.MINERAL] = GetVeinMat,
[df.tiletype_material.FROZEN_LIQUID] = fixedMat("WATER:NONE"),
[df.tiletype_material.CONSTRUCTION] = GetConstructionMat,
[df.tiletype_material.GRASS_LIGHT] = GetGrassMat,
[df.tiletype_material.GRASS_DARK] = GetGrassMat,
[df.tiletype_material.GRASS_DRY] = GetGrassMat,
[df.tiletype_material.GRASS_DEAD] = GetGrassMat,
[df.tiletype_material.PLANT] = GetShrubMat,
[df.tiletype_material.HFS] = nil, -- Eerie Glowing Pit
[df.tiletype_material.CAMPFIRE] = GetLayerMat,
[df.tiletype_material.FIRE] = GetLayerMat,
[df.tiletype_material.ASHES] = GetLayerMat,
[df.tiletype_material.MAGMA] = nil, -- SMR
[df.tiletype_material.DRIFTWOOD] = GetLayerMat,
[df.tiletype_material.POOL] = GetLayerMat,
[df.tiletype_material.BROOK] = GetLayerMat,
[df.tiletype_material.ROOT] = GetLayerMat,
[df.tiletype_material.TREE] = GetTreeMat,
[df.tiletype_material.MUSHROOM] = GetTreeMat,
[df.tiletype_material.UNDERWORLD_GATE] = nil, -- I guess this is for the gates found in vaults?
}
-- NoPlantMats is a matspec table to pass to GetTileMatSpec or GetTileTypeMat. This particular
-- matspec table will ignore plants, returning layer materials (or nil for trees) instead.
NoPlantMats = {
[df.tiletype_material.SOIL] = GetLayerMat,
[df.tiletype_material.STONE] = GetLayerMat,
[df.tiletype_material.FEATURE] = GetFeatureMat,
[df.tiletype_material.LAVA_STONE] = GetLavaStone,
[df.tiletype_material.MINERAL] = GetVeinMat,
[df.tiletype_material.FROZEN_LIQUID] = fixedMat("WATER:NONE"),
[df.tiletype_material.CONSTRUCTION] = GetConstructionMat,
[df.tiletype_material.GRASS_LIGHT] = GetLayerMat,
[df.tiletype_material.GRASS_DARK] = GetLayerMat,
[df.tiletype_material.GRASS_DRY] = GetLayerMat,
[df.tiletype_material.GRASS_DEAD] = GetLayerMat,
[df.tiletype_material.PLANT] = GetLayerMat,
[df.tiletype_material.CAMPFIRE] = GetLayerMat,
[df.tiletype_material.FIRE] = GetLayerMat,
[df.tiletype_material.ASHES] = GetLayerMat,
[df.tiletype_material.DRIFTWOOD] = GetLayerMat,
[df.tiletype_material.POOL] = GetLayerMat,
[df.tiletype_material.BROOK] = GetLayerMat,
[df.tiletype_material.ROOT] = GetLayerMat,
}
-- OnlyPlantMats is a matspec table to pass to GetTileMatSpec or GetTileTypeMat. This particular
-- matspec table will return nil for any non-plant tile. Plant tiles return the plant material.
OnlyPlantMats = {
[df.tiletype_material.GRASS_LIGHT] = GetGrassMat,
[df.tiletype_material.GRASS_DARK] = GetGrassMat,
[df.tiletype_material.GRASS_DRY] = GetGrassMat,
[df.tiletype_material.GRASS_DEAD] = GetGrassMat,
[df.tiletype_material.PLANT] = GetShrubMat,
[df.tiletype_material.TREE] = GetTreeMat,
[df.tiletype_material.MUSHROOM] = GetTreeMat,
}
-- GetLayerMat returns the layer material for the given tile. -- GetLayerMat returns the layer material for the given tile.
-- AFAIK this will never return nil. -- AFAIK this will never return nil.
function GetLayerMat(x, y, z) function GetLayerMat(x, y, z)
@ -349,6 +264,73 @@ function GetFeatureMat(x, y, z)
return nil return nil
end end
-- BasicMats is a matspec table to pass to GetTileMatSpec or GetTileTypeMat. This particular
-- matspec table covers the common case of returning plant materials for plant tiles and other
-- materials for the remaining tiles.
BasicMats = {
[df.tiletype_material.AIR] = nil, -- Empty
[df.tiletype_material.SOIL] = GetLayerMat,
[df.tiletype_material.STONE] = GetLayerMat,
[df.tiletype_material.FEATURE] = GetFeatureMat,
[df.tiletype_material.LAVA_STONE] = GetLavaStone,
[df.tiletype_material.MINERAL] = GetVeinMat,
[df.tiletype_material.FROZEN_LIQUID] = fixedMat("WATER:NONE"),
[df.tiletype_material.CONSTRUCTION] = GetConstructionMat,
[df.tiletype_material.GRASS_LIGHT] = GetGrassMat,
[df.tiletype_material.GRASS_DARK] = GetGrassMat,
[df.tiletype_material.GRASS_DRY] = GetGrassMat,
[df.tiletype_material.GRASS_DEAD] = GetGrassMat,
[df.tiletype_material.PLANT] = GetShrubMat,
[df.tiletype_material.HFS] = nil, -- Eerie Glowing Pit
[df.tiletype_material.CAMPFIRE] = GetLayerMat,
[df.tiletype_material.FIRE] = GetLayerMat,
[df.tiletype_material.ASHES] = GetLayerMat,
[df.tiletype_material.MAGMA] = nil, -- SMR
[df.tiletype_material.DRIFTWOOD] = GetLayerMat,
[df.tiletype_material.POOL] = GetLayerMat,
[df.tiletype_material.BROOK] = GetLayerMat,
[df.tiletype_material.ROOT] = GetLayerMat,
[df.tiletype_material.TREE] = GetTreeMat,
[df.tiletype_material.MUSHROOM] = GetTreeMat,
[df.tiletype_material.UNDERWORLD_GATE] = nil, -- I guess this is for the gates found in vaults?
}
-- NoPlantMats is a matspec table to pass to GetTileMatSpec or GetTileTypeMat. This particular
-- matspec table will ignore plants, returning layer materials (or nil for trees) instead.
NoPlantMats = {
[df.tiletype_material.SOIL] = GetLayerMat,
[df.tiletype_material.STONE] = GetLayerMat,
[df.tiletype_material.FEATURE] = GetFeatureMat,
[df.tiletype_material.LAVA_STONE] = GetLavaStone,
[df.tiletype_material.MINERAL] = GetVeinMat,
[df.tiletype_material.FROZEN_LIQUID] = fixedMat("WATER:NONE"),
[df.tiletype_material.CONSTRUCTION] = GetConstructionMat,
[df.tiletype_material.GRASS_LIGHT] = GetLayerMat,
[df.tiletype_material.GRASS_DARK] = GetLayerMat,
[df.tiletype_material.GRASS_DRY] = GetLayerMat,
[df.tiletype_material.GRASS_DEAD] = GetLayerMat,
[df.tiletype_material.PLANT] = GetLayerMat,
[df.tiletype_material.CAMPFIRE] = GetLayerMat,
[df.tiletype_material.FIRE] = GetLayerMat,
[df.tiletype_material.ASHES] = GetLayerMat,
[df.tiletype_material.DRIFTWOOD] = GetLayerMat,
[df.tiletype_material.POOL] = GetLayerMat,
[df.tiletype_material.BROOK] = GetLayerMat,
[df.tiletype_material.ROOT] = GetLayerMat,
}
-- OnlyPlantMats is a matspec table to pass to GetTileMatSpec or GetTileTypeMat. This particular
-- matspec table will return nil for any non-plant tile. Plant tiles return the plant material.
OnlyPlantMats = {
[df.tiletype_material.GRASS_LIGHT] = GetGrassMat,
[df.tiletype_material.GRASS_DARK] = GetGrassMat,
[df.tiletype_material.GRASS_DRY] = GetGrassMat,
[df.tiletype_material.GRASS_DEAD] = GetGrassMat,
[df.tiletype_material.PLANT] = GetShrubMat,
[df.tiletype_material.TREE] = GetTreeMat,
[df.tiletype_material.MUSHROOM] = GetTreeMat,
}
-- GetTileMat will return the material of the specified tile as determined by its tile type and the -- GetTileMat will return the material of the specified tile as determined by its tile type and the
-- world geology data, etc. -- world geology data, etc.
-- The returned material should exactly match the material reported by DF except in cases where is -- The returned material should exactly match the material reported by DF except in cases where is