light

From Minetest Developer Wiki
Jump to: navigation, search

In minetest, light is stored in the nodes.
Sunlight is propagated downwards ({x=0, y=-1, z=0}) and bright light makes the neighbour nodes brighter, it stops if there's a node which doesn't have sunlight_propagates = true in its nodedef or the value becomes 0.


Contents

daylight and nightlight

The param1 value (8 bit) of a node with paramtype "light" carries the information of the light amount.
The lower 4 bits of the param1 value store the so-called daylight.
The upper 4 bits of the param1 value store the so-called nightlight.


sunlight

The sunlight value tells how much light comes from the sun (direct sun light / shadows / caves).
This value is independent of time of day. If daylight is smaller than nightlight or daylight is zero, the sunlight value is daylight, else the daylight may be light from torches because it's set to the maximum of artificial and sunlight, in this case neighbouring nodes need to be searched to find the correct sunlight value.


natural light

The natural light value is the sun light at a specific time. minetest.get_natural_light returns this value, it first possibly searches neighbouring nodes to get the sunlight, then it calculates the value using a time of day value.


artificial light

The artificial light, light emanating from e.g. torches, is the same as the nightlight. minetest.get_artificial_light returns this value; in comparison to simply calculating it yourself (math.floor(param1 / 16)), the function ensures more compatibility.


node light

The function minetest.get_node_light returns the node light, it's the maximum of artificial and natural light. The bigger this value is, the less dark the node and neighbouring nodes look to the player. he less dark the node and neighbouring nodes look to the player.


This article is incomplete.


Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox