Whats wrong with this?

Place to get help with not working mods / modding interface.
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Whats wrong with this?

Post by ficolas »

Code: Select all

	elseif event.createdentity.name == "flooring" then
		
		if game.gettile(event.createdentity.position.x,event.createdentity.position.y).name=="floor" then
			game.player.character.insert{name="flooring",count=1}
		else
			game.settiles{{position=event.createdentity.position,name="floor"}}
		end
		event.createdentity.destroy()
	--elseif event.createdentity.name == "bridge" then
	--	game.settiles{{position=event.createdentity.position,name="bridge"}}
	--	event.createdentity.destroy()
	end
It should just replace the tile the entity is placed in to a floor entity, but it does weird things, replacing nearby floor tiles with grass.
More extended code
I added game.getplayer().print(game.gettile(event.createdentity.position.x, event.createdentity.position.y).name), and it seems to return grass even when it is not grass.
It does really weird things

Edit:The problem is something with the transitions of tiles, because If I edit a 3x3 instead of a 1x1, it only works weird when used between two diferent tiles (like grass and sand, or dark sand and sand.
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Whats wrong with this?

Post by rk84 »

Do you have something like this in your tile definitions?

Code: Select all

allowed_neighbors = { "grass" }
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Whats wrong with this?

Post by ficolas »

rk84 wrote:Do you have something like this in your tile definitions?

Code: Select all

allowed_neighbors = { "grass" }
No

Code: Select all

data:extend({
   {
    type= "container",
    name= "flooring",
    flags= {"placeable-neutral", "player-creation"},
    collision_box= {{-0, 0}, {0, 0}},
    selection_box= {{-0, 0}, {0, 0}},
    minable= { hardness= 0.2, mining_time= 999, result= "pda" },
    max_health= 150,
    drawing_position= {0.7, 0.12},
	inventory_size=1,
	icon="__F-mod__/resources/icons/pda.png",
    picture=
    {
      filename= "__F-mod__/resources/entity/blank/blank.png",
      width= 32,
      height= 32,
      priority= "extra-high",
      shift = {0, 0}
    }
  },
  
  
	{
		type= "item",
		name= "flooring",
		order= "b-c-a",
		place_result= "flooring",
		stack_size= 64,
		flags= { "goes-to-quickbar" },
		icon="__F-mod__/resources/icons/pda.png"
	},
	
  --[[{
    type= "container",
    name= "bridge",
    flags= {"placeable-neutral", "player-creation"},
    collision_box= {{-0, 0}, {0, 0}},
    selection_box= {{-0, 0}, {0, 0}},
    minable= { hardness= 0.2, mining_time= 999, result= "pda" },
    max_health= 150,
    drawing_position= {0.7, 0.12},
	inventory_size=1,
	icon="__F-mod__/resources/icons/pda.png",
    picture=
    {
      filename= "__F-mod__/resources/entity/blank/blank.png",
      width= 32,
      height= 32,
      priority= "extra-high",
      shift = {0, 0}
    }
  },
  
  
	{
		type= "item",
		name= "bridge",
		order= "b-c-a",
		place_result= "flooring",
		stack_size= 64,
		flags= { "goes-to-quickbar" },
		icon="__F-mod__/resources/icons/pda.png"
	},]]
	
	  {
    type = "tile",
    name = "floor",
    collision_mask = {"ground-tile"},
    layer = 20,
    variants =
    {
      main =
      {
        {
          picture = "__F-mod__/resources/tiles/flooring/flooring.png",
          count = 16,
          size = 1,
        },
      },
      inner_corner =
      {
        picture = "__F-mod__/resources/tiles/flooring/flooring-inner-corner.png",
        count = 8
      },
      outer_corner =
      {
        picture = "__F-mod__/resources/tiles/flooring/flooring-outer-corner.png",
        count = 8
      },
      side =
      {
        picture = "__F-mod__/resources/tiles/flooring/flooring-side.png",
        count = 8
      }
    },
    walking_sound =
    {
      {
        filename = "__base__/sound/walking/grass-01.wav",
        volume = 0.8
      },
      {
        filename = "__base__/sound/walking/grass-02.wav",
        volume = 0.8
      },
      {
        filename = "__base__/sound/walking/grass-03.wav",
        volume = 0.8
      },
      {
        filename = "__base__/sound/walking/grass-04.wav",
        volume = 0.8
      }
    },
    map_color={r=169, g=169, b=169}
  },
  
  -- call it water bridge for it to work with flooring
})
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Whats wrong with this?

Post by ficolas »

I added this:

Code: Select all

allowed_neighbors = { "grass-medium", "grass-dry", "dirt", "dirt-dark", "sand", "sand-dark", "deepwater", "deepwater-green", "water", "water-green", "grass"  }
but still doesnt seem to work
immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: Whats wrong with this?

Post by immibis »

Maybe you need to specify that it's allowed to be next to "floor" as well.
User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: Whats wrong with this?

Post by cube »

If the list of allowed neighbors is empty, everything should be allowed.
I have no idea what I'm talking about.
Post Reply

Return to “Modding help”