π Details
Version: 1.14.0
β Installation
Check out the documentation for information on how to install and use Noir in your addon.
π¬ Description
A decently large update update, woohoo.
Additions
-
Added
OnSit
andOnUnsit
events to thePlayerService
. -
The project manager tool now adds example services and libraries.
-
Added an
OnBodyDamage
event to theVehicleService
. AnOnDamage
event has been added to theNoirBody
class too. As the name suggests, this event is fired when the body takes damage. -
Added
:SpawnExplosion()
method to theObjectService
. This method doesn't return an object, just purely spawns an explosion. -
RecognizedIDs
inPlayerService
'sg_savedata
table is now cleared when players are loaded to preventg_savedata
build-up. -
Added a task types system to the
TaskService
. This allows you to create tasks that trigger differently. For example, time tasks are triggered byserver.getTimeMillisec()
, while tick tasks are triggered by total ticks. This additions comes with new methods::SecondsToTicks()
,:TicksToSeconds()
,:AddTimeTask()
and:AddTickTask()
. Unfortunately, this addition deprecates:AddTask()
which will be removed in a future update, please use:AddTimeTask()
instead.Rule of thumb: For precision, use
:AddTickTask()
. For time accuracy, use:AddTimeTask()
.It is also important you use the new
DeltaTicks
attribute ofTaskService
in calculations in tasks being ran in a task that uses ticks to account for time speeding up (eg: when all players sleep).
local last = Noir.Services.TaskService:GetTimeSeconds()
local time = 0
Noir.Services.TaskService:AddTickTask(function()
local now = Noir.Services.TaskService:GetTimeSeconds()
time = time + ((now - last) * Noir.Services.TaskService.DeltaTicks)
last = now
print(("%.1f seconds passed"):format(time))
end, 1, nil, true) -- This task is repeating every tick
- Added
Deprecation
, a new built-in library. This library allows you to mark functions as deprecated.
---@deprecated <-- for intellisense. recommended to add
function HelloWorld()
Noir.Libraries.Deprecation:Deprecated("HelloWorld", "AnOptionalReplacementFunction", "An optional note appended to the deprecation message")
print("Hello World")
end
HelloWorld()
-- [Noir] [Warning] [Deprecated] 'HelloWorld' is deprecated. Please use 'AnOptionalReplacementFunction' instead.
-- [Noir] [Warning] [Deprecated] An optional note appended to the deprecation message
- Added
RawTPS
toTPSService
. This is simply the TPS divided by the amount of ticks peronTick
call.
Changes
- Notification methods in
NotificationService
now acceptnil
for theplayer
parameter - The project manager tool now places
main.lua
into asrc
folder - Players, objects, etc, are now loaded before
Noir.Started
is fired. This means you can now fetch something like the host player directly inNoir.Started
instead of having to wait a tick or wait for an event likePlayerService
'sOnJoin
event. - Event argument descriptions are now consistent across Noir. Example:
Arguments: player (NoirPlayer), vehicle (NoirVehicle)
- IDs in classes like
NoirPlayer
andNoirObject
are now converted to integers sinceg_savedata
turns integers into floats. Noir.Libraries.JSON:Decode()
no longer errors if the string to decode is invalid JSON. This change was made because HTTP request responses, a commonly JSON-decoded thing, are unpredictable and can sometimes not be JSON-decoded due to invalid JSON, etc. Especially with the lack of apcall
function in SW Lua for error handling, the errors just weren't needed.
Fixes
- Fixed
NoirMessage
serialization regarding the recipient.
Removals
- Removed unnecessary duplicate
:_LoadSavedMessages()
call inMessageService
that may have caused issues.