SetTime: Difference between revisions
Jump to navigation
Jump to search
Automatyczna aktualizacja dokumentacji funkcji |
Complete Lua function catalog |
||
| Line 41: | Line 41: | ||
* A successful change triggers <code>onTimeChange</code>. | * A successful change triggers <code>onTimeChange</code>. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:World Functions]] | [[Category:World Functions]] | ||
Latest revision as of 09:55, 15 August 2026
setTime
Changes the authoritative in-game time for all connected players.
Syntax
bool setTime(int hour, int minute [, int day])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
hour |
int |
yes | The hour from 0 to 23. |
minute |
int |
yes | The minute from 0 to 59. |
day |
int |
no | Optional day from 0 to 1000000. The current day is preserved when omitted. |
Returns
Returns true when the new time is accepted; otherwise returns false.
Examples
Example 1
Set evening time while preserving the current day:
if not setTime(20, 15) then
outputDebugString("Could not change world time")
end
Example 2
Set day 4 at sunrise:
setTime(6, 0, 4)
Notes
- Available only in server-side resource scripts.
- Accepted changes are broadcast reliably to current players and included in late-join world state.
- A successful change triggers
onTimeChange.