setWorldLight(level, color)
-- World Light
-- NOTE: if defaultWorldLight is set to true the world light algorithm will
-- be handled in the sources. set it to false to avoid conflicts if you wish
-- to make use of the function setWorldLight(level, color)
defaultWorldLight = false
setWorldLight(level, color)
Check this file
config.lua
Lua:-- World Light -- NOTE: if defaultWorldLight is set to true the world light algorithm will -- be handled in the sources. set it to false to avoid conflicts if you wish -- to make use of the function setWorldLight(level, color) defaultWorldLight = false
Since this function affects everyone, it doesn't make sense to call it every time a player starts a section.I can add this on login.lua on creaturescripts? And how to set dark on game?
Since this function affects everyone, it doesn't make sense to call it every time a player starts a section.
the best place is in a globalevent, like for example onStartup or some repeating event with which you can control the time manually.
You must remember that if you disable the defaultWorldLight, then the day and night cycle will no longer happen, you will have to create your own time system
Who's he? Is he with us right now?Hi! Thank you for this lesson! I use this onStartUp.
He does not need his time, he wants to have constant light throughout the game at, for example, 60%.
I don't want the day to be like this all the time.
tell me how to do it?
Who's he? Is he with us right now?
Because I don't get it at all, so it has to be constant 60% of light but at the other hand not all the time
So maybe you want to reduce max brightness with keeping day-night cycle?
static constexpr uint8_t LIGHT_DAY = 250;
static constexpr uint8_t LIGHT_NIGHT = 40;
Thank you very much!Okay I guess that part is hardcoded:
C++:static constexpr uint8_t LIGHT_DAY = 250; static constexpr uint8_t LIGHT_NIGHT = 40;
forgottenserver/src/game.h at 9dc86d0c0e156417edf725b9a68c89d182511e3b · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
Or you could do it on your own with custom day/night cycle implementation as @Sarah Wesker suggested
But at the beginning you said you want a command (I suppose for admin)
Okay I guess that part is hardcoded:
C++:static constexpr uint8_t LIGHT_DAY = 250; static constexpr uint8_t LIGHT_NIGHT = 40;
forgottenserver/src/game.h at 9dc86d0c0e156417edf725b9a68c89d182511e3b · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
Or you could do it on your own with custom day/night cycle implementation as @Sarah Wesker suggested
But at the beginning you said you want a command (I suppose for admin)
I don't see this function on compat.lua.setWorldLight(level, color)
Check this file
config.lua
Lua:-- World Light -- NOTE: if defaultWorldLight is set to true the world light algorithm will -- be handled in the sources. set it to false to avoid conflicts if you wish -- to make use of the function setWorldLight(level, color) defaultWorldLight = false
Since this function affects everyone, it doesn't make sense to call it every time a player starts a section.
the best place is in a globalevent, like for example onStartup or some repeating event with which you can control the time manually.
You must remember that if you disable the defaultWorldLight, then the day and night cycle will no longer happen, you will have to create your own time system
static constexpr uint8_t LIGHT_DAY = 40;
static constexpr uint8_t LIGHT_NIGHT = 40;
// 1h realtime = 1day worldtime
// 2.5s realtime = 1min worldtime
// worldTime is calculated in minutes
static constexpr int16_t GAME_SUNRISE = 360;
static constexpr int16_t GAME_DAYTIME = 480;
static constexpr int16_t GAME_SUNSET = 1080;
static constexpr int16_t GAME_NIGHTTIME = 1200;
static constexpr float LIGHT_CHANGE_SUNRISE =
static_cast<int>(float(float(LIGHT_DAY - LIGHT_NIGHT) / float(GAME_DAYTIME - GAME_SUNRISE)) * 100) / 100.0f;
static constexpr float LIGHT_CHANGE_SUNSET =
static_cast<int>(float(float(LIGHT_DAY - LIGHT_NIGHT) / float(GAME_NIGHTTIME - GAME_SUNSET)) * 100) / 100.0f;
uint8_t lightLevel = LIGHT_DAY;
uint8_t lightColor = 215;
int16_t worldTime = 0;
static constexpr int16_t GAME_SUNRISE = 360;
static constexpr int16_t GAME_DAYTIME = 480;
static constexpr int16_t GAME_SUNSET = 1080;
static constexpr int16_t GAME_NIGHTTIME = 1200;
These are the values for the times when sunrise, day, sunset and night occur in Tibia. You can also edit this function forgottenserver/src/game.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/game.cpp#L4895) and remove some lines for sunrise and day.C++:static constexpr int16_t GAME_SUNRISE = 360; static constexpr int16_t GAME_DAYTIME = 480; static constexpr int16_t GAME_SUNSET = 1080; static constexpr int16_t GAME_NIGHTTIME = 1200;