Page 1 of 1
Check tile under entity?
Posted: Sat Apr 16, 2016 8:01 pm
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.
Re: Check tile under entity?
Posted: Sat Apr 16, 2016 8:08 pm
by prg
Re: Check tile under entity?
Posted: Sun Apr 17, 2016 3:17 pm
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.
Re: Check tile under entity?
Posted: Sun Apr 17, 2016 3:22 pm
by daniel34
It returns a LuaTile:
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.
Re: Check tile under entity?
Posted: Sun Apr 17, 2016 4:17 pm
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?
Re: Check tile under entity?
Posted: Sun Apr 17, 2016 4:25 pm
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.
Re: Check tile under entity?
Posted: Sun Apr 17, 2016 4:29 pm
by bloc97
Thanks... Though that would be a very "brute force" way... And it could bug easily in multiplayer...