Check tile under entity?

Place to get help with not working mods / modding interface.
User avatar
bloc97
Inserter
Inserter
Posts: 47
Joined: Sat Apr 16, 2016 4:57 am
Contact:

Check tile under entity?

Post by bloc97 »

Is there a function that I can use in the game to check the type of tile under an entity?

I am trying to make an amphibious vehicle faster on land and slower on water, and hovercraft faster on water and slower on land.

Thanks.
Image-Vehicles, Defense, Energy & More!
Image-Keep inventory on death!
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Check tile under entity?

Post by prg »

Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
User avatar
bloc97
Inserter
Inserter
Posts: 47
Joined: Sat Apr 16, 2016 4:57 am
Contact:

Re: Check tile under entity?

Post by bloc97 »

What does this function return? The tile name? Sorry if I didn't see it on the api page, I really looked everywhere.
Image-Vehicles, Defense, Energy & More!
Image-Keep inventory on death!
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Check tile under entity?

Post by daniel34 »

It returns a LuaTile:
Image

See here: http://lua-api.factorio.com/0.12.30/LuaTile.html

To get to the name you would use surface.get_tile(x, y).name.
quick links: log file | graphical issues | wiki
User avatar
bloc97
Inserter
Inserter
Posts: 47
Joined: Sat Apr 16, 2016 4:57 am
Contact:

Re: Check tile under entity?

Post by bloc97 »

Thanks, it worked!, But now I can't find how to change the sprite of a car when it is in water...

Is that even possible to do in control.lua?
Edit: Is it possible to access the sprite table of an already loaded entity?
Image-Vehicles, Defense, Energy & More!
Image-Keep inventory on death!
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Check tile under entity?

Post by daniel34 »

bloc97 wrote:Thanks, it worked!, But now I can't find how to change the sprite of a car when it is in water...

Is that even possible to do in control.lua?
Edit: Is it possible to access the sprite table of an already loaded entity?
I don't think you can change the sprite of an entity after it was loaded in the game, but you could replace that entity with a second entity, identical except it uses another sprite. You would need to change the entity back to its original entity when it goes on land though. Also, if your entity has an inventory, you would need to copy that inventory too.
quick links: log file | graphical issues | wiki
User avatar
bloc97
Inserter
Inserter
Posts: 47
Joined: Sat Apr 16, 2016 4:57 am
Contact:

Re: Check tile under entity?

Post by bloc97 »

Thanks... Though that would be a very "brute force" way... And it could bug easily in multiplayer...
Image-Vehicles, Defense, Energy & More!
Image-Keep inventory on death!
Post Reply

Return to “Modding help”