Jump to content

Recommended Posts

Hi - just a quickie,

Is there a way to turn a building's lights on using the game logic? For instance, the military offices? They having tube lights but they're all off? Or is this just because the game is only in the Alpha stage?

Thanks,

Share this post


Link to post
Share on other sites

So there's no way to turn building lights on then?

Share this post


Link to post
Share on other sites

AFAIK they are not technically lights, just part of the buildingmodel.

Share this post


Link to post
Share on other sites

You can create light sources in buildings by placing a Game Logic in the building and putting this in the initialization:

_nul = [this,0.05] execVM "lightSource.sqf";

The second param in that array is the light intensity, you will have to experiment to get the brightness you are looking for.

The "lightsource.sqf" file will look like this:

_light = _this select 0;
_intensity = _this select 1;

_light setPosATL[(getPosATL _light select 0), (getPosATL _light select 1), 1.8];

BIS_lightEmitor01 = "#lightpoint" createVehicleLocal getPosATL _light;  
BIS_lightEmitor01 setLightColor [1, 1, 1];
BIS_lightEmitor01 setLightBrightness _intensity;
BIS_lightEmitor01 setLightAmbient [1,1,1];
BIS_lightEmitor01 lightAttachObject [_light, [0, 0, 0.1]];

The most important param to change in this script is the z-index for SetPosATL. This will determine the height of the light above the floor. I've found that 1.8 is a good height in a single story building. You can also experiment with light color here as well if you want some kind of colored lighting effect.

Good luck.

  • Like 1

Share this post


Link to post
Share on other sites

I am using a 10cm sphere instead of a game logic and that does work, what I want to know is if there is any adjustment to the script to use the objects height in the editor instead of the one set in the script so i can have multiple sources on different floors of a building?

Share this post


Link to post
Share on other sites

I am using a 10cm sphere instead of a game logic and that does work, what I want to know is if there is any adjustment to the script to use the objects height in the editor instead of the one set in the script so i can have multiple sources on different floors of a building?

 

@Aradol, I am quite literally trying to get this script to work as well and am about to try the sphere instead of the logic. As for your issue about multiple floors I am not a coder, so my simple solution would be: 4 floors = 4 scripts. That is:

 

lightSource_gf.sqf (ground floor)

lightSource_1f.sqf (1st floor)

lightSource_2f.sqf (2nd floor)

lightSource_3f.sqf (3rd floor)

 

I am sure I will get shot down by a coder, but as I said I don't know this stuff.

Share this post


Link to post
Share on other sites

*click click bang*  Never repeat code. :)

// _nul = [this,0.05] execVM "lightSource.sqf";
// _nul = [this, 0.05, "1F"] execVM "lightSource.sqf"; // Optional, place on 1st floor.

params ["_light", "_intensity", ["_floor", "GF"]];

_height = switch (_floor) do {
	case "GF": {1.8};
	case "1F": {4.8}; // you'd play around with these numbers to get the right height per floor.
	case "2F": {7.8};
	default {1.8};
};

_light setPosATL[(getPosATL _light select 0), (getPosATL _light select 1), _height];

BIS_lightEmitor01 = "#lightpoint" createVehicleLocal getPosATL _light;  
BIS_lightEmitor01 setLightColor [1, 1, 1];
BIS_lightEmitor01 setLightBrightness _intensity;
BIS_lightEmitor01 setLightAmbient [1,1,1];
BIS_lightEmitor01 lightAttachObject [_light, [0, 0, 0.1]];
  • Like 1

Share this post


Link to post
Share on other sites

Hello kylania. i have problem when run on dedicated server, need other parameters in the script?. Sorry for my bad English. Regards.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×