#Light of a Players Current Room

1 messages · Page 1 of 1 (latest)

reef flax
#

I just want to get the bool of if the lights in the player's current room are enabled or not, I am currently using this player.Room.LightController.LightsEnabled to get that bool but it is not working, in fact, as soon as I try to call this bool I receive a NullReferenceException so what am I meant to use?

near shore
#

room or light controller

#

and when do you do it

reef flax
#

Well to test it I'm just putting it in one of my while loops and logging to the console to see and it appears to be the light controller that is null

near shore
#

room can be null

#

(if player is dead, not fpc or just noclips out)

#

light being null is weird

#

but might be specific rooms

#

or a bug

reef flax
#

Well when I do player.Room it'll return something but once doing player.Room.LightController I get the NullReferenceException

#

Might it be because I am trying to get it in a coroutine?

near shore
#

rq

reef flax
#

I am literally just printing player.Room.LightController that I've just chucked into one of my coroutine while loops

near shore
#

ok

#

@tribal turtle !!

#

public LightsController? LightController => Base.LightControllers.Count > 0 ? LightsController.Get(Base.LightControllers[0]) : null;

#

thats all it rly does

tribal turtle
#

Im 99% sure that this is labapi game version issue now only

near shore
#

ok

#

cool

tribal turtle
#

as this LightController cache assignment has been fixed on master

reef flax
#

Also, I reported is as a bug, as player.Room.AllLightControllers.Any(lights => lights.LightsEnabled) always returns false and it got closed saying that it was fixed on the latest internal version

near shore
#

oh

#

that was the issue then yeah

reef flax
#

And that it should be fixed in the next update, and it has been the next update but the bug is still here

#

The labapi version 0.5.0 is in the steam build right?

tribal turtle
#

As I said, this uses the base-game added caching which is not fixed in this version most likely

#

Ill download some server build and test it real quick if its works there

reef flax
#

Okay, wanted to make sure I had that latest

#

player.Room.AllLightControllers.Count() gave NullReferenceException

tribal turtle
#

Aha

reef flax
#

Aha?

tribal turtle
#

Well let me test it on newest version

#
 LabApi.Features.Console.Logger.Info(player.Room);
 LabApi.Features.Console.Logger.Info(player.Room.AllLightControllers);
 LabApi.Features.Console.Logger.Info(player.Room.AllLightControllers.Count());
#

So it is fixed on master

glacial prawn
#

So until like public beta you cant finish it

reef flax
#

Alright, looks like that'll be commented out for a while then

#

Welp, thank you for the help, I shall work on other things while I wait, I am the man who waits

reef flax
# tribal turtle ```cs LabApi.Features.Console.Logger.Info(player.Room); LabApi.Features.Consol...

So what is the go on this? When will it work, because it's still broken

LabApi.Features.Console.Logger.Info("test");
LabApi.Features.Console.Logger.Info(player.Room != null);
LabApi.Features.Console.Logger.Info(player.Room?.AllLightControllers != null);
LabApi.Features.Console.Logger.Info(player.Room?.AllLightControllers?.Count() != null);```
And it prints test, false, false, false, meaning they are all still null, what's goin on??
random portal
#

do you mean test, true, true, true? false means its not null by the code you gave

#

should be fixed in 14.1 as i tested it and they were working

tribal turtle
#

Public beta server & client

#

Works fine

#

You know its going to be null when the player is not in a room?

#

Or the player is spectator

#

Then the room is null aswell

reef flax
#

I just got off so I'll have to try something later

random portal
#

its possible that your server install was outdated, sometimes steam just doesnt download the updated files

reef flax
#

Oh, I completely forgot about this, basically I have absolutely no clue what was going on because I hadn't changed anything at all and it randomly started to work, and continued to work so I've got no idea what was wrong, but at least it works now