[Request] Make Darkness Writable, Move from Game to Surfaces

Things that already exist in the current mod API
User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

[Request] Make Darkness Writable, Move from Game to Surfaces

Post by Afforess »

What it says on the tin. Darkness should be writable, and darkness should be a per-surface property (so underground surfaces are always partial darkness, for example).

Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: [Request] Make Darkness Writable, Move from Game to Surfaces

Post by Supercheese »

Definitely, this would also be needed if a user-made mod wanted to implement the Space Platform idea, naturally for solar power there it'd always be full brightness.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14150
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Request] Make Darkness Writable, Move from Game to Surfaces

Post by Rseding91 »

daytime, wind_speed, wind_orientation, wind_orientation_change, and peaceful_mode have all been moved to LuaSurface for 0.13.

Darkness is a calculated field based off the daytime and as such isn't writable directly. Simply changing daytime effects darkness.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [Request] Make Darkness Writable, Move from Game to Surfaces

Post by Afforess »

Rseding91 wrote:daytime, wind_speed, wind_orientation, wind_orientation_change, and peaceful_mode have all been moved to LuaSurface for 0.13.

Darkness is a calculated field based off the daytime and as such isn't writable directly.
Fantastic news! You guys rock.
Rseding91 wrote:Simply changing daytime effects darkness.
Simply is an understatement. It took me 160 lines of code. https://github.com/Afforess/Gloom/blob/ ... ght.lua#L4

Also, there is no way to go below 0.14 brightness.

Koub
Global Moderator
Global Moderator
Posts: 7744
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: [Request] Make Darkness Writable, Move from Game to Surfaces

Post by Koub »

1) You made a mistake here :

Code: Select all

 elseif light_level <= 0.62 then
        return 0.6225
should be 0.6725

and I would have written that this way :

Code: Select all

 if light_level <= 0.14 then
        return 0.5
elseif light_level > 0.99
        return 0.8
else return =0.2*light_level+0.55
end
It's much shorter :)
Koub - Please consider English is not my native language.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [Request] Make Darkness Writable, Move from Game to Surfaces

Post by Afforess »

Koub wrote: and I would have written that this way :

Code: Select all

 if light_level <= 0.14 then
        return 0.5
elseif light_level > 0.99
        return 0.8
else return =0.2*light_level+0.55
end
It's much shorter :)
Is that the official formula? I dug around but the wiki didn't have it documented.

Edit: Rseding91 shared it in IRC: http://pastebin.com/raw/cRaYBrUn

Koub
Global Moderator
Global Moderator
Posts: 7744
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: [Request] Make Darkness Writable, Move from Game to Surfaces

Post by Koub »

No I just took your code, noticed that apart from the first and last value, you were just calculating a linear function for every increment of 0.01, so I put that in a formula that basically computes instead of chaining if then elseifs ^^.
Koub - Please consider English is not my native language.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [Request] Make Darkness Writable, Move from Game to Surfaces

Post by Afforess »

Koub wrote:No I just took your code, noticed that apart from the first and last value, you were just calculating a linear function for every increment of 0.01, so I put that in a formula that basically computes instead of chaining if then elseifs ^^.
Nice... I got my numbers from sampling. Was not fun. Turns out your formula actually does match the derived formula from the game too. So congrats.

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: [Request] Make Darkness Writable, Move from Game to Surfaces

Post by ratchetfreak »

Afforess wrote:
Koub wrote:No I just took your code, noticed that apart from the first and last value, you were just calculating a linear function for every increment of 0.01, so I put that in a formula that basically computes instead of chaining if then elseifs ^^.
Nice... I got my numbers from sampling. Was not fun. Turns out your formula actually does match the derived formula from the game too. So congrats.
putting the values in a spreadsheet and making a graph out of it will help seeing those things.

Post Reply

Return to “Already exists”