• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

How to check if is Night

Fortera Global

Intermediate OT User
Joined
Nov 20, 2015
Messages
1,180
Solutions
2
Reaction score
117
How to check if is night?
The script dont checking correctly:

Lua:
local tibiaTime= getWorldTime()
if(tibiaTime<1435 and tibiaTime>600)then -- is day
elseif(tibiaTime>=1435 and tibiaTime<=600)then -- is night
end

tfs 1.2
 
Solution
I assume it's the same or close to the same for 0.3.7
Here's my custom functions I created.
Lua:
function isDawn()     return getWorldTime() > ((7 * 60) + 0)  and getWorldTime() < ((8 * 60) + 0)  end
function isDay()      return getWorldTime() > ((8 * 60) + 0)  and getWorldTime() < ((22 * 60) + 0) end
function isTwilight() return getWorldTime() > ((22 * 60) + 0) and getWorldTime() < ((23 * 60) + 0) end
function isNight()    return getWorldTime() < ((7 * 00) + 0)  or  getWorldTime() > ((23 * 60) + 0) end
I assume it's the same or close to the same for 0.3.7
Here's my custom functions I created.
Lua:
function isDawn()     return getWorldTime() > ((7 * 60) + 0)  and getWorldTime() < ((8 * 60) + 0)  end
function isDay()      return getWorldTime() > ((8 * 60) + 0)  and getWorldTime() < ((22 * 60) + 0) end
function isTwilight() return getWorldTime() > ((22 * 60) + 0) and getWorldTime() < ((23 * 60) + 0) end
function isNight()    return getWorldTime() < ((7 * 00) + 0)  or  getWorldTime() > ((23 * 60) + 0) end
 
Last edited:
Solution
I assume it's the same or close to the same for 0.3.7
Here's my custom functions I created.
Lua:
function isDusk()     return getWorldTime() > ((7 * 60) + 0)  and getWorldTime() < ((8 * 60) + 0)  end
function isDay()      return getWorldTime() > ((8 * 60) + 0)  and getWorldTime() < ((22 * 60) + 0) end
function isTwilight() return getWorldTime() > ((22 * 60) + 0) and getWorldTime() < ((23 * 60) + 0) end
function isNight()    return getWorldTime() < ((7 * 00) + 0)  or  getWorldTime() > ((23 * 60) + 0) end

what is Twilight ?

we write it on global.lua right?
and for check is:

Lua:
if isNight then
-- night
elseif isDay then
-- day
end
 
I assume it's the same or close to the same for 0.3.7
Here's my custom functions I created.
Lua:
function isDusk()     return getWorldTime() > ((7 * 60) + 0)  and getWorldTime() < ((8 * 60) + 0)  end
function isDay()      return getWorldTime() > ((8 * 60) + 0)  and getWorldTime() < ((22 * 60) + 0) end
function isTwilight() return getWorldTime() > ((22 * 60) + 0) and getWorldTime() < ((23 * 60) + 0) end
function isNight()    return getWorldTime() < ((7 * 00) + 0)  or  getWorldTime() > ((23 * 60) + 0) end

should not one of them have an equal sign?

Lua:
function isDusk()    
return getWorldTime() >= ((7 * 60) + 0)  and getWorldTime() <= ((8 * 60) + 0) 
end


function isNight()   
return getWorldTime() < ((7 * 00) + 0)  or  getWorldTime() > ((23 * 60) + 0)
end
 
what is Twilight ?

we write it on global.lua right?
and for check is:

Lua:
if isNight then
-- night
elseif isDay then
-- day
end
Dawn is when the game is going from dark -> light
Day is when the game is fully bright.
Twilight is when the game is going from light -> dark.
Night is when the game is fully dark.
 
Last edited:
Dusk is when the game is going from dark -> light
Day is when the game is fully bright.
Twilight is when the game is going from light -> dark.
Night is when the game is fully dark.

the code dont need an equal sign or its good?

Lua:
function isDusk()   
return getWorldTime() >= ((7 * 60) + 0)  and getWorldTime() <= ((8 * 60) + 0)
end
function isNight() 
return getWorldTime() < ((7 * 00) + 0)  or  getWorldTime() > ((23 * 60) + 0)
end
 
the code dont need an equal sign or its good?

Lua:
function isDusk()  
return getWorldTime() >= ((7 * 60) + 0)  and getWorldTime() <= ((8 * 60) + 0)
end
function isNight()
return getWorldTime() < ((7 * 00) + 0)  or  getWorldTime() > ((23 * 60) + 0)
end
Test it out if you don't think it's working as you'd like.
 
Back
Top