transhumandesign / kag-base

King Arthur's Gold base folder.
256 stars 118 forks source link

Dark areas randomly gain light #2013

Open mugg91 opened 2 months ago

mugg91 commented 2 months ago

Description

Place a blob completely closed in underground. Have this code run in its onTick()

    Tile t = getMap().getTile(this.getPosition());
    u16 light = t.light 
    print("light: " + light); 

It will return 0 most of the time but will return a random value up to ~110 every few seconds. Not sure if because of the blob or because of the tile handling.

Maybe related

https://github.com/transhumandesign/kag-base/issues/1966

Additional

Also, when applying this.getSprite().SetLighting(false); in the same onTick(), the sprite will be very bright whereas setting this.getSprite().SetLighting(true); will make it dark as usual. Shouldn't it be the other way around?

Suggestion

Dark areas should remain dark and not randomly gain light.

asumagic commented 2 months ago

Probably solved by staging, but .light no longer works there. Still need to provide a way to compute and access tilemap lighting on the server-side for staging which might be through a new method or using the CMap method to get the "light color" at a position.

The problem being that the server can no longer know about light sources that aren't regular map lighting with staging.

Also, when applying this.getSprite().SetLighting(false); in the same onTick(), the sprite will be very bright whereas setting this.getSprite().SetLighting(true); will make it dark as usual. Shouldn't it be the other way around?

I think this is "intended" and just a peak KAG naming moment. The same thing surprised me with particle code. "Lighting" seems to need to be understood as "affected by lighting", not as "lighting source".

mugg91 commented 2 months ago

I encountered the issue while working on Solar Panel. Thanks to your information @asumagic , I fixed issues that existed with Solar Panel by using getMap().getColorLight() instead of tile.light. The only problem I'm seeing now is that blob emitted light can go through walls. A Solar Panel closed in completely can be powered by receiving light from a Lamp through the wall.