Modding Help How to check if we stand behind wall or under ceiling

Discussion in 'Starbound Modding' started by tfalmeida91, Mar 27, 2020.

  1. tfalmeida91

    tfalmeida91 Master Chief

    Hi everyone, I'm trying to make a mod where the player cannot stand in sun light.

    I already know how to do the sun light part by checking the current time of day.
    What I need to know is, just like the Beam (to ship or planet) mechanism, unless you are im admin mode, you cannot teleport to your ship if you are in an enclosed space , you may have a ceiling above you, as long as you have a hole on the wall, or you may have a hole on the ceiling.

    How do i know if I'm in an enclosed space?

    Like this:

    This hurts
    Hurt 1.png

    But this doens't

    No hurt 1.png
     
  2. tfalmeida91

    tfalmeida91 Master Chief

    Ok I was able to create something that actually works pretty well for what I want, for those who might come to ask the same:

    Code:
    --this gets the current position of the player
    local pos = mcontroller.position()
    
    --this checks whether the current position is under the ground, returns true if position is in underground layer
    local isUnderground = world.underground(pos)
    
    --this checks whether or not the current position has anything behind it (wall or nothing), returns name of material in case there is one, false in case there's no material, or nil in case theres nothing (for example, map loading)
    local hasWall = world.material(pos, "background")
    
    --this gets the current timeofday (between 0.5 and 1 IS night time, from 0 to 0.5, obviously is daytime)
    local timeOfDay = world.timeOfDay()
    then I just use these for variables to dictate what I want to allow, or not
     
    DrPvtSkittles likes this.

Share This Page