Author Topic: Custom light mod not working when the visible distance is below a certain tick?  (Read 2334 times)

so basically a while back heedicalking quickly wrote up a piece of code for me that allowed me to change the player's light datablock. i changed it to the default orange light because its very good for a build my clan was doing. we used it for one of our projects, Red Block Redemption, and it seemed that the light would not work whenever the player would enter the main town or near other light sources (candles inside of the town's buildings).

now when SPO (my clan) is working on gravebreak, a zombie server, the light will not work whenever the slider for visible distance on the fog options is below a certain tick.
whenever i press the light key on my keyboard the light sound turning on and off happens except the light will not mount to my player's hand.
i've tested this with arix it turns out the light wont turn on for him as well, so it isnt a problem on my end.
don't blame heedicalking for being bad at coding, because he had to make this at a moment's notice in like 5 minutes.

Code: [Select]
package CustomLight
{
function serverCmdLight(%client)
{
%l = %client.player.light;
Parent::serverCmdLight(%client);
if(isObject(%client.player.light) && %client.player.light != %l)
{
%client.player.light.delete();
%light = new fxlight()
{
dataBlock = OrangeLight;
enable = true;
iconsize = 1;
player = %client.player;
};
%light.attachToObject(%client.player);
%client.player.light = %light;
}
}
};
activatePackage(CustomLight);



Looks clean to me. Might just be a rendering glitch, try this:

Code: [Select]
package OrangeLight
{
    function servercmdLight(%cl)
    {
        Parent::servercmdLight(%cl);
        if(isObject(%light = %cl.player.light))
        {
            %light.setDatablock($OrangeLight);
            %light.reset();
        }
    }
};
activatePackage("OrangeLight");
$OrangeLight = (isObject(OrangeLight) ? OrangeLight : PlayerLight).getID();

Code: [Select]
package CustomLight
{
   function serverCmdLight(%client)
   {
      %client.light = OrangeLight.getId();
      parent::serverCmdLight(%client);
   }
};
activatePackage(CustomLight);

Try this if the code Xalos posted does not work.

Btw, can't test this so idk if it will work, but this is how I've always done it.
« Last Edit: July 22, 2013, 12:09:50 AM by Wrapperup »

The reason it doesn't show when near other light sources is probably cause blockland thinks the light isn't the player's light, so it acts like brick lights. When there are more than the limit, it stops showing some lights.

Instead, we can change the player light's datablock and it will work correctly.

The reason it doesn't show when near other light sources is probably cause blockland thinks the light isn't the player's light, so it acts like brick lights. When there are more than the limit, it stops showing some lights.

Instead, we can change the player light's datablock and it will work correctly.

Player lights = brick lights