Avledet¶
Avledet.version¶
Returns
stringValheim version:
0.221.6
Avledet.delta¶
Returns
number| readonlyThe delta time for this frame
Equivalent to Unity
Time.deltaTime
Avledet.id¶
Returns
Int64| readonlyThe randomly generated server id.
Used primarily for determining ZDO ownership throughout gameplay.
Avledet.nanos¶
Returns
Int64| readonlyThe time in nanoseconds
Avledet.time¶
Returns
number| readonlyThe time in seconds
Equivalent to Unity
Time.time
Avledet.time_multiplier¶
Returns
number| readonlyThe rate at which the server time advances
I cant remember why I created this member, so use with caution
Avledet.world_time¶
Returns
numberThe in-game time which determines the day/night cycle
Avledet.world_time_multiplier¶
Returns
numberThe rate at which the worldTime advances. Setting to a value less than 1 will slow the rate (might have weird client time-skip effects). Setting to a values greater than 1 will speed up the in-game time.
A simple use-case of this is the in-game sleep time-skip, which rapidly progresses the time until morning. See the Sleep mod for more information regarding usages.
Avledet.world_ticks¶
Returns
number| readonlySimilar to world_time but in the scale of C#
DateTime.Ticks
Avledet.day¶
Returns
numberThe current day in the world as an integer
Avledet.time_of_day¶
Returns
numberThe current relative time of day.
An entire cycle is 1800, where a new day starts at 270.
Time of day Start time End time Morning 240 270 Day 270 900 Afternoon 900 1530 Night 1530 240 Can set time of day, which will keep the current day, but switch around the time.
Avledet.is_morning¶
Returns
boolean| readonlyWhether the current time is morning
Avledet.is_day¶
Returns
boolean| readonlyWhether the current time is day
Avledet.is_afternoon¶
Returns
boolean| readonlyWhether the current time is the afternoon
Avledet.is_night¶
Returns
boolean| readonlyWhether the current time is night
Avledet.tomorrow_morning¶
Returns
number| readonlyThe worldTime for the morning time pertaining to the current
day+ 1
Avledet.tomorrow¶
Returns
number| readonlyThe worldTime for the day time pertaining to the current
day+ 1
Avledet.tomorrow_afternoon¶
Returns
number| readonlyThe worldTime for the afternoon time pertaining to the current
day+ 1
Avledet.tomorrow_night¶
Returns
number| readonlyThe worldTime for the nighttime pertaining to the current
day+ 1
Avledet:subscribe(name, cb_func)¶
Subscribe to a game event
The passed function will be called when the event fires
Avledet:subscribe('Enable', function() -- Will be dispatched only once when all plugins are loaded end) Avledet:subscribe('RouteInAll', 'ChatMessage', function(peer, targetZdoid, bytes) -- Will be dispatched whenever a peer calls RoutedRpc that is aimed towards all online peers end)Available event handlers:
Method Dispatched Passthrough Example EnableServer start :material-close: Avledet:subscribe('Enable', function() end)DisableServer stop :material-close: Avledet:subscribe('Disable', function() end)UpdateServer update loop :material-close: Avledet:subscribe('Update', function() end)PeriodicOnce every second :material-close: Avledet:subscribe('Periodic', function() end)ConnectAny peer connects PeerAvledet:subscribe('Connect', function(peer) end)DisconnectAny peer disconnects PeerAvledet:subscribe('Disconnect', function(peer) end)JoinValid peer joins PeerAvledet:subscribe('Join', function(peer) end)QuitValid peer quits PeerAvledet:subscribe('Quit', function(peer) end)RpcIn:material-monitor: :material-arrow-right: :material-server: Peer,...Avledet:subscribe('RpcIn', 'PeerInfo', function(peer, bytes) end)RpcOut:material-server: :material-arrow-right: :material-monitor: Peer,...Avledet:subscribe('RpcOut', 'PeerInfo', function(peer, bytes) end)RouteIn:material-monitor: :material-arrow-right: :material-server: Peer,ZDOID,...Avledet:subscribe('RouteIn', 'SetGlobalKey', function(peer, targetZdoid, key) end)RouteInAll:material-monitor: :material-arrow-right: :material-server: :material-arrow-right: :material-monitor-multiple: Peer,ZDOID,...Avledet:subscribe('RouteInAll', 'DestroyZDO', function(peer, targetZdoid, bytes) end)RouteOut:material-server: :material-arrow-right: :material-monitor: Peer,ZDOID,...Avledet:subscribe('RouteOut', 'SleepStart', function(peer, targetZdoid) end)RouteOutAll:material-server: :material-arrow-right: :material-monitor-multiple: ZDOID,...Avledet:subscribe('RouteOutAll', 'GlobalKeys', function(targetZdoid, keys) end)Routed:material-monitor: :material-arrow-right: :material-server: :material-arrow-right: :material-monitor: Peer-srcPeer-dst,ZDOID,...Avledet:subscribe('RouteOutAll', 'AddItem', function(srcpeer, dstpeer, targetZdoid, item) end)SendServer sends packet Socket,BytesAvledet:subscribe('Send', function(socket, bytes) end)RecvServer receives packet Socket,BytesAvledet:subscribe('Recv', function(socket, bytes) end)POSTEvent-modifier to run after the primary-event Most of the events above are prefix methods like in Harmony. Similarly, there is a
POSTevent that can be called after the major event has taken place. This only applies toRpc<>andRoute<>events (maybe also to some others not listed here).-- Will be ran after the internal PeerInfo has taken place Avledet:subscribe('RpcIn', 'PeerInfo' 'POST', function(peer, bytes) end)Handlers using
POSTcannot be canceled unless otherwise stated (because what would be the point?).