FANDOM


getBlockLightLevel

Object: world

Gets the light level of the block at the given position.

Variant 1:

var light_level = world.getBlockLightLevel(position);

Variant 2:

var light_level = world.getBlockLightLevel(x,y,z);

Parameters:

position - The block's position.

or

x - The block's x-coordinate;
y - The block's y-coordinate;
z - The block's z-coordinate.

Returns:

light_level - 0 (darkness)..15 (sunlight).


Example

This simple block shows a light level numerically on it side.

System requirements: CustomStuff2 0.11 (Minecraft 1.7.10)

Download CS2_LightMeter.zip

mods\CS2_LightMeter\mod.js

mod.addBlock ( "LightMeter.js", "normal" );
mod.addRecipe( "LightMeter:LightMeter 1", 3, 3,
  ":blockGlassColorless", ":dyeGreen", ":blockGlassColorless",
  ":blockGlassColorless", "minecraft:spider_eye", ":blockGlassColorless",
  ":blockGlassColorless", ":blockGlassColorless", ":blockGlassColorless" );

mods\CS2_LightMeter\blocks\LightMeter.js

name			= "LightMeter";
material		= "glass";
stepSound		= "glass";
creativeTab		= "buildingBlocks";
transparent		= true;
semiTransparent	= false;
opacity			= 0;
tickrate		= 20;
addToCreative[0]= true;
information[0]	= "Shows a light level.";
for ( var i = 0; i < 16; ++i )
{
	drop[i] = "LightMeter:LightMeter 1";
	textureFileYP[i] = textureFileYN[i] = textureFileXP[i] = textureFileXN[i] = textureFileZP[i] = textureFileZN[i] = name + i + ".png";
	onUpdate[i] = "var lvl = world.getBlockLightLevel( position ); if ( lvl < 0 ) lvl = 0; else if ( lvl > 15 ) lvl = 15; world.setBlockMetadata( position, lvl );";
}

mods\CS2_LightMeter\assets\lightmeter\lang\en_US.lang

tile.LightMeter0.name=Light Meter
tile.LightMeter1.name=Light Meter (1)
tile.LightMeter2.name=Light Meter (2)
tile.LightMeter3.name=Light Meter (3)
tile.LightMeter4.name=Light Meter (4)
tile.LightMeter5.name=Light Meter (5)
tile.LightMeter6.name=Light Meter (6)
tile.LightMeter7.name=Light Meter (7)
tile.LightMeter8.name=Light Meter (8)
tile.LightMeter9.name=Light Meter (9)
tile.LightMeter10.name=Light Meter (10)
tile.LightMeter11.name=Light Meter (11)
tile.LightMeter12.name=Light Meter (12)
tile.LightMeter13.name=Light Meter (13)
tile.LightMeter14.name=Light Meter (14)
tile.LightMeter15.name=Light Meter (15)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.