How to detect walls

  • ReallyJustDont
    25th Jul 2020 Member 0 Permalink

    I'm creating a new type of ray emitter element with Lua, but it always tends to shoot through walls when I test it out. How do I detect a wall at a certain position (do I need to set a particle there and check if it returns nil)?

  • jacob1
    26th Jul 2020 Developer 0 Permalink
    You can use tpt.get_wallmap for this. To check the wall at a position do tpt.get_wallmap(x/4, y/4). You need to divide by 4 to get the wall coordinates since each wall is 4 large.

    In case you checked the wiki before ... yeah the documentation for this function was entirely missing. I'm not sure why, I thought the legacy api page was complete. I put the missing documentation there now.