World
APIs related to the Just Cause 4 game world.
Global Methods
World.GetObjectByNID(nid: number): NetObject | nil
Returns the network object with the given network id.
World.GetAllByType(type: NetObjectType): NetObject[]
Returns network objects with the given type.
World.SetTime(value: number)
Sets the current world time. 12 is noon, and 0 is midnight.
Example usage:
World.GetTime(): number
Gets the current time of the world.
World.SetTimescale(value: number)
Sets the world timescale. This value determines how fast the day/night cycle runs. The default value is 1. Higher values make the day pass by quicker, and a value of 0 means that the time will never change.
World.GetTimescale(): number
Gets the current timescale of the world.
World.GetRenderDeltaTime(): number
Returns the time elapsed, in milliseconds, between the last two frames. This value can fluctuate depending on the frame rate.
World.GetUpdateDeltaTime(): number
Returns the fixed time step, in milliseconds, used for physics and game logic updates.
World.SetGravity(value: vec3)
Sets the world gravity. This affects everything in the world except for regular player movement. If a player enters ragdoll, this will affect the ragdoll gravity.
Example usage to enable anti-gravity:
World.SetGravity(vec3(0,0,0))
World.GetGravity(): vec3
Gets the current gravity of the world. Default is vec3(0, -9.8, 0).
World.SpawnPOI(position: vec3, type: POIType, display_mode: POIDisplayMode, minDistance: number, maxDistance: number): POI
Spawns a POI at the given position with the given type and display mode.
World.SetWaypoint(position: vec3)
Sets the waypoint to the given position.
World.ClearWaypoint()
Clears the waypoint.
World.SpawnRigidObject(position: vec3, model: string, collision: string, motionType: RigidObjectMotionType, rotation?: vec3, health?: number): RigidObject
Spawns a rigid object at the given position with the given rotation. This is synced to all players. See the objects list for a complete list of objects to spawn.
World.GetWaypoint(): POI
Returns the current waypoint as a POI instance. Note that this POI instance is not usable for now and doesn't have any methods available.
Returns: POI - The current waypoint POI instance
World.GetWaypointPosition(): vec3
Returns the position of the current waypoint.
Returns: vec3 - The position of the current waypoint
World.GetWaterLevel(position: vec3): pair<float, bool>
Gets the water level at the specified position.
Parameters:
position: vec3- The position to check for water level
Returns: pair<float, bool> - The water level (float) and whether the water is a waterfall (bool)
Example:
local waterLevel, isWaterfall = World.GetWaterLevel(vec3(100, 50, 200))
if waterLevel > 0 then
if isWaterfall then
print("Waterfall detected at level: " .. waterLevel)
else
print("Water detected at level: " .. waterLevel)
end
end