SetWeather: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Complete Lua function catalog
Release 0.1.9 / BUILD264 / Protocol42: availability and download setup; preserve experimental limits
 
(One intermediate revision by the same user not shown)
Line 12: Line 12:
! Name !! Type !! Required !! Description
! Name !! Type !! Required !! Description
|-
|-
| <code>weather</code> || <code>string</code> || yes || One of sunny, cloudy, rain1, rain2, or rain3.
| <code>weather</code> || <code>string</code> || yes || Earlier releases: sunny, cloudy, rain1, rain2 or rain3. From 0.1.9: any canonical name or alias in [[Weather catalog]], including snow, fog and sandstorms; query [[getWeatherTypes]].
|-
|-
| <code>transitionMs</code> || <code>int</code> || no || Transition duration from 0 to 300000 milliseconds. Defaults to 3000; 0 applies an immediate transition.
| <code>transitionMs</code> || <code>int</code> || no || Transition duration from 0 to 300000 milliseconds. Defaults to 3000; 0 applies an immediate transition.
Line 46: Line 46:
[[Category:Server Functions]]
[[Category:Server Functions]]
[[Category:World Functions]]
[[Category:World Functions]]
<!-- weather019:start -->
== Extended weather from 0.1.9 ==
'''Available from 0.1.9. Use matching updated clients and server.'''
This existing API retains its call shape; the catalog is extended, not restricted to five names. See [[Weather]] and [[Weather catalog]]. Server target/revision and client acknowledgement are not proof of the final rendered image. The new presets still require in-game visual qualification; use compatible clients and test late join, indoor areas and returning to ordinary weather.
<!-- weather019:end -->

Latest revision as of 13:29, 20 October 2026

setWeather

Changes the authoritative weather and replicates it to every connected player.

Syntax

bool setWeather(string weather [, int transitionMs = 3000])

Parameters

Name Type Required Description
weather string yes Earlier releases: sunny, cloudy, rain1, rain2 or rain3. From 0.1.9: any canonical name or alias in Weather catalog, including snow, fog and sandstorms; query getWeatherTypes.
transitionMs int no Transition duration from 0 to 300000 milliseconds. Defaults to 3000; 0 applies an immediate transition.

Returns

Returns true when the weather name and transition are accepted; otherwise returns false.

Examples

Example 1

Create a five-second transition into a storm:

if not setWeather("rain3", 5000) then
    outputDebugString("The server rejected the weather change")
end

Example 2

Register a simple sunny-weather command:

addCommandHandler("sunny", function(playerId)
    if setWeather("sunny", 3000) then
        outputChatBox("Clear weather enabled.", playerId)
    end
end)

Notes

  • Available only in server-side resource scripts.
  • The new state is retained for late joiners.
  • A successful change increments the weather revision and triggers onWeatherChange.

Extended weather from 0.1.9

Available from 0.1.9. Use matching updated clients and server.

This existing API retains its call shape; the catalog is extended, not restricted to five names. See Weather and Weather catalog. Server target/revision and client acknowledgement are not proof of the final rendered image. The new presets still require in-game visual qualification; use compatible clients and test late join, indoor areas and returning to ordinary weather.