Way to check what tile party is standing on (SOLVED)

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Way to check what tile party is standing on (SOLVED)

Post by akroma222 »

OK, a BIG thanks to minmay,
He was patient enough to endure my barrage of questions and walk me through this (all his scripting here)

Definitions for tiles and objects
(dungeon floor and beach ground used as examples,
these are slightly different because beach ground does not have a floor entity defined (in its original definition) so we dont need to spawn anything with the object "beach_ground_01_tile")
SpoilerShow

Code: Select all

defineObject{
	name = "dungeon_floor_dirt_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=1}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=1}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=1}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=1
            		end
            		self.go:spawn("dungeon_floor_dirt_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "dungeon_floor",
	editorIcon = 192,
	color = {150,150,150,255},
	builder = "dungeon",
	floor = {
		"dungeon_floor_dirt_01_tile", 1,
	},
	ceiling = {
		"dungeon_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 35,
		"dungeon_wall_02", 35,
		"dungeon_wall_drain", 2,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "dungeon_ceiling_shaft",
}

defineObject{
	name = "beach_ground_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=2}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=2}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=2}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=2
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "beach_ground",
	editorIcon = 200,
	color = {150,100,70,255},
	builder = "dungeon",
	floor = {
		"beach_ground_01_tile", 1,
	},
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_01",
	diggable = true,
}
Dont forget to add

Code: Select all

import "mod_assets/scripts/tiles.lua"
to init.lua

A script entity in dungeon named 'tileTableScript' with this pasted into it
SpoilerShow

Code: Select all

tiles = nil

    function moveTileTable()
          -- this wrapper function allows the setTileTable() function to be used from any environment
          -- by using this function instead of setTileTable() directly, you prevent save games from
          -- breaking if there is a reference to the function elsewhere
       tileTableScript.script.setTileTable()
       hudPrint("Table done")
    end

    function setTileTable()
       for l = 1,Dungeon.getMaxLevels() do
          for e in Dungeon.getMap(l):allEntities() do
             if e.destroyMe then e:destroy() end
          end
       end
       tiles = GameMode.tiles
        GameMode.tiles = nil
    end

    delayedCall(self.go.id,0.001,"moveTileTable")

    function getTile(level,x,y)
       if tiles[level] and tiles[level][x] then
          print(tiles[level][x][y])
           return tiles[level][x][y]
        else
            return nil
        end
    end

    --tileTableScript.script.getTile(party.level,party.x,party.y)
This will (for dungeon floor and beach ground) assign these tiles a reference
dungeon floor = 1
beach ground = 2
You can then use

Code: Select all

tileTableScript.script.getTile(party.level,party.x,party.y)
to check what tile the party is standing on,
if the tile has not been defined as above it will return nil,
otherwise it will return the value you assigned it in the object definition

So now, thanks to minmay, we have a way to check our tiles!! Good times :D
Akroma

------------------------------------------------------------------------------------------update

I have done the definitions for all the asset pack tiles as well as Phitt's Mine tiles
If you do not have phitts mine importing into your dungeon then you will need to delete the relevent tiles
SpoilerShow

Code: Select all

defineObject{
	name = "dungeon_floor_dirt_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=1}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=1}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=1}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=1
            		end
            		self.go:spawn("dungeon_floor_dirt_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "dungeon_floor",
	editorIcon = 192,
	color = {150,150,150,255},
	builder = "dungeon",
	floor = {
		"dungeon_floor_dirt_01_tile", 1,
	},
	ceiling = {
		"dungeon_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 35,
		"dungeon_wall_02", 35,
		"dungeon_wall_drain", 2,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "dungeon_ceiling_shaft",
}

defineTile{
	name = "catacomb_floor",
	editorIcon = 192,
	color = {130,130,150,255},
	builder = "dungeon",
	floor = {
		"dungeon_floor_dirt_01_tile", 1,
	},
	ceiling = {
		"catacomb_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 1,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	ceilingShaft = "catacomb_ceiling_shaft",
}

defineObject{
	name = "beach_ground_stones_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=1}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=1}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=1}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=1
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "beach_ground_stones",
	editorIcon = 200,
	color = {150,150,120,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_stones_01",
	floor = {
		"beach_ground_stones_01_tile", 1,
	},
}

------------------------------------------------------------------------------------------------

defineObject{
	name = "dungeon_floor_dirt_01_water_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=2}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=2}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=2}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=2
            		end
            		self.go:spawn("dungeon_floor_dirt_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "dungeon_floor_water",
	editorIcon = 112,
	color = {45,95,140,255},
	builder = "dungeon",
	floor = {
		"dungeon_floor_dirt_01_water_tile", 1,
	},
	ceiling = {
		"dungeon_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 1,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	underwater = true,
	ceilingEdgeVariations = true,
	ceilingShaft = "dungeon_ceiling_shaft",
	automapTile = "water",
}
----------------------------------------------------------------------------------------------

defineObject{
	name = "dungeon_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=3}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=3}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=3}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=3
            		end
            		self.go:spawn("dungeon_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "dungeon_floor_tiles",
	editorIcon = 192,
	color = {110,110,110,255},
	builder = "dungeon",
	randomFloorFacing = true,
	floor = {
		"dungeon_floor_01_tile", 1,
	},
	ceiling = {
		"dungeon_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 35,
		"dungeon_wall_02", 35,
		"dungeon_wall_drain", 2,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "dungeon_ceiling_shaft",
	randomFloorFacing = true,
}

--------------------------------------------------------------------------------------------------------
defineObject{
	name = "tomb_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=4}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=4}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=4}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=4
            		end
            		self.go:spawn("tomb_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineObject{
	name = "tomb_floor_02_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=4}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=4}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=4}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=4
            		end
            		self.go:spawn("tomb_floor_02") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "tomb_floor",
	editorIcon = 112,
	color = {150,132,100,255},
	builder = "dungeon",
	floor = {
		"tomb_floor_01_tile", 1,
		"tomb_floor_02_tile", 1,
	},
	ceiling = {
		"tomb_ceiling_01", 1,
	},
	wall = {
		"tomb_wall_01", 1,
		"tomb_wall_02", 1,
		"tomb_wall_03", 1,
		"tomb_wall_04", 1,
	},
	pillar = {
		"tomb_pillar", 1,
	},
	ceilingShaft = "tomb_ceiling_shaft",
}

------------------------------------------------------------------------------------------------------
defineObject{
	name = "mine_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=5}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=5}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=5}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=5
            		end
            		self.go:spawn("mine_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "mine_floor",
	editorIcon = 192,
	color = {120,120,120,255},
	builder = "dungeon",
	floor = {
		"mine_floor_01_tile", 1,
	},
	ceiling = {
		"mine_ceiling_01", 50,
		"mine_ceiling_02", 50,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	ceilingShaft = "mine_ceiling_shaft",
}

defineObject{
	name = "ph_mine_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=5}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=5}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=5}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=5
            		end
            		self.go:spawn("ph_mine_floor_basic") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
  	name = "ph_mine_floor",
  	editorIcon = 112,
  	color = {110,130,110,255},
  	randomFloorFacing = false,
  	solid = false,
  	builder = "dungeon",
	floor = {
		"ph_mine_floor_01_tile", 1,
	},
	wall = {
		"ph_mine_wall_basic", 10,
	},
	pillar = {
		"mine_support_pillar_01", 1,
		--"old_mine_wood_pillar", 1,
	},
	ceiling = {
		"ph_mine_ceiling_basic", 1,
	},
	automapTile = "ground",
}


defineTile{
  	name = "ph_mine_floor_02",
  	editorIcon = 112,
  	color = {110,130,110,255},
  	randomFloorFacing = false,
  	solid = false,
  	builder = "dungeon",
	floor = {
		"ph_mine_floor_01_tile", 1,
	},
	wall = {
		"ph_mine_wall_rocky_2", 10,
	},
	pillar = {
		"mine_support_pillar_01", 1,
	},
	ceiling = {
		"ph_mine_ceiling_rocky", 1, ---ph_mine_ceiling_rock---
	},
	automapTile = "ground",
}

--------------------------------------------------------------------------------------
defineObject{
	name = "mine_floor_01_crystal_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=6}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=6}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=6}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=6
            		end
            		self.go:spawn("mine_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "mine_floor_crystal",
	editorIcon = 192,
	color = {130,130,150,255},
	builder = "dungeon",
	floor = {
		"mine_floor_01_crystal_tile", 1,
	},
	ceiling = {
		"mine_ceiling_01", 50,
		"mine_ceiling_02", 50,
		"mine_ceiling_03", 7,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	ceilingShaft = "mine_ceiling_shaft",
}
------------------------------------------------------------------------------------

defineObject{
	name = "ph_mine_floor_01_water_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=7}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=7}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=7}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=7
            		end
            		self.go:spawn("ph_mine_floor_basic") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "ph_mine_water",
	editorIcon = 112,
	color = {45,95,140,255},
	builder = "dungeon",
	floor = {
	"ph_mine_floor_01_water_tile", 1,
	},
	ceiling = {
	"ph_mine_ceiling_basic", 1,
	},
	wall = {
	"ph_mine_wall_basic", 1,
	},
	pillar = {
	"mine_support_pillar_01", 1,
	},
	underwater = true,
	ceilingShaft = "dungeon_ceiling_shaft",
	automapTile = "water",
}

defineTile{
  	name = "ph_mine_chasm_water",
  	editorIcon = 112,
  	color = {30,95,140,255}, --- 45,95,140,255 ---
  	builder = "dungeon",
	floor = {
		"ph_mine_floor_01_water_tile", 1,
	},
	ceiling = {
		"ph_mine_ceiling_rock", 1,
	},
	wall = {
		"ph_mine_wall_rocky", 1,
	},
	underwater = true,
	ceilingShaft = "dungeon_ceiling_shaft",
	automapTile = "water",
}


--------------------------------------------------------------------------------------------
defineObject{
	name = "mine_swamp_grass_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=8}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=8}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=8}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=8
            		end
            		self.go:spawn("swamp_grass_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "mine_floor_grass",
	editorIcon = 192,
	color = {50,140,50,255},
	builder = "dungeon",
	heightmapMaterial = "swamp_ground_02",
	floor = {
		"mine_swamp_grass_01_tile", 1,
	},
	ceiling = {
		"mine_moss_ceiling_01", 1,
		"mine_moss_ceiling_02", 1,
		"mine_moss_ceiling_03", 1,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	moveSound = "party_move_grass",
}

defineTile{
	name = "mine_floor_grass_leaves",
	editorIcon = 192, 
	color = {50,110,50,255},
	builder = "dungeon",
	heightmapMaterial = "forest_ground_01",
	floor = {
		"mine_swamp_grass_01_tile", 1,
	},
	ceiling = {
		"mine_moss_ceiling_01", 1,
		"mine_moss_ceiling_02", 1,
		"mine_moss_ceiling_03", 1,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	moveSound = "party_move_grass",
}

--------------------------------------------------------------------------------
defineObject{
	name = "swamp_grass_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=9}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=9}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=9}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=9
            		end
            		self.go:spawn("swamp_grass_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "swamp_ground2",
	editorIcon = 200,
	color = {145,155,35,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "swamp_ground_02",
	diggable = true,
	floor = {
		"swamp_grass_01_tile", 1,
	},
	wall = {
		"forest_elevation_edge", 1,
	},
	moveSound = "party_move_grass",
	automapTile = "grassy_ground",
}

defineObject{
	name = "swamp_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=9}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=9}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=9}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=9
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "swamp_ground",
	editorIcon = 200,
	color = {140,145,90,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "swamp_ground_01",
	diggable = true,
	wall = {
		"forest_elevation_edge", 1,
	},
	automapTile = "grassy_ground",
	floor = {
		"swamp_01_tile", 1,
	},
}
------------------------------------------------------------------------------------------


defineObject{
	name = "forest_ground_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=10}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=10}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=10}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=10
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "forest_ground",
	editorIcon = 200,
	color = {70,150,70,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "forest_ground_01",
	diggable = true,
	moveSound = "party_move_grass",
	automapTile = "grassy_ground",
	floor = {
		"forest_ground_01_tile", 1,
	},
}

defineTile{
	name = "forest_ground2",
	editorIcon = 200,
	color = {140,145,90,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "forest_ground_02",
	heightmapMaterialPriority = -1,
	diggable = true,
	automapTile = "grassy_ground",
	floor = {
		"forest_ground_01_tile", 1,
	},
}
-----------------------------------------------------------------------------------

defineObject{
	name = "forest_trail_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=11}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=11}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=11}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=11
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "forest_trail",
	editorIcon = 200,
	color = {150,100,70,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "forest_trail",
	heightmapMaterialPriority = -1,
	diggable = true,
	automapTile = "grassy_ground",
	floor = {
		"forest_ground_01_tile", 1,
	},
}


---------------------------------------------------------------------------------------

defineObject{
	name = "forest_01_water_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=12}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=12}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=12}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=12
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "forest_underwater",
	editorIcon = 200,
	color = {50,75,115,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "swamp_ground_01",
	wall = {
		"forest_elevation_edge", 1,
	},
	underwater = true,
	automapTile = "water",
	floor = {
		"forest_01_water_tile", 1,
	},
}

----------------------------------------------------------------------------------------------

defineObject{
	name = "beach_ground_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=13}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=13}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=13}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=13
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "beach_ground",
	editorIcon = 200,
	color = {150,100,70,255},
	builder = "dungeon",
	floor = {
		"beach_ground_01_tile", 1,
	},
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_01",
	diggable = true,
}

----------------------------------------------------------------------------------------

defineObject{
	name = "beach_ground_grass_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=14}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=14}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=14}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=14
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "beach_ground_grass",
	editorIcon = 200,
	color = {150,150,70,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_grass_01",
	diggable = true,
	moveSound = "party_move_grass",
	automapTile = "grassy_ground",
	floor = {
		"beach_ground_grass_01_tile", 1,
	},
}


----------------------------------------------------------------------------------------

defineObject{
	name = "beach_ground_01_water_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=15}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=15}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=15}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=15
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "beach_ground_water",
	editorIcon = 200,
	color = {70,100,120,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_01",
	diggable = true,
	moveSound = "party_move_wade",
	automapTile = "water",
	floor = {
		"beach_ground_01_water_tile", 1,
	},
}



---------------------------------------------------------------------------------------------

defineObject{
	name = "castle_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=16}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=16}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=16}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=16
            		end
			self.go:spawn("castle_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}
defineTile{
	name = "castle_floor",
	editorIcon = 192,
	color = {150,160,150,255},
	builder = "dungeon",
	floor = {
		"castle_floor_01_tile", 1,
	},
	ceiling = {
		"castle_ceiling", 1,
	},
	wall = {
		"castle_wall_01", 1,
		"castle_wall_02", 1,
		"castle_wall_03", 1,

	},
	pillar = {
		"castle_pillar_01", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "castle_ceiling_shaft",
	randomFloorFacing = true,
}

defineTile{
	name = "castle_floor_tall",
	editorIcon = 192,
	color = {240,250,240,255},
	builder = "dungeon",
	floor = {
		"castle_floor_01_tile", 1,
	},
	ceiling = {
		"castle_ceiling_tall_01", 1,
	},
	randomFloorFacing = true,
	ceilingShaft = "castle_ceiling_shaft",
}

defineTile{
	name = "castle_arena_floor",
	editorIcon = 192,
	color = {150,150,150,255},
	builder = "dungeon",
	floor = {
		"castle_floor_01_tile", 1,
	},
	randomFloorFacing = true,
}


----------------------------------------------------------------------------------------------
defineObject{
	name = "castle_floor_01_water_tile",
      	--replacesFloor = true,
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=17}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=17}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=17}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=17
            		end
			self.go:spawn("castle_floor_01")
         	 end,
        	},
      	},
      	placement = "floor",
}
defineTile{
	name = "castle_floor_water",
	editorIcon = 192,
	color = {45,95,140,255},
	builder = "dungeon",
	floor = {
		"castle_floor_01_water_tile", 1,
	},
	ceiling = {
		"castle_ceiling", 1,
	},
	wall = {
		"castle_wall_01", 1,
		"castle_wall_02", 1,
		"castle_wall_03", 1,

	},
	pillar = {
		"castle_pillar_01", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "castle_ceiling_shaft",
	underwater = true,
	randomFloorFacing = true,
}
And have added this to the tileTableScript
-getTileStanding (the tile party is standing on)
-getTileFront (tile in front of party)
-list of tile references
(references have been made by -what kind of ground are you standing on?
Are there conditions that separate this ground from similar ground?
Is this tile going to be underwater?? Will it receive sunlight?)
SpoilerShow

Code: Select all

--------------------------	
--dungeon_floor = 1
--catacomb_floor = 1
--beach_ground_stones = 1
--dungeon_floor_water = 2
--dungeon_floor_tiles = 3
--tomb_floor = 4
--mine_floor = 5
--ph_mine_floor = 5
--ph_mine_floor_02 = 5
--mine_floor_crystal = 6
--ph_mine_water = 7
--ph_mine_chasm_water = 7
--mine_floor_grass = 8
--mine_floor_grass_leaves = 8
--swamp_ground2 = 9
--swamp_ground = 9
--forest_ground = 10
--forest_ground2 = 10
--forest_trail = 11
--forest_underwater = 12
--beach_ground = 13
--beach_ground_grass = 14
--beach_ground_water = 15
--castle_floor = 16
--castle_floor_tall = 16
--castle_arena_floor = 16
--castle_floor_water = 17

---------------------------tileTableScript.script.getTileStanding(party.level,party.x,party.y)
---------------------------tileTableScript.script.getTileFront(party.level,party.x,party.y)

tiles = nil

function moveTileTable()
          -- this wrapper function allows the setTileTable() function to be used from any environment
          -- by using this function instead of setTileTable() directly, you prevent save games from
          -- breaking if there is a reference to the function elsewhere
	tileTableScript.script.setTileTable()
    hudPrint("Table done")
end

function setTileTable()
	for l = 1,Dungeon.getMaxLevels() do
    	for e in Dungeon.getMap(l):allEntities() do
        	if e.destroyMe then e:destroy() end
        end
    end
    tiles = GameMode.tiles
    GameMode.tiles = nil
end

delayedCall(self.go.id,0.001,"moveTileTable")

function getTileStanding(level,x,y)
		
    if tiles[level] and tiles[level][x] then
    	print(tiles[level][x][y])
        return tiles[level][x][y]
    else
        return nil
    end
end

function getTileFront(level,x,y)
	local direction = party.facing
	--local elevation = party.elevation
	local dx,dy = getForward(party.facing)
	local x1 = x + dx
	local y1 = y + dy
		
    if tiles[level] and tiles[level][x1] then
    	print(tiles[level][x1][y1])
        return tiles[level][x1][y1]
    else
        return nil
    end
end
------------------------------------------------------------------------------------------------------Original post

Hey folks,
Curious, do we yet have a way to determine what tile we are standing on / is in front of the party??
I ask because I do not want thorn walls to able to be spawned or herbs grown through a castle floor, for example
as such - map:getAutomapTile - will not do the job, I need to be more specific about the tile....

I can see from my dungeon.lua that
SpoilerShow

Code: Select all

newMap{
	name = "Unnamed",
	width = 32,
	height = 32,
	levelCoord = {0,0,1},
	ambientTrack = "ruins",
	tiles = {
		"beach_ground",
		"beach_ground_grass",
		"beach_ground_stones",
		"castle_floor",
		"catacomb_floor",
		"dungeon_floor",
		"dungeon_floor_tiles",
		"dungeon_wall",
		"forest_ground",
		"forest_ground2",
		"forest_trail",
		"mine_floor",
		"mine_floor_crystal",
		"mine_floor_grass",
		"mine_floor_grass_leaves",
		"ph_mine_floor",
		"ph_mine_floor_02",
		"swamp_ground",
		"swamp_ground2",
		"tomb_floor",
	}
}

loadLayer("tiles", {
	1,1,3,3,2,2,4,9,9,10,10,11,11,4,16,16,17,17,20,20,4,8,8,8,8,8,8,8,8,8,8,8,
	1,1,3,3,2,2,4,9,9,10,10,11,11,4,16,16,17,17,20,20,4,8,8,8,8,8,8,8,8,8,8,8,
	1,1,3,3,2,2,4,9,9,10,10,11,11,4,16,16,17,17,20,20,4,8,8,8,8,8,8,8,8,8,8,8,
	4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,8,
	5,5,6,6,7,7,4,12,12,13,13,14,14,15,15,4,18,18,19,19,4,8,8,8,8,8,8,8,8,8,8,8,
	5,5,6,6,7,7,4,12,12,13,13,14,14,15,15,4,18,18,19,19,4,8,8,8,8,8,8,8,8,8,8,8,
	5,5,6,6,7,7,4,12,12,13,13,14,14,15,15,4,18,18,19,19,4,8,8,8,8,8,8,8,8,8,8,8,
the tiles are numbered according to a table (tiles = {}) and those numbers are used when loading the tile layer
(although the same tile can have different numbers in different levels :? :roll: )

Does anyone know if we have a way to detect the name of the tile???

Akroma
Last edited by akroma222 on Fri Mar 27, 2015 7:18 am, edited 4 times in total.
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: Help - Anyway to detect tile type/name? (not automap til

Post by MrChoke »

We do not have access to the tile definitions themselves in-game. I learned that very early on in modding Log2. I wish we had it. If we did, it would make sense to be some function on the Map object.

As you probably know, when you start a game, each tile is processed and converted to GameObjects that are then put into the map. How and what is converted is a combination of the tile definition and the builder used (Dungeon or Mine). So in-game, we can only use what these tiles became (the components created) in order to determine the tiles.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Help - Anyway to detect tile type/name? (not automap til

Post by minmay »

define all tiles with only one floor entity -> there should be one such entity for each tile type, only component needed is a NullComponent -> in that NullComponent's onInit, add a tile identifier to a table in your dungeon, then GameObject:spawn() whatever floor entities you normally would and GameObject:destroyDelayed() -> now you have a table of all tiles without your dungeon changing in any other way, except initialization time at game start will be a bit longer and initialization will consume 1024*levels numeric ids (who cares)

this should be trivial to automatically generate
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Help - Anyway to detect tile type/name? (not automap til

Post by GoldenShadowGS »

Coming at this from another angle. Maybe you can use the same script that digging with the shovel uses. Somehow it knows you can can't dig on non-dirt tiles.

Looks like dig is hard coded, but the tiles have a field named
diggable = true
maybe this could be used?
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Help - Anyway to detect tile type/name? (not automap til

Post by akroma222 »

Ahh thank you guys!
Quick response - I will have a red hot go at this tomorrow....I think the diggable solution is an good way to go
If not I will follow your instructions with the initilizing, minmay
Its been work work moving house and now work sleep, so will report back asap tomorrow :D
Thanks again guys!
Akroma
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Help - Anyway to detect tile type/name? (not automap til

Post by akroma222 »

OK, a BIG thanks to minmay,
He was patient enough to endure my barrage of questions and walk me through this (all his scripting here)

Definitions for tiles and objects
(dungeon floor and beach ground used as examples,
these are slightly different because beach ground does not have a floor entity defined (in its original definition) so we dont need to spawn anything with the object "beach_ground_01_tile")
SpoilerShow

Code: Select all

defineObject{
	name = "dungeon_floor_dirt_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=1}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=1}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=1}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=1
            		end
            		self.go:spawn("dungeon_floor_dirt_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "dungeon_floor",
	editorIcon = 192,
	color = {150,150,150,255},
	builder = "dungeon",
	floor = {
		"dungeon_floor_dirt_01_tile", 1,
	},
	ceiling = {
		"dungeon_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 35,
		"dungeon_wall_02", 35,
		"dungeon_wall_drain", 2,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "dungeon_ceiling_shaft",
}

defineObject{
	name = "beach_ground_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=2}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=2}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=2}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=2
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "beach_ground",
	editorIcon = 200,
	color = {150,100,70,255},
	builder = "dungeon",
	floor = {
		"beach_ground_01_tile", 1,
	},
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_01",
	diggable = true,
}
Dont forget to add

Code: Select all

import "mod_assets/scripts/tiles.lua"
to init.lua

A script entity in dungeon named 'tileTableScript' with this pasted into it
SpoilerShow

Code: Select all

tiles = nil

    function moveTileTable()
          -- this wrapper function allows the setTileTable() function to be used from any environment
          -- by using this function instead of setTileTable() directly, you prevent save games from
          -- breaking if there is a reference to the function elsewhere
       tileTableScript.script.setTileTable()
       hudPrint("Table done")
    end

    function setTileTable()
       for l = 1,Dungeon.getMaxLevels() do
          for e in Dungeon.getMap(l):allEntities() do
             if e.destroyMe then e:destroy() end
          end
       end
       tiles = GameMode.tiles
        GameMode.tiles = nil
    end

    delayedCall(self.go.id,0.001,"moveTileTable")

    function getTile(level,x,y)
       if tiles[level] and tiles[level][x] then
          print(tiles[level][x][y])
           return tiles[level][x][y]
        else
            return nil
        end
    end

    --tileTableScript.script.getTile(party.level,party.x,party.y)
This will (for dungeon floor and beach ground) assign these tiles a reference
dungeon floor = 1
beach ground = 2
You can then use

Code: Select all

tileTableScript.script.getTile(party.level,party.x,party.y)
to check what tile the party is standing on,
if the tile has not been defined as above it will return nil,
otherwise it will return the value you assigned it in the object definition

So now, thanks to minmay, we have a way to check our tiles!! Good times :D
Akroma
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Way to check what tile party is standing on (SOLVED)

Post by Eleven Warrior »

Err what is the point of this imam slow learner yeah?
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Way to check what tile party is standing on (SOLVED)

Post by akroma222 »

Ok, so we can check automap tile easily...
but automap tile values do not give flexibility.

This way we can give tiles our own values to suit our own needs.

For example, one of my spells requires a tile that has dirt / soil / fertile ground to 'grow' herbs
I didnt want people to be able to use this spell inside a castle or somewhere else where that wouldnt make sense...

Akroma ;)
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Way to check what tile party is standing on (SOLVED)

Post by akroma222 »

I have done the definitions for all the asset pack tiles as well as Phitt's Mine tiles
SpoilerShow

Code: Select all

defineObject{
	name = "dungeon_floor_dirt_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=1}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=1}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=1}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=1
            		end
            		self.go:spawn("dungeon_floor_dirt_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "dungeon_floor",
	editorIcon = 192,
	color = {150,150,150,255},
	builder = "dungeon",
	floor = {
		"dungeon_floor_dirt_01_tile", 1,
	},
	ceiling = {
		"dungeon_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 35,
		"dungeon_wall_02", 35,
		"dungeon_wall_drain", 2,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "dungeon_ceiling_shaft",
}

defineTile{
	name = "catacomb_floor",
	editorIcon = 192,
	color = {130,130,150,255},
	builder = "dungeon",
	floor = {
		"dungeon_floor_dirt_01_tile", 1,
	},
	ceiling = {
		"catacomb_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 1,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	ceilingShaft = "catacomb_ceiling_shaft",
}

defineObject{
	name = "beach_ground_stones_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=1}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=1}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=1}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=1
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "beach_ground_stones",
	editorIcon = 200,
	color = {150,150,120,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_stones_01",
	floor = {
		"beach_ground_stones_01_tile", 1,
	},
}

------------------------------------------------------------------------------------------------

defineObject{
	name = "dungeon_floor_dirt_01_water_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=2}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=2}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=2}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=2
            		end
            		self.go:spawn("dungeon_floor_dirt_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "dungeon_floor_water",
	editorIcon = 112,
	color = {45,95,140,255},
	builder = "dungeon",
	floor = {
		"dungeon_floor_dirt_01_water_tile", 1,
	},
	ceiling = {
		"dungeon_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 1,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	underwater = true,
	ceilingEdgeVariations = true,
	ceilingShaft = "dungeon_ceiling_shaft",
	automapTile = "water",
}
----------------------------------------------------------------------------------------------

defineObject{
	name = "dungeon_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=3}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=3}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=3}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=3
            		end
            		self.go:spawn("dungeon_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "dungeon_floor_tiles",
	editorIcon = 192,
	color = {110,110,110,255},
	builder = "dungeon",
	randomFloorFacing = true,
	floor = {
		"dungeon_floor_01_tile", 1,
	},
	ceiling = {
		"dungeon_ceiling", 1,
	},
	wall = {
		"dungeon_wall_01", 35,
		"dungeon_wall_02", 35,
		"dungeon_wall_drain", 2,
	},
	pillar = {
		"dungeon_pillar", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "dungeon_ceiling_shaft",
	randomFloorFacing = true,
}

--------------------------------------------------------------------------------------------------------
defineObject{
	name = "tomb_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=4}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=4}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=4}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=4
            		end
            		self.go:spawn("tomb_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineObject{
	name = "tomb_floor_02_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=4}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=4}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=4}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=4
            		end
            		self.go:spawn("tomb_floor_02") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "tomb_floor",
	editorIcon = 112,
	color = {150,132,100,255},
	builder = "dungeon",
	floor = {
		"tomb_floor_01_tile", 1,
		"tomb_floor_02_tile", 1,
	},
	ceiling = {
		"tomb_ceiling_01", 1,
	},
	wall = {
		"tomb_wall_01", 1,
		"tomb_wall_02", 1,
		"tomb_wall_03", 1,
		"tomb_wall_04", 1,
	},
	pillar = {
		"tomb_pillar", 1,
	},
	ceilingShaft = "tomb_ceiling_shaft",
}

------------------------------------------------------------------------------------------------------
defineObject{
	name = "mine_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=5}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=5}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=5}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=5
            		end
            		self.go:spawn("mine_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "mine_floor",
	editorIcon = 192,
	color = {120,120,120,255},
	builder = "dungeon",
	floor = {
		"mine_floor_01_tile", 1,
	},
	ceiling = {
		"mine_ceiling_01", 50,
		"mine_ceiling_02", 50,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	ceilingShaft = "mine_ceiling_shaft",
}

defineObject{
	name = "ph_mine_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=5}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=5}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=5}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=5
            		end
            		self.go:spawn("ph_mine_floor_basic") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
  	name = "ph_mine_floor",
  	editorIcon = 112,
  	color = {110,130,110,255},
  	randomFloorFacing = false,
  	solid = false,
  	builder = "dungeon",
	floor = {
		"ph_mine_floor_01_tile", 1,
	},
	wall = {
		"ph_mine_wall_basic", 10,
	},
	pillar = {
		"mine_support_pillar_01", 1,
		--"old_mine_wood_pillar", 1,
	},
	ceiling = {
		"ph_mine_ceiling_basic", 1,
	},
	automapTile = "ground",
}


defineTile{
  	name = "ph_mine_floor_02",
  	editorIcon = 112,
  	color = {110,130,110,255},
  	randomFloorFacing = false,
  	solid = false,
  	builder = "dungeon",
	floor = {
		"ph_mine_floor_01_tile", 1,
	},
	wall = {
		"ph_mine_wall_rocky_2", 10,
	},
	pillar = {
		"mine_support_pillar_01", 1,
	},
	ceiling = {
		"ph_mine_ceiling_rocky", 1, ---ph_mine_ceiling_rock---
	},
	automapTile = "ground",
}

--------------------------------------------------------------------------------------
defineObject{
	name = "mine_floor_01_crystal_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=6}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=6}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=6}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=6
            		end
            		self.go:spawn("mine_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "mine_floor_crystal",
	editorIcon = 192,
	color = {130,130,150,255},
	builder = "dungeon",
	floor = {
		"mine_floor_01_crystal_tile", 1,
	},
	ceiling = {
		"mine_ceiling_01", 50,
		"mine_ceiling_02", 50,
		"mine_ceiling_03", 7,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	ceilingShaft = "mine_ceiling_shaft",
}
------------------------------------------------------------------------------------

defineObject{
	name = "ph_mine_floor_01_water_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=7}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=7}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=7}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=7
            		end
            		self.go:spawn("ph_mine_floor_basic") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "ph_mine_water",
	editorIcon = 112,
	color = {45,95,140,255},
	builder = "dungeon",
	floor = {
	"ph_mine_floor_01_water_tile", 1,
	},
	ceiling = {
	"ph_mine_ceiling_basic", 1,
	},
	wall = {
	"ph_mine_wall_basic", 1,
	},
	pillar = {
	"mine_support_pillar_01", 1,
	},
	underwater = true,
	ceilingShaft = "dungeon_ceiling_shaft",
	automapTile = "water",
}

defineTile{
  	name = "ph_mine_chasm_water",
  	editorIcon = 112,
  	color = {30,95,140,255}, --- 45,95,140,255 ---
  	builder = "dungeon",
	floor = {
		"ph_mine_floor_01_water_tile", 1,
	},
	ceiling = {
		"ph_mine_ceiling_rock", 1,
	},
	wall = {
		"ph_mine_wall_rocky", 1,
	},
	underwater = true,
	ceilingShaft = "dungeon_ceiling_shaft",
	automapTile = "water",
}


--------------------------------------------------------------------------------------------
defineObject{
	name = "mine_swamp_grass_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=8}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=8}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=8}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=8
            		end
            		self.go:spawn("swamp_grass_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "mine_floor_grass",
	editorIcon = 192,
	color = {50,140,50,255},
	builder = "dungeon",
	heightmapMaterial = "swamp_ground_02",
	floor = {
		"mine_swamp_grass_01_tile", 1,
	},
	ceiling = {
		"mine_moss_ceiling_01", 1,
		"mine_moss_ceiling_02", 1,
		"mine_moss_ceiling_03", 1,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	moveSound = "party_move_grass",
}

defineTile{
	name = "mine_floor_grass_leaves",
	editorIcon = 192, 
	color = {50,110,50,255},
	builder = "dungeon",
	heightmapMaterial = "forest_ground_01",
	floor = {
		"mine_swamp_grass_01_tile", 1,
	},
	ceiling = {
		"mine_moss_ceiling_01", 1,
		"mine_moss_ceiling_02", 1,
		"mine_moss_ceiling_03", 1,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	moveSound = "party_move_grass",
}

--------------------------------------------------------------------------------
defineObject{
	name = "swamp_grass_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=9}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=9}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=9}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=9
            		end
            		self.go:spawn("swamp_grass_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "swamp_ground2",
	editorIcon = 200,
	color = {145,155,35,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "swamp_ground_02",
	diggable = true,
	floor = {
		"swamp_grass_01_tile", 1,
	},
	wall = {
		"forest_elevation_edge", 1,
	},
	moveSound = "party_move_grass",
	automapTile = "grassy_ground",
}

defineObject{
	name = "swamp_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=9}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=9}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=9}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=9
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "swamp_ground",
	editorIcon = 200,
	color = {140,145,90,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "swamp_ground_01",
	diggable = true,
	wall = {
		"forest_elevation_edge", 1,
	},
	automapTile = "grassy_ground",
	floor = {
		"swamp_01_tile", 1,
	},
}
------------------------------------------------------------------------------------------


defineObject{
	name = "forest_ground_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=10}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=10}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=10}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=10
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "forest_ground",
	editorIcon = 200,
	color = {70,150,70,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "forest_ground_01",
	diggable = true,
	moveSound = "party_move_grass",
	automapTile = "grassy_ground",
	floor = {
		"forest_ground_01_tile", 1,
	},
}

defineTile{
	name = "forest_ground2",
	editorIcon = 200,
	color = {140,145,90,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "forest_ground_02",
	heightmapMaterialPriority = -1,
	diggable = true,
	automapTile = "grassy_ground",
	floor = {
		"forest_ground_01_tile", 1,
	},
}
-----------------------------------------------------------------------------------

defineObject{
	name = "forest_trail_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=11}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=11}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=11}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=11
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "forest_trail",
	editorIcon = 200,
	color = {150,100,70,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "forest_trail",
	heightmapMaterialPriority = -1,
	diggable = true,
	automapTile = "grassy_ground",
	floor = {
		"forest_ground_01_tile", 1,
	},
}


---------------------------------------------------------------------------------------

defineObject{
	name = "forest_01_water_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=12}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=12}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=12}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=12
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "forest_underwater",
	editorIcon = 200,
	color = {50,75,115,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "swamp_ground_01",
	wall = {
		"forest_elevation_edge", 1,
	},
	underwater = true,
	automapTile = "water",
	floor = {
		"forest_01_water_tile", 1,
	},
}

----------------------------------------------------------------------------------------------

defineObject{
	name = "beach_ground_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=13}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=13}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=13}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=13
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "beach_ground",
	editorIcon = 200,
	color = {150,100,70,255},
	builder = "dungeon",
	floor = {
		"beach_ground_01_tile", 1,
	},
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_01",
	diggable = true,
}

----------------------------------------------------------------------------------------

defineObject{
	name = "beach_ground_grass_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=14}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=14}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=14}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=14
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}

defineTile{
	name = "beach_ground_grass",
	editorIcon = 200,
	color = {150,150,70,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_grass_01",
	diggable = true,
	moveSound = "party_move_grass",
	automapTile = "grassy_ground",
	floor = {
		"beach_ground_grass_01_tile", 1,
	},
}


----------------------------------------------------------------------------------------

defineObject{
	name = "beach_ground_01_water_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=15}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=15}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=15}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=15
            		end
         	 end,
        	},
      	},
      	placement = "floor",
}


defineTile{
	name = "beach_ground_water",
	editorIcon = 200,
	color = {70,100,120,255},
	builder = "dungeon",
	-- floor geometry is generated by heightmap
	heightmapMaterial = "beach_ground_01",
	diggable = true,
	moveSound = "party_move_wade",
	automapTile = "water",
	floor = {
		"beach_ground_01_water_tile", 1,
	},
}



---------------------------------------------------------------------------------------------

defineObject{
	name = "castle_floor_01_tile",
      	--replacesFloor = true, -- remove this if the spawned object doesn't have replacesFloor, of course
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=16}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=16}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=16}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=16
            		end
			self.go:spawn("castle_floor_01") -- spawn the desired floor entity
         	 end,
        	},
      	},
      	placement = "floor",
}
defineTile{
	name = "castle_floor",
	editorIcon = 192,
	color = {150,160,150,255},
	builder = "dungeon",
	floor = {
		"castle_floor_01_tile", 1,
	},
	ceiling = {
		"castle_ceiling", 1,
	},
	wall = {
		"castle_wall_01", 1,
		"castle_wall_02", 1,
		"castle_wall_03", 1,

	},
	pillar = {
		"castle_pillar_01", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "castle_ceiling_shaft",
	randomFloorFacing = true,
}

defineTile{
	name = "castle_floor_tall",
	editorIcon = 192,
	color = {240,250,240,255},
	builder = "dungeon",
	floor = {
		"castle_floor_01_tile", 1,
	},
	ceiling = {
		"castle_ceiling_tall_01", 1,
	},
	randomFloorFacing = true,
	ceilingShaft = "castle_ceiling_shaft",
}

defineTile{
	name = "castle_arena_floor",
	editorIcon = 192,
	color = {150,150,150,255},
	builder = "dungeon",
	floor = {
		"castle_floor_01_tile", 1,
	},
	randomFloorFacing = true,
}


----------------------------------------------------------------------------------------------
defineObject{
	name = "castle_floor_01_water_tile",
      	--replacesFloor = true,
      	components = {
        	{
          	class = "Null",
		name = "destroyMe",
          	onInit = function(self)
            		if not GameMode.tiles then
              			GameMode.tiles = {[self.go.level]={[self.go.x]={[self.go.y]=17}}}
            		elseif not GameMode.tiles[self.go.level] then
              			GameMode.tiles[self.go.level] = {[self.go.x]={[self.go.y]=17}}
            		elseif not GameMode.tiles[self.go.level][self.go.x] then
              			GameMode.tiles[self.go.level][self.go.x]={[self.go.y]=17}
            		else
              			GameMode.tiles[self.go.level][self.go.x][self.go.y]=17
            		end
			self.go:spawn("castle_floor_01")
         	 end,
        	},
      	},
      	placement = "floor",
}
defineTile{
	name = "castle_floor_water",
	editorIcon = 192,
	color = {45,95,140,255},
	builder = "dungeon",
	floor = {
		"castle_floor_01_water_tile", 1,
	},
	ceiling = {
		"castle_ceiling", 1,
	},
	wall = {
		"castle_wall_01", 1,
		"castle_wall_02", 1,
		"castle_wall_03", 1,

	},
	pillar = {
		"castle_pillar_01", 1,
	},
	ceilingEdgeVariations = true,
	ceilingShaft = "castle_ceiling_shaft",
	underwater = true,
	randomFloorFacing = true,
}
And have added this to the tileTableScript
-getTileStanding (the tile party is standing on)
-getTileFront (tile in front of party)
-list of tile references
(references have been made by -what kind of ground are you standing on?
Are there conditions that separate this ground from similar ground?
Is this tile going to be underwater?? Will it receive sunlight?)
SpoilerShow

Code: Select all

--------------------------	
--dungeon_floor = 1
--catacomb_floor = 1
--beach_ground_stones = 1
--dungeon_floor_water = 2
--dungeon_floor_tiles = 3
--tomb_floor = 4
--mine_floor = 5
--ph_mine_floor = 5
--ph_mine_floor_02 = 5
--mine_floor_crystal = 6
--ph_mine_water = 7
--ph_mine_chasm_water = 7
--mine_floor_grass = 8
--mine_floor_grass_leaves = 8
--swamp_ground2 = 9
--swamp_ground = 9
--forest_ground = 10
--forest_ground2 = 10
--forest_trail = 11
--forest_underwater = 12
--beach_ground = 13
--beach_ground_grass = 14
--beach_ground_water = 15
--castle_floor = 16
--castle_floor_tall = 16
--castle_arena_floor = 16
--castle_floor_water = 17

---------------------------tileTableScript.script.getTileStanding(party.level,party.x,party.y)
---------------------------tileTableScript.script.getTileFront(party.level,party.x,party.y)

tiles = nil

function moveTileTable()
          -- this wrapper function allows the setTileTable() function to be used from any environment
          -- by using this function instead of setTileTable() directly, you prevent save games from
          -- breaking if there is a reference to the function elsewhere
	tileTableScript.script.setTileTable()
    hudPrint("Table done")
end

function setTileTable()
	for l = 1,Dungeon.getMaxLevels() do
    	for e in Dungeon.getMap(l):allEntities() do
        	if e.destroyMe then e:destroy() end
        end
    end
    tiles = GameMode.tiles
    GameMode.tiles = nil
end

delayedCall(self.go.id,0.001,"moveTileTable")

function getTileStanding(level,x,y)
		
    if tiles[level] and tiles[level][x] then
    	print(tiles[level][x][y])
        return tiles[level][x][y]
    else
        return nil
    end
end

function getTileFront(level,x,y)
	local direction = party.facing
	--local elevation = party.elevation
	local dx,dy = getForward(party.facing)
	local x1 = x + dx
	local y1 = y + dy
		
    if tiles[level] and tiles[level][x1] then
    	print(tiles[level][x1][y1])
        return tiles[level][x1][y1]
    else
        return nil
    end
end
Post Reply