Author Topic: Temporarily replacing the player light?  (Read 1570 times)

I would like to temporarily replace the player light (not mount the light, but simply change what light is mounted when the light is turned on) when a specified image is mounted. I have no idea where to start. Can someone help me?

On a related note, how to call the "player light" command in a function?

You can change the light datablock.

Code: [Select]
package ChangeLight
{
   function servercmdLight(%cl)
   {
      Parent::servercmdLight(%cl);
      if(!isObject(%pl = %cl.player) && !isObject(%l = %pl.light)) return;
      if(isObject(%db = %pl.lightDatablock)) %l.setDatablock(%db);
   }
};
activatePackage("ChangeLight");

On a related note, how to call the "player light" command in a function?
The command for the "player light" is
Code: [Select]
serverCmdLight(%client);

Is this on a per-player basis?


I believe that the light is an image and can be mounted or unmounted.

I believe that the light is an image and can be mounted or unmounted.
Indeed it is. How does that change anything?

I believe that the light is an image
Violently untrue. It's an fxLight like all lights.

and can be mounted or unmounted.
Violently true. However the light still exists if you do this.

I have no idea where to start.

I have an add-on on my server that lets you change the light via /setlight [lightnamehere].
http://forum.returntoblockland.com/dlm/viewFile.php?id=555
Additionally, this exists: http://forum.returntoblockland.com/dlm/viewFile.php?id=1393

I suggest looking through the code on those to find what you seek.

As far as making it happen when a specific image is mounted, ajksdfgaskldhvaksd.  I guess you could find another add-on that does 'something' as soon as it's mounted...

As far as making it happen when a specific image is mounted, ajksdfgaskldhvaksd.  I guess you could find another add-on that does 'something' as soon as it's mounted...
That's not the problem. I can do that but I need to do it on a per client basis. One client mounts the image and their light is changed but some other client can still use the default player light.

Actually the link Dglider posted is on a per-client basis, I suggest using it.

Why does this break the light key? It doesn't work with the item either.
Code: [Select]
function lantern_OFF_Image::onFire(%this, %obj, %slot, %client)
{
%client.lanternLightName = lanternLightData;
%obj.schedule(0,"playThread",2,shiftRight);
%obj.schedule(200,"playThread",1,armReadyRight);
%obj.unMountImage(0);
%obj.mountimage(lantern_ON_Image, 0);
serverCmdLight(%client);
}

function lantern_ON_Image::onFire(%this, %obj, %slot, %client)
{
%obj.schedule(0,"playThread",2,shiftRight);
%obj.schedule(200,"playThread",1,armReadyRight);
%obj.unMountImage(0);
%obj.mountimage(lantern_OFF_Image, 0);
serverCmdLight(%client);
%client.lanternLightName = PlayerLight;
}

function serverCmdLight(%client)
{
if(%client.lanternLightName !$= "")
{
%lname = %client.lanternLightName.getName();

PlayerLight.setName(LLightN);
%client.lanternLightName.setName(PlayerLight);
}

Parent::serverCmdLight(%client);

if(%client.lanternLightName !$= "")
{
PlayerLight.setName(%lname);
LLightN.setName(PlayerLight);
}
}

You need to package the serverCmdLight(%client) function.

You need to package the serverCmdLight(%client) function.
Why? I though packages were just for conveniency.

Why? I though packages were just for conveniency.
No, if you want to add something to an already existing function without overwriting it you create a package, and put it in there.
The parent::function will then call the already existing function.

If you create the function outside of a package it overwrites the existing one and the parent::function leads to an error.