Skip to content

Noir 1.14.0

Latest
Compare
Choose a tag to compare
@Cuh4 Cuh4 released this 21 Oct 09:45
· 5 commits to main since this release

πŸ“š 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 and OnUnsit events to the PlayerService.

  • The project manager tool now adds example services and libraries.

  • Added an OnBodyDamage event to the VehicleService. An OnDamage event has been added to the NoirBody class too. As the name suggests, this event is fired when the body takes damage.

  • Added :SpawnExplosion() method to the ObjectService. This method doesn't return an object, just purely spawns an explosion.

  • RecognizedIDs in PlayerService's g_savedata table is now cleared when players are loaded to prevent g_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 by server.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 of TaskService 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 to TPSService. This is simply the TPS divided by the amount of ticks per onTick call.

Changes

  • Notification methods in NotificationService now accept nil for the player parameter
  • The project manager tool now places main.lua into a src folder
  • Players, objects, etc, are now loaded before Noir.Started is fired. This means you can now fetch something like the host player directly in Noir.Started instead of having to wait a tick or wait for an event like PlayerService's OnJoin event.
  • Event argument descriptions are now consistent across Noir. Example: Arguments: player (NoirPlayer), vehicle (NoirVehicle)
  • IDs in classes like NoirPlayer and NoirObject are now converted to integers since g_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 a pcall 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 in MessageService that may have caused issues.